babylon.d.ts 2.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019
  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. private _moveAssets;
  165. /**
  166. * Removes all the assets contained in the scene and adds them to the container.
  167. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  168. */
  169. moveAllFromScene(keepAssets?: KeepAssets): void;
  170. /**
  171. * 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.
  172. * @returns the root mesh
  173. */
  174. createRootMesh(): Mesh;
  175. }
  176. }
  177. interface Window {
  178. mozIndexedDB: IDBFactory;
  179. webkitIndexedDB: IDBFactory;
  180. msIndexedDB: IDBFactory;
  181. webkitURL: typeof URL;
  182. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  183. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  184. WebGLRenderingContext: WebGLRenderingContext;
  185. MSGesture: MSGesture;
  186. CANNON: any;
  187. AudioContext: AudioContext;
  188. webkitAudioContext: AudioContext;
  189. PointerEvent: any;
  190. Math: Math;
  191. Uint8Array: Uint8ArrayConstructor;
  192. Float32Array: Float32ArrayConstructor;
  193. mozURL: typeof URL;
  194. msURL: typeof URL;
  195. VRFrameData: any;
  196. DracoDecoderModule: any;
  197. setImmediate(handler: (...args: any[]) => void): number;
  198. }
  199. interface WebGLProgram {
  200. context?: WebGLRenderingContext;
  201. vertexShader?: WebGLShader;
  202. fragmentShader?: WebGLShader;
  203. isParallelCompiled: boolean;
  204. onCompiled?: () => void;
  205. }
  206. interface WebGLRenderingContext {
  207. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  208. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  209. vertexAttribDivisor(index: number, divisor: number): void;
  210. createVertexArray(): any;
  211. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  212. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  213. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  214. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  215. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  216. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  217. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  218. createQuery(): WebGLQuery;
  219. deleteQuery(query: WebGLQuery): void;
  220. beginQuery(target: number, query: WebGLQuery): void;
  221. endQuery(target: number): void;
  222. getQueryParameter(query: WebGLQuery, pname: number): any;
  223. getQuery(target: number, pname: number): any;
  224. MAX_SAMPLES: number;
  225. RGBA8: number;
  226. READ_FRAMEBUFFER: number;
  227. DRAW_FRAMEBUFFER: number;
  228. UNIFORM_BUFFER: number;
  229. HALF_FLOAT_OES: number;
  230. RGBA16F: number;
  231. RGBA32F: number;
  232. R32F: number;
  233. RG32F: number;
  234. RGB32F: number;
  235. R16F: number;
  236. RG16F: number;
  237. RGB16F: number;
  238. RED: number;
  239. RG: number;
  240. R8: number;
  241. RG8: number;
  242. UNSIGNED_INT_24_8: number;
  243. DEPTH24_STENCIL8: number;
  244. drawBuffers(buffers: number[]): void;
  245. readBuffer(src: number): void;
  246. readonly COLOR_ATTACHMENT0: number;
  247. readonly COLOR_ATTACHMENT1: number;
  248. readonly COLOR_ATTACHMENT2: number;
  249. readonly COLOR_ATTACHMENT3: number;
  250. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  251. ANY_SAMPLES_PASSED: number;
  252. QUERY_RESULT_AVAILABLE: number;
  253. QUERY_RESULT: number;
  254. }
  255. interface Document {
  256. mozCancelFullScreen(): void;
  257. msCancelFullScreen(): void;
  258. webkitCancelFullScreen(): void;
  259. requestPointerLock(): void;
  260. exitPointerLock(): void;
  261. mozFullScreen: boolean;
  262. msIsFullScreen: boolean;
  263. readonly webkitIsFullScreen: boolean;
  264. readonly pointerLockElement: Element;
  265. mozPointerLockElement: HTMLElement;
  266. msPointerLockElement: HTMLElement;
  267. webkitPointerLockElement: HTMLElement;
  268. }
  269. interface HTMLCanvasElement {
  270. requestPointerLock(): void;
  271. msRequestPointerLock?(): void;
  272. mozRequestPointerLock?(): void;
  273. webkitRequestPointerLock?(): void;
  274. }
  275. interface CanvasRenderingContext2D {
  276. msImageSmoothingEnabled: boolean;
  277. }
  278. interface WebGLBuffer {
  279. references: number;
  280. capacity: number;
  281. is32Bits: boolean;
  282. }
  283. interface WebGLProgram {
  284. transformFeedback?: WebGLTransformFeedback | null;
  285. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  286. }
  287. interface MouseEvent {
  288. mozMovementX: number;
  289. mozMovementY: number;
  290. webkitMovementX: number;
  291. webkitMovementY: number;
  292. msMovementX: number;
  293. msMovementY: number;
  294. }
  295. interface Navigator {
  296. mozGetVRDevices: (any: any) => any;
  297. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  298. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  299. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  300. webkitGetGamepads(): Gamepad[];
  301. msGetGamepads(): Gamepad[];
  302. webkitGamepads(): Gamepad[];
  303. }
  304. interface HTMLVideoElement {
  305. mozSrcObject: any;
  306. }
  307. interface Math {
  308. fround(x: number): number;
  309. imul(a: number, b: number): number;
  310. }
  311. interface EXT_disjoint_timer_query {
  312. QUERY_COUNTER_BITS_EXT: number;
  313. TIME_ELAPSED_EXT: number;
  314. TIMESTAMP_EXT: number;
  315. GPU_DISJOINT_EXT: number;
  316. QUERY_RESULT_EXT: number;
  317. QUERY_RESULT_AVAILABLE_EXT: number;
  318. queryCounterEXT(query: WebGLQuery, target: number): void;
  319. createQueryEXT(): WebGLQuery;
  320. beginQueryEXT(target: number, query: WebGLQuery): void;
  321. endQueryEXT(target: number): void;
  322. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  323. deleteQueryEXT(query: WebGLQuery): void;
  324. }
  325. interface WebGLUniformLocation {
  326. _currentState: any;
  327. }
  328. interface XRDevice {
  329. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  330. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  331. }
  332. interface XRSession {
  333. getInputSources(): Array<any>;
  334. baseLayer: XRWebGLLayer;
  335. requestFrameOfReference(type: string): Promise<void>;
  336. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  337. end(): Promise<void>;
  338. requestAnimationFrame: Function;
  339. addEventListener: Function;
  340. }
  341. interface XRSessionCreationOptions {
  342. outputContext?: WebGLRenderingContext | null;
  343. immersive?: boolean;
  344. environmentIntegration?: boolean;
  345. }
  346. interface XRLayer {
  347. getViewport: Function;
  348. framebufferWidth: number;
  349. framebufferHeight: number;
  350. }
  351. interface XRView {
  352. projectionMatrix: Float32Array;
  353. }
  354. interface XRFrame {
  355. getDevicePose: Function;
  356. getInputPose: Function;
  357. views: Array<XRView>;
  358. baseLayer: XRLayer;
  359. }
  360. interface XRFrameOfReference {
  361. }
  362. interface XRWebGLLayer extends XRLayer {
  363. framebuffer: WebGLFramebuffer;
  364. }
  365. declare var XRWebGLLayer: {
  366. prototype: XRWebGLLayer;
  367. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  368. };
  369. declare module BABYLON {
  370. /**
  371. * Defines how a node can be built from a string name.
  372. */
  373. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  374. /**
  375. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  376. */
  377. class Node implements IBehaviorAware<Node> {
  378. private static _NodeConstructors;
  379. /**
  380. * Add a new node constructor
  381. * @param type defines the type name of the node to construct
  382. * @param constructorFunc defines the constructor function
  383. */
  384. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  385. /**
  386. * Returns a node constructor based on type name
  387. * @param type defines the type name
  388. * @param name defines the new node name
  389. * @param scene defines the hosting scene
  390. * @param options defines optional options to transmit to constructors
  391. * @returns the new constructor or null
  392. */
  393. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  394. /**
  395. * Gets or sets the name of the node
  396. */
  397. name: string;
  398. /**
  399. * Gets or sets the id of the node
  400. */
  401. id: string;
  402. /**
  403. * Gets or sets the unique id of the node
  404. */
  405. uniqueId: number;
  406. /**
  407. * Gets or sets a string used to store user defined state for the node
  408. */
  409. state: string;
  410. /**
  411. * Gets or sets an object used to store user defined information for the node
  412. */
  413. metadata: any;
  414. /**
  415. * Gets or sets a boolean used to define if the node must be serialized
  416. */
  417. doNotSerialize: boolean;
  418. /** @hidden */
  419. _isDisposed: boolean;
  420. /**
  421. * Gets a list of Animations associated with the node
  422. */
  423. animations: Animation[];
  424. protected _ranges: {
  425. [name: string]: Nullable<AnimationRange>;
  426. };
  427. /**
  428. * Callback raised when the node is ready to be used
  429. */
  430. onReady: (node: Node) => void;
  431. private _isEnabled;
  432. private _isParentEnabled;
  433. private _isReady;
  434. /** @hidden */
  435. _currentRenderId: number;
  436. private _parentRenderId;
  437. protected _childRenderId: number;
  438. /** @hidden */
  439. _waitingParentId: Nullable<string>;
  440. /** @hidden */
  441. _scene: Scene;
  442. /** @hidden */
  443. _cache: any;
  444. private _parentNode;
  445. private _children;
  446. /** @hidden */
  447. _worldMatrix: Matrix;
  448. /** @hidden */
  449. _worldMatrixDeterminant: number;
  450. /** @hidden */
  451. private _sceneRootNodesIndex;
  452. /**
  453. * Gets a boolean indicating if the node has been disposed
  454. * @returns true if the node was disposed
  455. */
  456. isDisposed(): boolean;
  457. /**
  458. * Gets or sets the parent of the node
  459. */
  460. parent: Nullable<Node>;
  461. private addToSceneRootNodes;
  462. private removeFromSceneRootNodes;
  463. private _animationPropertiesOverride;
  464. /**
  465. * Gets or sets the animation properties override
  466. */
  467. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  468. /**
  469. * Gets a string idenfifying the name of the class
  470. * @returns "Node" string
  471. */
  472. getClassName(): string;
  473. /**
  474. * An event triggered when the mesh is disposed
  475. */
  476. onDisposeObservable: Observable<Node>;
  477. private _onDisposeObserver;
  478. /**
  479. * Sets a callback that will be raised when the node will be disposed
  480. */
  481. onDispose: () => void;
  482. /**
  483. * Creates a new Node
  484. * @param name the name and id to be given to this node
  485. * @param scene the scene this node will be added to
  486. * @param addToRootNodes the node will be added to scene.rootNodes
  487. */
  488. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  489. /**
  490. * Gets the scene of the node
  491. * @returns a scene
  492. */
  493. getScene(): Scene;
  494. /**
  495. * Gets the engine of the node
  496. * @returns a Engine
  497. */
  498. getEngine(): Engine;
  499. private _behaviors;
  500. /**
  501. * Attach a behavior to the node
  502. * @see http://doc.babylonjs.com/features/behaviour
  503. * @param behavior defines the behavior to attach
  504. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  505. * @returns the current Node
  506. */
  507. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  508. /**
  509. * Remove an attached behavior
  510. * @see http://doc.babylonjs.com/features/behaviour
  511. * @param behavior defines the behavior to attach
  512. * @returns the current Node
  513. */
  514. removeBehavior(behavior: Behavior<Node>): Node;
  515. /**
  516. * Gets the list of attached behaviors
  517. * @see http://doc.babylonjs.com/features/behaviour
  518. */
  519. readonly behaviors: Behavior<Node>[];
  520. /**
  521. * Gets an attached behavior by name
  522. * @param name defines the name of the behavior to look for
  523. * @see http://doc.babylonjs.com/features/behaviour
  524. * @returns null if behavior was not found else the requested behavior
  525. */
  526. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  527. /**
  528. * Returns the latest update of the World matrix
  529. * @returns a Matrix
  530. */
  531. getWorldMatrix(): Matrix;
  532. /** @hidden */
  533. _getWorldMatrixDeterminant(): number;
  534. /**
  535. * Returns directly the latest state of the mesh World matrix.
  536. * A Matrix is returned.
  537. */
  538. readonly worldMatrixFromCache: Matrix;
  539. /** @hidden */
  540. _initCache(): void;
  541. /** @hidden */
  542. updateCache(force?: boolean): void;
  543. /** @hidden */
  544. _updateCache(ignoreParentClass?: boolean): void;
  545. /** @hidden */
  546. _isSynchronized(): boolean;
  547. /** @hidden */
  548. _markSyncedWithParent(): void;
  549. /** @hidden */
  550. isSynchronizedWithParent(): boolean;
  551. /** @hidden */
  552. isSynchronized(): boolean;
  553. /**
  554. * Is this node ready to be used/rendered
  555. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  556. * @return true if the node is ready
  557. */
  558. isReady(completeCheck?: boolean): boolean;
  559. /**
  560. * Is this node enabled?
  561. * 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
  562. * @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
  563. * @return whether this node (and its parent) is enabled
  564. */
  565. isEnabled(checkAncestors?: boolean): boolean;
  566. /** @hidden */
  567. protected _syncParentEnabledState(): void;
  568. /**
  569. * Set the enabled state of this node
  570. * @param value defines the new enabled state
  571. */
  572. setEnabled(value: boolean): void;
  573. /**
  574. * Is this node a descendant of the given node?
  575. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  576. * @param ancestor defines the parent node to inspect
  577. * @returns a boolean indicating if this node is a descendant of the given node
  578. */
  579. isDescendantOf(ancestor: Node): boolean;
  580. /** @hidden */
  581. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  582. /**
  583. * Will return all nodes that have this node as ascendant
  584. * @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
  585. * @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
  586. * @return all children nodes of all types
  587. */
  588. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  589. /**
  590. * Get all child-meshes of this node
  591. * @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
  592. * @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
  593. * @returns an array of AbstractMesh
  594. */
  595. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  596. /**
  597. * Get all child-transformNodes of this node
  598. * @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
  599. * @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
  600. * @returns an array of TransformNode
  601. */
  602. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  603. /**
  604. * Get all direct children of this node
  605. * @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
  606. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  607. * @returns an array of Node
  608. */
  609. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  610. /** @hidden */
  611. _setReady(state: boolean): void;
  612. /**
  613. * Get an animation by name
  614. * @param name defines the name of the animation to look for
  615. * @returns null if not found else the requested animation
  616. */
  617. getAnimationByName(name: string): Nullable<Animation>;
  618. /**
  619. * Creates an animation range for this node
  620. * @param name defines the name of the range
  621. * @param from defines the starting key
  622. * @param to defines the end key
  623. */
  624. createAnimationRange(name: string, from: number, to: number): void;
  625. /**
  626. * Delete a specific animation range
  627. * @param name defines the name of the range to delete
  628. * @param deleteFrames defines if animation frames from the range must be deleted as well
  629. */
  630. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  631. /**
  632. * Get an animation range by name
  633. * @param name defines the name of the animation range to look for
  634. * @returns null if not found else the requested animation range
  635. */
  636. getAnimationRange(name: string): Nullable<AnimationRange>;
  637. /**
  638. * Will start the animation sequence
  639. * @param name defines the range frames for animation sequence
  640. * @param loop defines if the animation should loop (false by default)
  641. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  642. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  643. * @returns the object created for this animation. If range does not exist, it will return null
  644. */
  645. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  646. /**
  647. * Serialize animation ranges into a JSON compatible object
  648. * @returns serialization object
  649. */
  650. serializeAnimationRanges(): any;
  651. /**
  652. * Computes the world matrix of the node
  653. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  654. * @returns the world matrix
  655. */
  656. computeWorldMatrix(force?: boolean): Matrix;
  657. /**
  658. * Releases resources associated with this node.
  659. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  660. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  661. */
  662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  663. /**
  664. * Parse animation range data from a serialization object and store them into a given node
  665. * @param node defines where to store the animation ranges
  666. * @param parsedNode defines the serialization object to read data from
  667. * @param scene defines the hosting scene
  668. */
  669. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  670. }
  671. }
  672. declare module BABYLON {
  673. /**
  674. * Define an interface for all classes that will hold resources
  675. */
  676. interface IDisposable {
  677. /**
  678. * Releases all held resources
  679. */
  680. dispose(): void;
  681. }
  682. /**
  683. * This class is used by the onRenderingGroupObservable
  684. */
  685. class RenderingGroupInfo {
  686. /**
  687. * The Scene that being rendered
  688. */
  689. scene: Scene;
  690. /**
  691. * The camera currently used for the rendering pass
  692. */
  693. camera: Nullable<Camera>;
  694. /**
  695. * The ID of the renderingGroup being processed
  696. */
  697. renderingGroupId: number;
  698. }
  699. /** Interface defining initialization parameters for Scene class */
  700. interface SceneOptions {
  701. /**
  702. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  703. * It will improve performance when the number of geometries becomes important.
  704. */
  705. useGeometryIdsMap?: boolean;
  706. /**
  707. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  708. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  709. */
  710. useMaterialMeshMap?: boolean;
  711. /**
  712. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  713. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  714. */
  715. useClonedMeshhMap?: boolean;
  716. }
  717. /**
  718. * Represents a scene to be rendered by the engine.
  719. * @see http://doc.babylonjs.com/features/scene
  720. */
  721. class Scene extends AbstractScene implements IAnimatable {
  722. private static _uniqueIdCounter;
  723. /** The fog is deactivated */
  724. static readonly FOGMODE_NONE: number;
  725. /** The fog density is following an exponential function */
  726. static readonly FOGMODE_EXP: number;
  727. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  728. static readonly FOGMODE_EXP2: number;
  729. /** The fog density is following a linear function. */
  730. static readonly FOGMODE_LINEAR: number;
  731. /**
  732. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  733. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  734. */
  735. static MinDeltaTime: number;
  736. /**
  737. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  739. */
  740. static MaxDeltaTime: number;
  741. /**
  742. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  743. */
  744. autoClear: boolean;
  745. /**
  746. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  747. */
  748. autoClearDepthAndStencil: boolean;
  749. /**
  750. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  751. */
  752. clearColor: Color4;
  753. /**
  754. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  755. */
  756. ambientColor: Color3;
  757. /** @hidden */
  758. _environmentBRDFTexture: BaseTexture;
  759. /** @hidden */
  760. protected _environmentTexture: BaseTexture;
  761. /**
  762. * Texture used in all pbr material as the reflection texture.
  763. * As in the majority of the scene they are the same (exception for multi room and so on),
  764. * this is easier to reference from here than from all the materials.
  765. */
  766. /**
  767. * Texture used in all pbr material as the reflection texture.
  768. * As in the majority of the scene they are the same (exception for multi room and so on),
  769. * this is easier to set here than in all the materials.
  770. */
  771. environmentTexture: BaseTexture;
  772. /** @hidden */
  773. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  774. /**
  775. * Default image processing configuration used either in the rendering
  776. * Forward main pass or through the imageProcessingPostProcess if present.
  777. * As in the majority of the scene they are the same (exception for multi camera),
  778. * this is easier to reference from here than from all the materials and post process.
  779. *
  780. * No setter as we it is a shared configuration, you can set the values instead.
  781. */
  782. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  783. private _forceWireframe;
  784. /**
  785. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  786. */
  787. forceWireframe: boolean;
  788. private _forcePointsCloud;
  789. /**
  790. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  791. */
  792. forcePointsCloud: boolean;
  793. /**
  794. * Gets or sets the active clipplane 1
  795. */
  796. clipPlane: Nullable<Plane>;
  797. /**
  798. * Gets or sets the active clipplane 2
  799. */
  800. clipPlane2: Nullable<Plane>;
  801. /**
  802. * Gets or sets the active clipplane 3
  803. */
  804. clipPlane3: Nullable<Plane>;
  805. /**
  806. * Gets or sets the active clipplane 4
  807. */
  808. clipPlane4: Nullable<Plane>;
  809. /**
  810. * Gets or sets a boolean indicating if animations are enabled
  811. */
  812. animationsEnabled: boolean;
  813. private _animationPropertiesOverride;
  814. /**
  815. * Gets or sets the animation properties override
  816. */
  817. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  818. /**
  819. * Gets or sets a boolean indicating if a constant deltatime has to be used
  820. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  821. */
  822. useConstantAnimationDeltaTime: boolean;
  823. /**
  824. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  825. * Please note that it requires to run a ray cast through the scene on every frame
  826. */
  827. constantlyUpdateMeshUnderPointer: boolean;
  828. /**
  829. * Defines the HTML cursor to use when hovering over interactive elements
  830. */
  831. hoverCursor: string;
  832. /**
  833. * Defines the HTML default cursor to use (empty by default)
  834. */
  835. defaultCursor: string;
  836. /**
  837. * This is used to call preventDefault() on pointer down
  838. * in order to block unwanted artifacts like system double clicks
  839. */
  840. preventDefaultOnPointerDown: boolean;
  841. /**
  842. * This is used to call preventDefault() on pointer up
  843. * in order to block unwanted artifacts like system double clicks
  844. */
  845. preventDefaultOnPointerUp: boolean;
  846. /**
  847. * Gets or sets user defined metadata
  848. */
  849. metadata: any;
  850. /**
  851. * Gets the name of the plugin used to load this scene (null by default)
  852. */
  853. loadingPluginName: string;
  854. /**
  855. * Use this array to add regular expressions used to disable offline support for specific urls
  856. */
  857. disableOfflineSupportExceptionRules: RegExp[];
  858. /**
  859. * An event triggered when the scene is disposed.
  860. */
  861. onDisposeObservable: Observable<Scene>;
  862. private _onDisposeObserver;
  863. /** Sets a function to be executed when this scene is disposed. */
  864. onDispose: () => void;
  865. /**
  866. * An event triggered before rendering the scene (right after animations and physics)
  867. */
  868. onBeforeRenderObservable: Observable<Scene>;
  869. private _onBeforeRenderObserver;
  870. /** Sets a function to be executed before rendering this scene */
  871. beforeRender: Nullable<() => void>;
  872. /**
  873. * An event triggered after rendering the scene
  874. */
  875. onAfterRenderObservable: Observable<Scene>;
  876. private _onAfterRenderObserver;
  877. /** Sets a function to be executed after rendering this scene */
  878. afterRender: Nullable<() => void>;
  879. /**
  880. * An event triggered before animating the scene
  881. */
  882. onBeforeAnimationsObservable: Observable<Scene>;
  883. /**
  884. * An event triggered after animations processing
  885. */
  886. onAfterAnimationsObservable: Observable<Scene>;
  887. /**
  888. * An event triggered before draw calls are ready to be sent
  889. */
  890. onBeforeDrawPhaseObservable: Observable<Scene>;
  891. /**
  892. * An event triggered after draw calls have been sent
  893. */
  894. onAfterDrawPhaseObservable: Observable<Scene>;
  895. /**
  896. * An event triggered when the scene is ready
  897. */
  898. onReadyObservable: Observable<Scene>;
  899. /**
  900. * An event triggered before rendering a camera
  901. */
  902. onBeforeCameraRenderObservable: Observable<Camera>;
  903. private _onBeforeCameraRenderObserver;
  904. /** Sets a function to be executed before rendering a camera*/
  905. beforeCameraRender: () => void;
  906. /**
  907. * An event triggered after rendering a camera
  908. */
  909. onAfterCameraRenderObservable: Observable<Camera>;
  910. private _onAfterCameraRenderObserver;
  911. /** Sets a function to be executed after rendering a camera*/
  912. afterCameraRender: () => void;
  913. /**
  914. * An event triggered when active meshes evaluation is about to start
  915. */
  916. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  917. /**
  918. * An event triggered when active meshes evaluation is done
  919. */
  920. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  921. /**
  922. * An event triggered when particles rendering is about to start
  923. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  924. */
  925. onBeforeParticlesRenderingObservable: Observable<Scene>;
  926. /**
  927. * An event triggered when particles rendering is done
  928. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  929. */
  930. onAfterParticlesRenderingObservable: Observable<Scene>;
  931. /**
  932. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  933. */
  934. onDataLoadedObservable: Observable<Scene>;
  935. /**
  936. * An event triggered when a camera is created
  937. */
  938. onNewCameraAddedObservable: Observable<Camera>;
  939. /**
  940. * An event triggered when a camera is removed
  941. */
  942. onCameraRemovedObservable: Observable<Camera>;
  943. /**
  944. * An event triggered when a light is created
  945. */
  946. onNewLightAddedObservable: Observable<Light>;
  947. /**
  948. * An event triggered when a light is removed
  949. */
  950. onLightRemovedObservable: Observable<Light>;
  951. /**
  952. * An event triggered when a geometry is created
  953. */
  954. onNewGeometryAddedObservable: Observable<Geometry>;
  955. /**
  956. * An event triggered when a geometry is removed
  957. */
  958. onGeometryRemovedObservable: Observable<Geometry>;
  959. /**
  960. * An event triggered when a transform node is created
  961. */
  962. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  963. /**
  964. * An event triggered when a transform node is removed
  965. */
  966. onTransformNodeRemovedObservable: Observable<TransformNode>;
  967. /**
  968. * An event triggered when a mesh is created
  969. */
  970. onNewMeshAddedObservable: Observable<AbstractMesh>;
  971. /**
  972. * An event triggered when a mesh is removed
  973. */
  974. onMeshRemovedObservable: Observable<AbstractMesh>;
  975. /**
  976. * An event triggered when a material is created
  977. */
  978. onNewMaterialAddedObservable: Observable<Material>;
  979. /**
  980. * An event triggered when a material is removed
  981. */
  982. onMaterialRemovedObservable: Observable<Material>;
  983. /**
  984. * An event triggered when a texture is created
  985. */
  986. onNewTextureAddedObservable: Observable<BaseTexture>;
  987. /**
  988. * An event triggered when a texture is removed
  989. */
  990. onTextureRemovedObservable: Observable<BaseTexture>;
  991. /**
  992. * An event triggered when render targets are about to be rendered
  993. * Can happen multiple times per frame.
  994. */
  995. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  996. /**
  997. * An event triggered when render targets were rendered.
  998. * Can happen multiple times per frame.
  999. */
  1000. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  1001. /**
  1002. * An event triggered before calculating deterministic simulation step
  1003. */
  1004. onBeforeStepObservable: Observable<Scene>;
  1005. /**
  1006. * An event triggered after calculating deterministic simulation step
  1007. */
  1008. onAfterStepObservable: Observable<Scene>;
  1009. /**
  1010. * An event triggered when the activeCamera property is updated
  1011. */
  1012. onActiveCameraChanged: Observable<Scene>;
  1013. /**
  1014. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1015. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1016. * 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)
  1017. */
  1018. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1019. /**
  1020. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1021. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1022. * 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)
  1023. */
  1024. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1025. /**
  1026. * This Observable will when a mesh has been imported into the scene.
  1027. */
  1028. onMeshImportedObservable: Observable<AbstractMesh>;
  1029. private _registeredForLateAnimationBindings;
  1030. /**
  1031. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1032. */
  1033. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1034. /**
  1035. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1036. */
  1037. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1038. /**
  1039. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1040. */
  1041. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1042. private _onPointerMove;
  1043. private _onPointerDown;
  1044. private _onPointerUp;
  1045. /** Callback called when a pointer move is detected */
  1046. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1047. /** Callback called when a pointer down is detected */
  1048. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1049. /** Callback called when a pointer up is detected */
  1050. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1051. /** Callback called when a pointer pick is detected */
  1052. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1053. /**
  1054. * 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).
  1055. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1056. */
  1057. onPrePointerObservable: Observable<PointerInfoPre>;
  1058. /**
  1059. * Observable event triggered each time an input event is received from the rendering canvas
  1060. */
  1061. onPointerObservable: Observable<PointerInfo>;
  1062. /**
  1063. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1064. */
  1065. readonly unTranslatedPointer: Vector2;
  1066. /** The distance in pixel that you have to move to prevent some events */
  1067. static DragMovementThreshold: number;
  1068. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1069. static LongPressDelay: number;
  1070. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1071. static DoubleClickDelay: number;
  1072. /** If you need to check double click without raising a single click at first click, enable this flag */
  1073. static ExclusiveDoubleClickMode: boolean;
  1074. private _initClickEvent;
  1075. private _initActionManager;
  1076. private _delayedSimpleClick;
  1077. private _delayedSimpleClickTimeout;
  1078. private _previousDelayedSimpleClickTimeout;
  1079. private _meshPickProceed;
  1080. private _previousButtonPressed;
  1081. private _currentPickResult;
  1082. private _previousPickResult;
  1083. private _totalPointersPressed;
  1084. private _doubleClickOccured;
  1085. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1086. cameraToUseForPointers: Nullable<Camera>;
  1087. private _pointerX;
  1088. private _pointerY;
  1089. private _unTranslatedPointerX;
  1090. private _unTranslatedPointerY;
  1091. private _startingPointerPosition;
  1092. private _previousStartingPointerPosition;
  1093. private _startingPointerTime;
  1094. private _previousStartingPointerTime;
  1095. private _pointerCaptures;
  1096. private _timeAccumulator;
  1097. private _currentStepId;
  1098. private _currentInternalStep;
  1099. /** @hidden */
  1100. _mirroredCameraPosition: Nullable<Vector3>;
  1101. /**
  1102. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1103. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1104. */
  1105. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1106. /**
  1107. * Observable event triggered each time an keyboard event is received from the hosting window
  1108. */
  1109. onKeyboardObservable: Observable<KeyboardInfo>;
  1110. private _onKeyDown;
  1111. private _onKeyUp;
  1112. private _onCanvasFocusObserver;
  1113. private _onCanvasBlurObserver;
  1114. private _useRightHandedSystem;
  1115. /**
  1116. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1117. */
  1118. useRightHandedSystem: boolean;
  1119. /**
  1120. * Sets the step Id used by deterministic lock step
  1121. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1122. * @param newStepId defines the step Id
  1123. */
  1124. setStepId(newStepId: number): void;
  1125. /**
  1126. * Gets the step Id used by deterministic lock step
  1127. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1128. * @returns the step Id
  1129. */
  1130. getStepId(): number;
  1131. /**
  1132. * Gets the internal step used by deterministic lock step
  1133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1134. * @returns the internal step
  1135. */
  1136. getInternalStep(): number;
  1137. private _fogEnabled;
  1138. /**
  1139. * Gets or sets a boolean indicating if fog is enabled on this scene
  1140. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1141. * (Default is true)
  1142. */
  1143. fogEnabled: boolean;
  1144. private _fogMode;
  1145. /**
  1146. * Gets or sets the fog mode to use
  1147. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1148. * | mode | value |
  1149. * | --- | --- |
  1150. * | FOGMODE_NONE | 0 |
  1151. * | FOGMODE_EXP | 1 |
  1152. * | FOGMODE_EXP2 | 2 |
  1153. * | FOGMODE_LINEAR | 3 |
  1154. */
  1155. fogMode: number;
  1156. /**
  1157. * Gets or sets the fog color to use
  1158. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1159. * (Default is Color3(0.2, 0.2, 0.3))
  1160. */
  1161. fogColor: Color3;
  1162. /**
  1163. * Gets or sets the fog density to use
  1164. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1165. * (Default is 0.1)
  1166. */
  1167. fogDensity: number;
  1168. /**
  1169. * Gets or sets the fog start distance to use
  1170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1171. * (Default is 0)
  1172. */
  1173. fogStart: number;
  1174. /**
  1175. * Gets or sets the fog end distance to use
  1176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1177. * (Default is 1000)
  1178. */
  1179. fogEnd: number;
  1180. private _shadowsEnabled;
  1181. /**
  1182. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1183. */
  1184. shadowsEnabled: boolean;
  1185. private _lightsEnabled;
  1186. /**
  1187. * Gets or sets a boolean indicating if lights are enabled on this scene
  1188. */
  1189. lightsEnabled: boolean;
  1190. /** All of the active cameras added to this scene. */
  1191. activeCameras: Camera[];
  1192. private _activeCamera;
  1193. /** Gets or sets the current active camera */
  1194. activeCamera: Nullable<Camera>;
  1195. private _defaultMaterial;
  1196. /** The default material used on meshes when no material is affected */
  1197. /** The default material used on meshes when no material is affected */
  1198. defaultMaterial: Material;
  1199. private _texturesEnabled;
  1200. /**
  1201. * Gets or sets a boolean indicating if textures are enabled on this scene
  1202. */
  1203. texturesEnabled: boolean;
  1204. /**
  1205. * Gets or sets a boolean indicating if particles are enabled on this scene
  1206. */
  1207. particlesEnabled: boolean;
  1208. /**
  1209. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1210. */
  1211. spritesEnabled: boolean;
  1212. private _skeletonsEnabled;
  1213. /**
  1214. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1215. */
  1216. skeletonsEnabled: boolean;
  1217. /**
  1218. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1219. */
  1220. lensFlaresEnabled: boolean;
  1221. /**
  1222. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1224. */
  1225. collisionsEnabled: boolean;
  1226. private _workerCollisions;
  1227. /** @hidden */
  1228. collisionCoordinator: ICollisionCoordinator;
  1229. /**
  1230. * Defines the gravity applied to this scene (used only for collisions)
  1231. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1232. */
  1233. gravity: Vector3;
  1234. /**
  1235. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1236. */
  1237. postProcessesEnabled: boolean;
  1238. /**
  1239. * The list of postprocesses added to the scene
  1240. */
  1241. postProcesses: PostProcess[];
  1242. /**
  1243. * Gets the current postprocess manager
  1244. */
  1245. postProcessManager: PostProcessManager;
  1246. /**
  1247. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1248. */
  1249. renderTargetsEnabled: boolean;
  1250. /**
  1251. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1252. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1253. */
  1254. dumpNextRenderTargets: boolean;
  1255. /**
  1256. * The list of user defined render targets added to the scene
  1257. */
  1258. customRenderTargets: RenderTargetTexture[];
  1259. /**
  1260. * Defines if texture loading must be delayed
  1261. * If true, textures will only be loaded when they need to be rendered
  1262. */
  1263. useDelayedTextureLoading: boolean;
  1264. /**
  1265. * Gets the list of meshes imported to the scene through SceneLoader
  1266. */
  1267. importedMeshesFiles: String[];
  1268. /**
  1269. * Gets or sets a boolean indicating if probes are enabled on this scene
  1270. */
  1271. probesEnabled: boolean;
  1272. /**
  1273. * Gets or sets the current offline provider to use to store scene data
  1274. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1275. */
  1276. offlineProvider: IOfflineProvider;
  1277. /**
  1278. * Gets or sets the action manager associated with the scene
  1279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1280. */
  1281. actionManager: ActionManager;
  1282. private _meshesForIntersections;
  1283. /**
  1284. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1285. */
  1286. proceduralTexturesEnabled: boolean;
  1287. private _engine;
  1288. private _totalVertices;
  1289. /** @hidden */
  1290. _activeIndices: PerfCounter;
  1291. /** @hidden */
  1292. _activeParticles: PerfCounter;
  1293. /** @hidden */
  1294. _activeBones: PerfCounter;
  1295. private _animationRatio;
  1296. private _animationTimeLast;
  1297. private _animationTime;
  1298. /**
  1299. * Gets or sets a general scale for animation speed
  1300. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1301. */
  1302. animationTimeScale: number;
  1303. /** @hidden */
  1304. _cachedMaterial: Nullable<Material>;
  1305. /** @hidden */
  1306. _cachedEffect: Nullable<Effect>;
  1307. /** @hidden */
  1308. _cachedVisibility: Nullable<number>;
  1309. private _renderId;
  1310. private _frameId;
  1311. private _executeWhenReadyTimeoutId;
  1312. private _intermediateRendering;
  1313. private _viewUpdateFlag;
  1314. private _projectionUpdateFlag;
  1315. private _alternateViewUpdateFlag;
  1316. private _alternateProjectionUpdateFlag;
  1317. /** @hidden */
  1318. _toBeDisposed: Nullable<IDisposable>[];
  1319. private _activeRequests;
  1320. private _pendingData;
  1321. private _isDisposed;
  1322. /**
  1323. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1324. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1325. */
  1326. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1327. private _activeMeshes;
  1328. private _processedMaterials;
  1329. private _renderTargets;
  1330. /** @hidden */
  1331. _activeParticleSystems: SmartArray<IParticleSystem>;
  1332. private _activeSkeletons;
  1333. private _softwareSkinnedMeshes;
  1334. private _renderingManager;
  1335. /** @hidden */
  1336. _activeAnimatables: Animatable[];
  1337. private _transformMatrix;
  1338. private _sceneUbo;
  1339. private _alternateSceneUbo;
  1340. private _pickWithRayInverseMatrix;
  1341. private _viewMatrix;
  1342. private _projectionMatrix;
  1343. private _alternateViewMatrix;
  1344. private _alternateProjectionMatrix;
  1345. private _alternateTransformMatrix;
  1346. private _useAlternateCameraConfiguration;
  1347. private _alternateRendering;
  1348. private _wheelEventName;
  1349. /** @hidden */
  1350. _forcedViewPosition: Nullable<Vector3>;
  1351. /** @hidden */
  1352. readonly _isAlternateRenderingEnabled: boolean;
  1353. private _frustumPlanes;
  1354. /**
  1355. * Gets the list of frustum planes (built from the active camera)
  1356. */
  1357. readonly frustumPlanes: Plane[];
  1358. /**
  1359. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1360. * This is useful if there are more lights that the maximum simulteanous authorized
  1361. */
  1362. requireLightSorting: boolean;
  1363. /** @hidden */
  1364. readonly useMaterialMeshMap: boolean;
  1365. /** @hidden */
  1366. readonly useClonedMeshhMap: boolean;
  1367. private _pointerOverMesh;
  1368. private _pickedDownMesh;
  1369. private _pickedUpMesh;
  1370. private _externalData;
  1371. private _uid;
  1372. /**
  1373. * @hidden
  1374. * Backing store of defined scene components.
  1375. */
  1376. _components: ISceneComponent[];
  1377. /**
  1378. * @hidden
  1379. * Backing store of defined scene components.
  1380. */
  1381. _serializableComponents: ISceneSerializableComponent[];
  1382. /**
  1383. * List of components to register on the next registration step.
  1384. */
  1385. private _transientComponents;
  1386. /**
  1387. * Registers the transient components if needed.
  1388. */
  1389. private _registerTransientComponents;
  1390. /**
  1391. * @hidden
  1392. * Add a component to the scene.
  1393. * Note that the ccomponent could be registered on th next frame if this is called after
  1394. * the register component stage.
  1395. * @param component Defines the component to add to the scene
  1396. */
  1397. _addComponent(component: ISceneComponent): void;
  1398. /**
  1399. * @hidden
  1400. * Gets a component from the scene.
  1401. * @param name defines the name of the component to retrieve
  1402. * @returns the component or null if not present
  1403. */
  1404. _getComponent(name: string): Nullable<ISceneComponent>;
  1405. /**
  1406. * @hidden
  1407. * Defines the actions happening before camera updates.
  1408. */
  1409. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1410. /**
  1411. * @hidden
  1412. * Defines the actions happening before clear the canvas.
  1413. */
  1414. _beforeClearStage: Stage<SimpleStageAction>;
  1415. /**
  1416. * @hidden
  1417. * Defines the actions when collecting render targets for the frame.
  1418. */
  1419. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1420. /**
  1421. * @hidden
  1422. * Defines the actions happening for one camera in the frame.
  1423. */
  1424. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1425. /**
  1426. * @hidden
  1427. * Defines the actions happening during the per mesh ready checks.
  1428. */
  1429. _isReadyForMeshStage: Stage<MeshStageAction>;
  1430. /**
  1431. * @hidden
  1432. * Defines the actions happening before evaluate active mesh checks.
  1433. */
  1434. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1435. /**
  1436. * @hidden
  1437. * Defines the actions happening during the evaluate sub mesh checks.
  1438. */
  1439. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1440. /**
  1441. * @hidden
  1442. * Defines the actions happening during the active mesh stage.
  1443. */
  1444. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1445. /**
  1446. * @hidden
  1447. * Defines the actions happening during the per camera render target step.
  1448. */
  1449. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1450. /**
  1451. * @hidden
  1452. * Defines the actions happening just before the active camera is drawing.
  1453. */
  1454. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1455. /**
  1456. * @hidden
  1457. * Defines the actions happening just before a rendering group is drawing.
  1458. */
  1459. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1460. /**
  1461. * @hidden
  1462. * Defines the actions happening just before a mesh is drawing.
  1463. */
  1464. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1465. /**
  1466. * @hidden
  1467. * Defines the actions happening just after a mesh has been drawn.
  1468. */
  1469. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1470. /**
  1471. * @hidden
  1472. * Defines the actions happening just after a rendering group has been drawn.
  1473. */
  1474. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1475. /**
  1476. * @hidden
  1477. * Defines the actions happening just after the active camera has been drawn.
  1478. */
  1479. _afterCameraDrawStage: Stage<CameraStageAction>;
  1480. /**
  1481. * @hidden
  1482. * Defines the actions happening just after rendering all cameras and computing intersections.
  1483. */
  1484. _afterRenderStage: Stage<SimpleStageAction>;
  1485. /**
  1486. * @hidden
  1487. * Defines the actions happening when a pointer move event happens.
  1488. */
  1489. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1490. /**
  1491. * @hidden
  1492. * Defines the actions happening when a pointer down event happens.
  1493. */
  1494. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1495. /**
  1496. * @hidden
  1497. * Defines the actions happening when a pointer up event happens.
  1498. */
  1499. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1500. /**
  1501. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1502. */
  1503. private geometriesById;
  1504. /**
  1505. * Creates a new Scene
  1506. * @param engine defines the engine to use to render this scene
  1507. */
  1508. constructor(engine: Engine, options?: SceneOptions);
  1509. private _defaultMeshCandidates;
  1510. /**
  1511. * @hidden
  1512. */
  1513. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1514. private _defaultSubMeshCandidates;
  1515. /**
  1516. * @hidden
  1517. */
  1518. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1519. /**
  1520. * Sets the default candidate providers for the scene.
  1521. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1522. * and getCollidingSubMeshCandidates to their default function
  1523. */
  1524. setDefaultCandidateProviders(): void;
  1525. /**
  1526. * Gets a boolean indicating if collisions are processed on a web worker
  1527. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1528. */
  1529. workerCollisions: boolean;
  1530. /**
  1531. * Gets the mesh that is currently under the pointer
  1532. */
  1533. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1534. /**
  1535. * Gets the current on-screen X position of the pointer
  1536. */
  1537. readonly pointerX: number;
  1538. /**
  1539. * Gets the current on-screen Y position of the pointer
  1540. */
  1541. readonly pointerY: number;
  1542. /**
  1543. * Gets the cached material (ie. the latest rendered one)
  1544. * @returns the cached material
  1545. */
  1546. getCachedMaterial(): Nullable<Material>;
  1547. /**
  1548. * Gets the cached effect (ie. the latest rendered one)
  1549. * @returns the cached effect
  1550. */
  1551. getCachedEffect(): Nullable<Effect>;
  1552. /**
  1553. * Gets the cached visibility state (ie. the latest rendered one)
  1554. * @returns the cached visibility state
  1555. */
  1556. getCachedVisibility(): Nullable<number>;
  1557. /**
  1558. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1559. * @param material defines the current material
  1560. * @param effect defines the current effect
  1561. * @param visibility defines the current visibility state
  1562. * @returns true if one parameter is not cached
  1563. */
  1564. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1565. /**
  1566. * Gets the engine associated with the scene
  1567. * @returns an Engine
  1568. */
  1569. getEngine(): Engine;
  1570. /**
  1571. * Gets the total number of vertices rendered per frame
  1572. * @returns the total number of vertices rendered per frame
  1573. */
  1574. getTotalVertices(): number;
  1575. /**
  1576. * Gets the performance counter for total vertices
  1577. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1578. */
  1579. readonly totalVerticesPerfCounter: PerfCounter;
  1580. /**
  1581. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1582. * @returns the total number of active indices rendered per frame
  1583. */
  1584. getActiveIndices(): number;
  1585. /**
  1586. * Gets the performance counter for active indices
  1587. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1588. */
  1589. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1590. /**
  1591. * Gets the total number of active particles rendered per frame
  1592. * @returns the total number of active particles rendered per frame
  1593. */
  1594. getActiveParticles(): number;
  1595. /**
  1596. * Gets the performance counter for active particles
  1597. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1598. */
  1599. readonly activeParticlesPerfCounter: PerfCounter;
  1600. /**
  1601. * Gets the total number of active bones rendered per frame
  1602. * @returns the total number of active bones rendered per frame
  1603. */
  1604. getActiveBones(): number;
  1605. /**
  1606. * Gets the performance counter for active bones
  1607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1608. */
  1609. readonly activeBonesPerfCounter: PerfCounter;
  1610. /**
  1611. * Gets the array of active meshes
  1612. * @returns an array of AbstractMesh
  1613. */
  1614. getActiveMeshes(): SmartArray<AbstractMesh>;
  1615. /**
  1616. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1617. * @returns a number
  1618. */
  1619. getAnimationRatio(): number;
  1620. /**
  1621. * Gets an unique Id for the current render phase
  1622. * @returns a number
  1623. */
  1624. getRenderId(): number;
  1625. /**
  1626. * Gets an unique Id for the current frame
  1627. * @returns a number
  1628. */
  1629. getFrameId(): number;
  1630. /** Call this function if you want to manually increment the render Id*/
  1631. incrementRenderId(): void;
  1632. private _updatePointerPosition;
  1633. private _createUbo;
  1634. private _createAlternateUbo;
  1635. private _setRayOnPointerInfo;
  1636. /**
  1637. * Use this method to simulate a pointer move on a mesh
  1638. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1639. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1640. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1641. * @returns the current scene
  1642. */
  1643. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1644. private _processPointerMove;
  1645. private _checkPrePointerObservable;
  1646. /**
  1647. * Use this method to simulate a pointer down on a mesh
  1648. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1649. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1650. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1651. * @returns the current scene
  1652. */
  1653. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1654. private _processPointerDown;
  1655. /**
  1656. * Use this method to simulate a pointer up on a mesh
  1657. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1658. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1659. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1660. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1661. * @returns the current scene
  1662. */
  1663. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1664. private _processPointerUp;
  1665. /**
  1666. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1667. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1668. * @returns true if the pointer was captured
  1669. */
  1670. isPointerCaptured(pointerId?: number): boolean;
  1671. /** @hidden */
  1672. _isPointerSwiping(): boolean;
  1673. /**
  1674. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1675. * @param attachUp defines if you want to attach events to pointerup
  1676. * @param attachDown defines if you want to attach events to pointerdown
  1677. * @param attachMove defines if you want to attach events to pointermove
  1678. */
  1679. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1680. /** Detaches all event handlers*/
  1681. detachControl(): void;
  1682. /**
  1683. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1684. * Delay loaded resources are not taking in account
  1685. * @return true if all required resources are ready
  1686. */
  1687. isReady(): boolean;
  1688. /** Resets all cached information relative to material (including effect and visibility) */
  1689. resetCachedMaterial(): void;
  1690. /**
  1691. * Registers a function to be called before every frame render
  1692. * @param func defines the function to register
  1693. */
  1694. registerBeforeRender(func: () => void): void;
  1695. /**
  1696. * Unregisters a function called before every frame render
  1697. * @param func defines the function to unregister
  1698. */
  1699. unregisterBeforeRender(func: () => void): void;
  1700. /**
  1701. * Registers a function to be called after every frame render
  1702. * @param func defines the function to register
  1703. */
  1704. registerAfterRender(func: () => void): void;
  1705. /**
  1706. * Unregisters a function called after every frame render
  1707. * @param func defines the function to unregister
  1708. */
  1709. unregisterAfterRender(func: () => void): void;
  1710. private _executeOnceBeforeRender;
  1711. /**
  1712. * The provided function will run before render once and will be disposed afterwards.
  1713. * A timeout delay can be provided so that the function will be executed in N ms.
  1714. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1715. * @param func The function to be executed.
  1716. * @param timeout optional delay in ms
  1717. */
  1718. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1719. /** @hidden */
  1720. _addPendingData(data: any): void;
  1721. /** @hidden */
  1722. _removePendingData(data: any): void;
  1723. /**
  1724. * Returns the number of items waiting to be loaded
  1725. * @returns the number of items waiting to be loaded
  1726. */
  1727. getWaitingItemsCount(): number;
  1728. /**
  1729. * Returns a boolean indicating if the scene is still loading data
  1730. */
  1731. readonly isLoading: boolean;
  1732. /**
  1733. * Registers a function to be executed when the scene is ready
  1734. * @param {Function} func - the function to be executed
  1735. */
  1736. executeWhenReady(func: () => void): void;
  1737. /**
  1738. * Returns a promise that resolves when the scene is ready
  1739. * @returns A promise that resolves when the scene is ready
  1740. */
  1741. whenReadyAsync(): Promise<void>;
  1742. /** @hidden */
  1743. _checkIsReady(): void;
  1744. /**
  1745. * Will start the animation sequence of a given target
  1746. * @param target defines the target
  1747. * @param from defines from which frame should animation start
  1748. * @param to defines until which frame should animation run.
  1749. * @param weight defines the weight to apply to the animation (1.0 by default)
  1750. * @param loop defines if the animation loops
  1751. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1752. * @param onAnimationEnd defines the function to be executed when the animation ends
  1753. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1754. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1755. * @returns the animatable object created for this animation
  1756. */
  1757. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  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 loop defines if the animation loops
  1764. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1765. * @param onAnimationEnd defines the function to be executed when the animation ends
  1766. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1767. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  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. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1772. /**
  1773. * Will start the animation sequence of a given target and its hierarchy
  1774. * @param target defines the target
  1775. * @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.
  1776. * @param from defines from which frame should animation start
  1777. * @param to defines until which frame should animation run.
  1778. * @param loop defines if the animation loops
  1779. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1780. * @param onAnimationEnd defines the function to be executed when the animation ends
  1781. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1782. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1783. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1784. * @returns the list of created animatables
  1785. */
  1786. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable[];
  1787. /**
  1788. * Begin a new animation on a given node
  1789. * @param target defines the target where the animation will take place
  1790. * @param animations defines the list of animations to start
  1791. * @param from defines the initial value
  1792. * @param to defines the final value
  1793. * @param loop defines if you want animation to loop (off by default)
  1794. * @param speedRatio defines the speed ratio to apply to all animations
  1795. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1796. * @returns the list of created animatables
  1797. */
  1798. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1799. /**
  1800. * Begin a new animation on a given node and its hierarchy
  1801. * @param target defines the root node where the animation will take place
  1802. * @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.
  1803. * @param animations defines the list of animations to start
  1804. * @param from defines the initial value
  1805. * @param to defines the final value
  1806. * @param loop defines if you want animation to loop (off by default)
  1807. * @param speedRatio defines the speed ratio to apply to all animations
  1808. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1809. * @returns the list of animatables created for all nodes
  1810. */
  1811. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1812. /**
  1813. * Gets the animatable associated with a specific target
  1814. * @param target defines the target of the animatable
  1815. * @returns the required animatable if found
  1816. */
  1817. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1818. /**
  1819. * Gets all animatables associated with a given target
  1820. * @param target defines the target to look animatables for
  1821. * @returns an array of Animatables
  1822. */
  1823. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1824. /**
  1825. * Gets all animatable attached to the scene
  1826. */
  1827. readonly animatables: Animatable[];
  1828. /**
  1829. * Will stop the animation of the given target
  1830. * @param target - the target
  1831. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1832. * @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)
  1833. */
  1834. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1835. /**
  1836. * Stops and removes all animations that have been applied to the scene
  1837. */
  1838. stopAllAnimations(): void;
  1839. private _animate;
  1840. /** @hidden */
  1841. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1842. private _processLateAnimationBindingsForMatrices;
  1843. private _processLateAnimationBindingsForQuaternions;
  1844. private _processLateAnimationBindings;
  1845. /** @hidden */
  1846. _switchToAlternateCameraConfiguration(active: boolean): void;
  1847. /**
  1848. * Gets the current view matrix
  1849. * @returns a Matrix
  1850. */
  1851. getViewMatrix(): Matrix;
  1852. /**
  1853. * Gets the current projection matrix
  1854. * @returns a Matrix
  1855. */
  1856. getProjectionMatrix(): Matrix;
  1857. /**
  1858. * Gets the current transform matrix
  1859. * @returns a Matrix made of View * Projection
  1860. */
  1861. getTransformMatrix(): Matrix;
  1862. /**
  1863. * Sets the current transform matrix
  1864. * @param view defines the View matrix to use
  1865. * @param projection defines the Projection matrix to use
  1866. */
  1867. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1868. /** @hidden */
  1869. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1870. /**
  1871. * Gets the uniform buffer used to store scene data
  1872. * @returns a UniformBuffer
  1873. */
  1874. getSceneUniformBuffer(): UniformBuffer;
  1875. /**
  1876. * Gets an unique (relatively to the current scene) Id
  1877. * @returns an unique number for the scene
  1878. */
  1879. getUniqueId(): number;
  1880. /**
  1881. * Add a mesh to the list of scene's meshes
  1882. * @param newMesh defines the mesh to add
  1883. * @param recursive if all child meshes should also be added to the scene
  1884. */
  1885. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1886. /**
  1887. * Remove a mesh for the list of scene's meshes
  1888. * @param toRemove defines the mesh to remove
  1889. * @param recursive if all child meshes should also be removed from the scene
  1890. * @returns the index where the mesh was in the mesh list
  1891. */
  1892. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1893. /**
  1894. * Add a transform node to the list of scene's transform nodes
  1895. * @param newTransformNode defines the transform node to add
  1896. */
  1897. addTransformNode(newTransformNode: TransformNode): void;
  1898. /**
  1899. * Remove a transform node for the list of scene's transform nodes
  1900. * @param toRemove defines the transform node to remove
  1901. * @returns the index where the transform node was in the transform node list
  1902. */
  1903. removeTransformNode(toRemove: TransformNode): number;
  1904. /**
  1905. * Remove a skeleton for the list of scene's skeletons
  1906. * @param toRemove defines the skeleton to remove
  1907. * @returns the index where the skeleton was in the skeleton list
  1908. */
  1909. removeSkeleton(toRemove: Skeleton): number;
  1910. /**
  1911. * Remove a morph target for the list of scene's morph targets
  1912. * @param toRemove defines the morph target to remove
  1913. * @returns the index where the morph target was in the morph target list
  1914. */
  1915. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1916. /**
  1917. * Remove a light for the list of scene's lights
  1918. * @param toRemove defines the light to remove
  1919. * @returns the index where the light was in the light list
  1920. */
  1921. removeLight(toRemove: Light): number;
  1922. /**
  1923. * Remove a camera for the list of scene's cameras
  1924. * @param toRemove defines the camera to remove
  1925. * @returns the index where the camera was in the camera list
  1926. */
  1927. removeCamera(toRemove: Camera): number;
  1928. /**
  1929. * Remove a particle system for the list of scene's particle systems
  1930. * @param toRemove defines the particle system to remove
  1931. * @returns the index where the particle system was in the particle system list
  1932. */
  1933. removeParticleSystem(toRemove: IParticleSystem): number;
  1934. /**
  1935. * Remove a animation for the list of scene's animations
  1936. * @param toRemove defines the animation to remove
  1937. * @returns the index where the animation was in the animation list
  1938. */
  1939. removeAnimation(toRemove: Animation): number;
  1940. /**
  1941. * Removes the given animation group from this scene.
  1942. * @param toRemove The animation group to remove
  1943. * @returns The index of the removed animation group
  1944. */
  1945. removeAnimationGroup(toRemove: AnimationGroup): number;
  1946. /**
  1947. * Removes the given multi-material from this scene.
  1948. * @param toRemove The multi-material to remove
  1949. * @returns The index of the removed multi-material
  1950. */
  1951. removeMultiMaterial(toRemove: MultiMaterial): number;
  1952. /**
  1953. * Removes the given material from this scene.
  1954. * @param toRemove The material to remove
  1955. * @returns The index of the removed material
  1956. */
  1957. removeMaterial(toRemove: Material): number;
  1958. /**
  1959. * Removes the given action manager from this scene.
  1960. * @param toRemove The action manager to remove
  1961. * @returns The index of the removed action manager
  1962. */
  1963. removeActionManager(toRemove: ActionManager): number;
  1964. /**
  1965. * Removes the given texture from this scene.
  1966. * @param toRemove The texture to remove
  1967. * @returns The index of the removed texture
  1968. */
  1969. removeTexture(toRemove: BaseTexture): number;
  1970. /**
  1971. * Adds the given light to this scene
  1972. * @param newLight The light to add
  1973. */
  1974. addLight(newLight: Light): void;
  1975. /**
  1976. * Sorts the list list based on light priorities
  1977. */
  1978. sortLightsByPriority(): void;
  1979. /**
  1980. * Adds the given camera to this scene
  1981. * @param newCamera The camera to add
  1982. */
  1983. addCamera(newCamera: Camera): void;
  1984. /**
  1985. * Adds the given skeleton to this scene
  1986. * @param newSkeleton The skeleton to add
  1987. */
  1988. addSkeleton(newSkeleton: Skeleton): void;
  1989. /**
  1990. * Adds the given particle system to this scene
  1991. * @param newParticleSystem The particle system to add
  1992. */
  1993. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1994. /**
  1995. * Adds the given animation to this scene
  1996. * @param newAnimation The animation to add
  1997. */
  1998. addAnimation(newAnimation: Animation): void;
  1999. /**
  2000. * Adds the given animation group to this scene.
  2001. * @param newAnimationGroup The animation group to add
  2002. */
  2003. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2004. /**
  2005. * Adds the given multi-material to this scene
  2006. * @param newMultiMaterial The multi-material to add
  2007. */
  2008. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2009. /**
  2010. * Adds the given material to this scene
  2011. * @param newMaterial The material to add
  2012. */
  2013. addMaterial(newMaterial: Material): void;
  2014. /**
  2015. * Adds the given morph target to this scene
  2016. * @param newMorphTargetManager The morph target to add
  2017. */
  2018. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2019. /**
  2020. * Adds the given geometry to this scene
  2021. * @param newGeometry The geometry to add
  2022. */
  2023. addGeometry(newGeometry: Geometry): void;
  2024. /**
  2025. * Adds the given action manager to this scene
  2026. * @param newActionManager The action manager to add
  2027. */
  2028. addActionManager(newActionManager: ActionManager): void;
  2029. /**
  2030. * Adds the given texture to this scene.
  2031. * @param newTexture The texture to add
  2032. */
  2033. addTexture(newTexture: BaseTexture): void;
  2034. /**
  2035. * Switch active camera
  2036. * @param newCamera defines the new active camera
  2037. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2038. */
  2039. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2040. /**
  2041. * sets the active camera of the scene using its ID
  2042. * @param id defines the camera's ID
  2043. * @return the new active camera or null if none found.
  2044. */
  2045. setActiveCameraByID(id: string): Nullable<Camera>;
  2046. /**
  2047. * sets the active camera of the scene using its name
  2048. * @param name defines the camera's name
  2049. * @returns the new active camera or null if none found.
  2050. */
  2051. setActiveCameraByName(name: string): Nullable<Camera>;
  2052. /**
  2053. * get an animation group using its name
  2054. * @param name defines the material's name
  2055. * @return the animation group or null if none found.
  2056. */
  2057. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2058. /**
  2059. * get a material using its id
  2060. * @param id defines the material's ID
  2061. * @return the material or null if none found.
  2062. */
  2063. getMaterialByID(id: string): Nullable<Material>;
  2064. /**
  2065. * Gets a material using its name
  2066. * @param name defines the material's name
  2067. * @return the material or null if none found.
  2068. */
  2069. getMaterialByName(name: string): Nullable<Material>;
  2070. /**
  2071. * Gets a camera using its id
  2072. * @param id defines the id to look for
  2073. * @returns the camera or null if not found
  2074. */
  2075. getCameraByID(id: string): Nullable<Camera>;
  2076. /**
  2077. * Gets a camera using its unique id
  2078. * @param uniqueId defines the unique id to look for
  2079. * @returns the camera or null if not found
  2080. */
  2081. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2082. /**
  2083. * Gets a camera using its name
  2084. * @param name defines the camera's name
  2085. * @return the camera or null if none found.
  2086. */
  2087. getCameraByName(name: string): Nullable<Camera>;
  2088. /**
  2089. * Gets a bone using its id
  2090. * @param id defines the bone's id
  2091. * @return the bone or null if not found
  2092. */
  2093. getBoneByID(id: string): Nullable<Bone>;
  2094. /**
  2095. * Gets a bone using its id
  2096. * @param name defines the bone's name
  2097. * @return the bone or null if not found
  2098. */
  2099. getBoneByName(name: string): Nullable<Bone>;
  2100. /**
  2101. * Gets a light node using its name
  2102. * @param name defines the the light's name
  2103. * @return the light or null if none found.
  2104. */
  2105. getLightByName(name: string): Nullable<Light>;
  2106. /**
  2107. * Gets a light node using its id
  2108. * @param id defines the light's id
  2109. * @return the light or null if none found.
  2110. */
  2111. getLightByID(id: string): Nullable<Light>;
  2112. /**
  2113. * Gets a light node using its scene-generated unique ID
  2114. * @param uniqueId defines the light's unique id
  2115. * @return the light or null if none found.
  2116. */
  2117. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2118. /**
  2119. * Gets a particle system by id
  2120. * @param id defines the particle system id
  2121. * @return the corresponding system or null if none found
  2122. */
  2123. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2124. /**
  2125. * Gets a geometry using its ID
  2126. * @param id defines the geometry's id
  2127. * @return the geometry or null if none found.
  2128. */
  2129. getGeometryByID(id: string): Nullable<Geometry>;
  2130. /**
  2131. * Add a new geometry to this scene
  2132. * @param geometry defines the geometry to be added to the scene.
  2133. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2134. * @return a boolean defining if the geometry was added or not
  2135. */
  2136. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2137. /**
  2138. * Removes an existing geometry
  2139. * @param geometry defines the geometry to be removed from the scene
  2140. * @return a boolean defining if the geometry was removed or not
  2141. */
  2142. removeGeometry(geometry: Geometry): boolean;
  2143. /**
  2144. * Gets the list of geometries attached to the scene
  2145. * @returns an array of Geometry
  2146. */
  2147. getGeometries(): Geometry[];
  2148. /**
  2149. * Gets the first added mesh found of a given ID
  2150. * @param id defines the id to search for
  2151. * @return the mesh found or null if not found at all
  2152. */
  2153. getMeshByID(id: string): Nullable<AbstractMesh>;
  2154. /**
  2155. * Gets a list of meshes using their id
  2156. * @param id defines the id to search for
  2157. * @returns a list of meshes
  2158. */
  2159. getMeshesByID(id: string): Array<AbstractMesh>;
  2160. /**
  2161. * Gets the first added transform node found of a given ID
  2162. * @param id defines the id to search for
  2163. * @return the found transform node or null if not found at all.
  2164. */
  2165. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2166. /**
  2167. * Gets a list of transform nodes using their id
  2168. * @param id defines the id to search for
  2169. * @returns a list of transform nodes
  2170. */
  2171. getTransformNodesByID(id: string): Array<TransformNode>;
  2172. /**
  2173. * Gets a mesh with its auto-generated unique id
  2174. * @param uniqueId defines the unique id to search for
  2175. * @return the found mesh or null if not found at all.
  2176. */
  2177. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2178. /**
  2179. * Gets a the last added mesh using a given id
  2180. * @param id defines the id to search for
  2181. * @return the found mesh or null if not found at all.
  2182. */
  2183. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2184. /**
  2185. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2186. * @param id defines the id to search for
  2187. * @return the found node or null if not found at all
  2188. */
  2189. getLastEntryByID(id: string): Nullable<Node>;
  2190. /**
  2191. * Gets a node (Mesh, Camera, Light) using a given id
  2192. * @param id defines the id to search for
  2193. * @return the found node or null if not found at all
  2194. */
  2195. getNodeByID(id: string): Nullable<Node>;
  2196. /**
  2197. * Gets a node (Mesh, Camera, Light) using a given name
  2198. * @param name defines the name to search for
  2199. * @return the found node or null if not found at all.
  2200. */
  2201. getNodeByName(name: string): Nullable<Node>;
  2202. /**
  2203. * Gets a mesh using a given name
  2204. * @param name defines the name to search for
  2205. * @return the found mesh or null if not found at all.
  2206. */
  2207. getMeshByName(name: string): Nullable<AbstractMesh>;
  2208. /**
  2209. * Gets a transform node using a given name
  2210. * @param name defines the name to search for
  2211. * @return the found transform node or null if not found at all.
  2212. */
  2213. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2214. /**
  2215. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2216. * @param id defines the id to search for
  2217. * @return the found skeleton or null if not found at all.
  2218. */
  2219. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2220. /**
  2221. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2222. * @param id defines the id to search for
  2223. * @return the found skeleton or null if not found at all.
  2224. */
  2225. getSkeletonById(id: string): Nullable<Skeleton>;
  2226. /**
  2227. * Gets a skeleton using a given name
  2228. * @param name defines the name to search for
  2229. * @return the found skeleton or null if not found at all.
  2230. */
  2231. getSkeletonByName(name: string): Nullable<Skeleton>;
  2232. /**
  2233. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2234. * @param id defines the id to search for
  2235. * @return the found morph target manager or null if not found at all.
  2236. */
  2237. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2238. /**
  2239. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2240. * @param id defines the id to search for
  2241. * @return the found morph target or null if not found at all.
  2242. */
  2243. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2244. /**
  2245. * Gets a boolean indicating if the given mesh is active
  2246. * @param mesh defines the mesh to look for
  2247. * @returns true if the mesh is in the active list
  2248. */
  2249. isActiveMesh(mesh: AbstractMesh): boolean;
  2250. /**
  2251. * Return a unique id as a string which can serve as an identifier for the scene
  2252. */
  2253. readonly uid: string;
  2254. /**
  2255. * Add an externaly attached data from its key.
  2256. * This method call will fail and return false, if such key already exists.
  2257. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2258. * @param key the unique key that identifies the data
  2259. * @param data the data object to associate to the key for this Engine instance
  2260. * @return true if no such key were already present and the data was added successfully, false otherwise
  2261. */
  2262. addExternalData<T>(key: string, data: T): boolean;
  2263. /**
  2264. * Get an externaly attached data from its key
  2265. * @param key the unique key that identifies the data
  2266. * @return the associated data, if present (can be null), or undefined if not present
  2267. */
  2268. getExternalData<T>(key: string): Nullable<T>;
  2269. /**
  2270. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2271. * @param key the unique key that identifies the data
  2272. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2273. * @return the associated data, can be null if the factory returned null.
  2274. */
  2275. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2276. /**
  2277. * Remove an externaly attached data from the Engine instance
  2278. * @param key the unique key that identifies the data
  2279. * @return true if the data was successfully removed, false if it doesn't exist
  2280. */
  2281. removeExternalData(key: string): boolean;
  2282. private _evaluateSubMesh;
  2283. /**
  2284. * Clear the processed materials smart array preventing retention point in material dispose.
  2285. */
  2286. freeProcessedMaterials(): void;
  2287. private _preventFreeActiveMeshesAndRenderingGroups;
  2288. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2289. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2290. * when disposing several meshes in a row or a hierarchy of meshes.
  2291. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2292. */
  2293. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2294. /**
  2295. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2296. */
  2297. freeActiveMeshes(): void;
  2298. /**
  2299. * Clear the info related to rendering groups preventing retention points during dispose.
  2300. */
  2301. freeRenderingGroups(): void;
  2302. /** @hidden */
  2303. _isInIntermediateRendering(): boolean;
  2304. /**
  2305. * Lambda returning the list of potentially active meshes.
  2306. */
  2307. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2308. /**
  2309. * Lambda returning the list of potentially active sub meshes.
  2310. */
  2311. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2312. /**
  2313. * Lambda returning the list of potentially intersecting sub meshes.
  2314. */
  2315. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2316. /**
  2317. * Lambda returning the list of potentially colliding sub meshes.
  2318. */
  2319. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2320. private _activeMeshesFrozen;
  2321. /**
  2322. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2323. * @returns the current scene
  2324. */
  2325. freezeActiveMeshes(): Scene;
  2326. /**
  2327. * Use this function to restart evaluating active meshes on every frame
  2328. * @returns the current scene
  2329. */
  2330. unfreezeActiveMeshes(): Scene;
  2331. private _evaluateActiveMeshes;
  2332. private _activeMesh;
  2333. /**
  2334. * Update the transform matrix to update from the current active camera
  2335. * @param force defines a boolean used to force the update even if cache is up to date
  2336. */
  2337. updateTransformMatrix(force?: boolean): void;
  2338. /**
  2339. * 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)
  2340. * @param alternateCamera defines the camera to use
  2341. */
  2342. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2343. /** @hidden */
  2344. _allowPostProcessClearColor: boolean;
  2345. private _renderForCamera;
  2346. private _processSubCameras;
  2347. private _checkIntersections;
  2348. /** @hidden */
  2349. _advancePhysicsEngineStep(step: number): void;
  2350. /**
  2351. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2352. */
  2353. getDeterministicFrameTime: () => number;
  2354. /**
  2355. * Render the scene
  2356. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2357. */
  2358. render(updateCameras?: boolean): void;
  2359. /**
  2360. * Freeze all materials
  2361. * A frozen material will not be updatable but should be faster to render
  2362. */
  2363. freezeMaterials(): void;
  2364. /**
  2365. * Unfreeze all materials
  2366. * A frozen material will not be updatable but should be faster to render
  2367. */
  2368. unfreezeMaterials(): void;
  2369. /**
  2370. * Releases all held ressources
  2371. */
  2372. dispose(): void;
  2373. /**
  2374. * Gets if the scene is already disposed
  2375. */
  2376. readonly isDisposed: boolean;
  2377. /**
  2378. * Call this function to reduce memory footprint of the scene.
  2379. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2380. */
  2381. clearCachedVertexData(): void;
  2382. /**
  2383. * This function will remove the local cached buffer data from texture.
  2384. * It will save memory but will prevent the texture from being rebuilt
  2385. */
  2386. cleanCachedTextureBuffer(): void;
  2387. /**
  2388. * Get the world extend vectors with an optional filter
  2389. *
  2390. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2391. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2392. */
  2393. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2394. min: Vector3;
  2395. max: Vector3;
  2396. };
  2397. /**
  2398. * Creates a ray that can be used to pick in the scene
  2399. * @param x defines the x coordinate of the origin (on-screen)
  2400. * @param y defines the y coordinate of the origin (on-screen)
  2401. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2402. * @param camera defines the camera to use for the picking
  2403. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2404. * @returns a Ray
  2405. */
  2406. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2407. /**
  2408. * Creates a ray that can be used to pick in the scene
  2409. * @param x defines the x coordinate of the origin (on-screen)
  2410. * @param y defines the y coordinate of the origin (on-screen)
  2411. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2412. * @param result defines the ray where to store the picking ray
  2413. * @param camera defines the camera to use for the picking
  2414. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2415. * @returns the current scene
  2416. */
  2417. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2418. /**
  2419. * Creates a ray that can be used to pick in the scene
  2420. * @param x defines the x coordinate of the origin (on-screen)
  2421. * @param y defines the y coordinate of the origin (on-screen)
  2422. * @param camera defines the camera to use for the picking
  2423. * @returns a Ray
  2424. */
  2425. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2426. /**
  2427. * Creates a ray that can be used to pick in the scene
  2428. * @param x defines the x coordinate of the origin (on-screen)
  2429. * @param y defines the y coordinate of the origin (on-screen)
  2430. * @param result defines the ray where to store the picking ray
  2431. * @param camera defines the camera to use for the picking
  2432. * @returns the current scene
  2433. */
  2434. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2435. private _internalPick;
  2436. private _internalMultiPick;
  2437. private _tempPickingRay;
  2438. /** Launch a ray to try to pick a mesh in the scene
  2439. * @param x position on screen
  2440. * @param y position on screen
  2441. * @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
  2442. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2443. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2444. * @returns a PickingInfo
  2445. */
  2446. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2447. private _cachedRayForTransform;
  2448. /** Use the given ray to pick a mesh in the scene
  2449. * @param ray The ray to use to pick meshes
  2450. * @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
  2451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2452. * @returns a PickingInfo
  2453. */
  2454. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2455. /**
  2456. * Launch a ray to try to pick a mesh in the scene
  2457. * @param x X position on screen
  2458. * @param y Y position on screen
  2459. * @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
  2460. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2461. * @returns an array of PickingInfo
  2462. */
  2463. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2464. /**
  2465. * Launch a ray to try to pick a mesh in the scene
  2466. * @param ray Ray to use
  2467. * @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
  2468. * @returns an array of PickingInfo
  2469. */
  2470. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2471. /**
  2472. * Force the value of meshUnderPointer
  2473. * @param mesh defines the mesh to use
  2474. */
  2475. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2476. /**
  2477. * Gets the mesh under the pointer
  2478. * @returns a Mesh or null if no mesh is under the pointer
  2479. */
  2480. getPointerOverMesh(): Nullable<AbstractMesh>;
  2481. /** @hidden */
  2482. _rebuildGeometries(): void;
  2483. /** @hidden */
  2484. _rebuildTextures(): void;
  2485. private _getByTags;
  2486. /**
  2487. * Get a list of meshes by tags
  2488. * @param tagsQuery defines the tags query to use
  2489. * @param forEach defines a predicate used to filter results
  2490. * @returns an array of Mesh
  2491. */
  2492. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2493. /**
  2494. * Get a list of cameras by tags
  2495. * @param tagsQuery defines the tags query to use
  2496. * @param forEach defines a predicate used to filter results
  2497. * @returns an array of Camera
  2498. */
  2499. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2500. /**
  2501. * Get a list of lights 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 Light
  2505. */
  2506. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2507. /**
  2508. * Get a list of materials 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 Material
  2512. */
  2513. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2514. /**
  2515. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2516. * This allowed control for front to back rendering or reversly depending of the special needs.
  2517. *
  2518. * @param renderingGroupId The rendering group id corresponding to its index
  2519. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2520. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2521. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2522. */
  2523. 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;
  2524. /**
  2525. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2526. *
  2527. * @param renderingGroupId The rendering group id corresponding to its index
  2528. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2529. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2530. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2531. */
  2532. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2533. /**
  2534. * Gets the current auto clear configuration for one rendering group of the rendering
  2535. * manager.
  2536. * @param index the rendering group index to get the information for
  2537. * @returns The auto clear setup for the requested rendering group
  2538. */
  2539. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2540. private _blockMaterialDirtyMechanism;
  2541. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2542. blockMaterialDirtyMechanism: boolean;
  2543. /**
  2544. * Will flag all materials as dirty to trigger new shader compilation
  2545. * @param flag defines the flag used to specify which material part must be marked as dirty
  2546. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2547. */
  2548. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2549. /** @hidden */
  2550. _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;
  2551. /** @hidden */
  2552. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2553. }
  2554. }
  2555. declare module BABYLON {
  2556. /**
  2557. * Groups all the scene component constants in one place to ease maintenance.
  2558. * @hidden
  2559. */
  2560. class SceneComponentConstants {
  2561. static readonly NAME_EFFECTLAYER: string;
  2562. static readonly NAME_LAYER: string;
  2563. static readonly NAME_LENSFLARESYSTEM: string;
  2564. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2565. static readonly NAME_PARTICLESYSTEM: string;
  2566. static readonly NAME_GAMEPAD: string;
  2567. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2568. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2569. static readonly NAME_DEPTHRENDERER: string;
  2570. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2571. static readonly NAME_SPRITE: string;
  2572. static readonly NAME_OUTLINERENDERER: string;
  2573. static readonly NAME_PROCEDURALTEXTURE: string;
  2574. static readonly NAME_SHADOWGENERATOR: string;
  2575. static readonly NAME_OCTREE: string;
  2576. static readonly NAME_PHYSICSENGINE: string;
  2577. static readonly NAME_AUDIO: string;
  2578. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2579. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2580. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2581. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2582. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2583. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2584. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2585. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2586. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2587. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2588. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2589. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2590. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2591. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2592. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2593. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2594. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2595. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2596. static readonly STEP_AFTERRENDER_AUDIO: number;
  2597. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2598. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2599. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2600. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2601. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2602. static readonly STEP_POINTERMOVE_SPRITE: number;
  2603. static readonly STEP_POINTERDOWN_SPRITE: number;
  2604. static readonly STEP_POINTERUP_SPRITE: number;
  2605. }
  2606. /**
  2607. * This represents a scene component.
  2608. *
  2609. * This is used to decouple the dependency the scene is having on the different workloads like
  2610. * layers, post processes...
  2611. */
  2612. interface ISceneComponent {
  2613. /**
  2614. * The name of the component. Each component must have a unique name.
  2615. */
  2616. name: string;
  2617. /**
  2618. * The scene the component belongs to.
  2619. */
  2620. scene: Scene;
  2621. /**
  2622. * Register the component to one instance of a scene.
  2623. */
  2624. register(): void;
  2625. /**
  2626. * Rebuilds the elements related to this component in case of
  2627. * context lost for instance.
  2628. */
  2629. rebuild(): void;
  2630. /**
  2631. * Disposes the component and the associated ressources.
  2632. */
  2633. dispose(): void;
  2634. }
  2635. /**
  2636. * This represents a SERIALIZABLE scene component.
  2637. *
  2638. * This extends Scene Component to add Serialization methods on top.
  2639. */
  2640. interface ISceneSerializableComponent extends ISceneComponent {
  2641. /**
  2642. * Adds all the element from the container to the scene
  2643. * @param container the container holding the elements
  2644. */
  2645. addFromContainer(container: AbstractScene): void;
  2646. /**
  2647. * Removes all the elements in the container from the scene
  2648. * @param container contains the elements to remove
  2649. */
  2650. removeFromContainer(container: AbstractScene): void;
  2651. /**
  2652. * Serializes the component data to the specified json object
  2653. * @param serializationObject The object to serialize to
  2654. */
  2655. serialize(serializationObject: any): void;
  2656. }
  2657. /**
  2658. * Strong typing of a Mesh related stage step action
  2659. */
  2660. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2661. /**
  2662. * Strong typing of a Evaluate Sub Mesh related stage step action
  2663. */
  2664. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2665. /**
  2666. * Strong typing of a Active Mesh related stage step action
  2667. */
  2668. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2669. /**
  2670. * Strong typing of a Camera related stage step action
  2671. */
  2672. type CameraStageAction = (camera: Camera) => void;
  2673. /**
  2674. * Strong typing of a RenderingGroup related stage step action
  2675. */
  2676. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2677. /**
  2678. * Strong typing of a Mesh Render related stage step action
  2679. */
  2680. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2681. /**
  2682. * Strong typing of a simple stage step action
  2683. */
  2684. type SimpleStageAction = () => void;
  2685. /**
  2686. * Strong typing of a render target action.
  2687. */
  2688. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2689. /**
  2690. * Strong typing of a pointer move action.
  2691. */
  2692. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2693. /**
  2694. * Strong typing of a pointer up/down action.
  2695. */
  2696. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2697. /**
  2698. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2699. * @hidden
  2700. */
  2701. class Stage<T extends Function> extends Array<{
  2702. index: number;
  2703. component: ISceneComponent;
  2704. action: T;
  2705. }> {
  2706. /**
  2707. * Hide ctor from the rest of the world.
  2708. * @param items The items to add.
  2709. */
  2710. private constructor();
  2711. /**
  2712. * Creates a new Stage.
  2713. * @returns A new instance of a Stage
  2714. */
  2715. static Create<T extends Function>(): Stage<T>;
  2716. /**
  2717. * Registers a step in an ordered way in the targeted stage.
  2718. * @param index Defines the position to register the step in
  2719. * @param component Defines the component attached to the step
  2720. * @param action Defines the action to launch during the step
  2721. */
  2722. registerStep(index: number, component: ISceneComponent, action: T): void;
  2723. /**
  2724. * Clears all the steps from the stage.
  2725. */
  2726. clear(): void;
  2727. }
  2728. }
  2729. declare module BABYLON {
  2730. /** Alias type for value that can be null */
  2731. type Nullable<T> = T | null;
  2732. /**
  2733. * Alias type for number that are floats
  2734. * @ignorenaming
  2735. */
  2736. type float = number;
  2737. /**
  2738. * Alias type for number that are doubles.
  2739. * @ignorenaming
  2740. */
  2741. type double = number;
  2742. /**
  2743. * Alias type for number that are integer
  2744. * @ignorenaming
  2745. */
  2746. type int = number;
  2747. /** Alias type for number array or Float32Array */
  2748. type FloatArray = number[] | Float32Array;
  2749. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2750. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2751. /**
  2752. * Alias for types that can be used by a Buffer or VertexBuffer.
  2753. */
  2754. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2755. /**
  2756. * Alias type for primitive types
  2757. * @ignorenaming
  2758. */
  2759. type Primitive = undefined | null | boolean | string | number | Function;
  2760. /**
  2761. * Type modifier to make all the properties of an object Readonly
  2762. */
  2763. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2764. /**
  2765. * Type modifier to make all the properties of an object Readonly recursively
  2766. */
  2767. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2768. /** @hidden */
  2769. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2770. }
  2771. /** @hidden */
  2772. /** @hidden */
  2773. type DeepImmutableObject<T> = {
  2774. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2775. };
  2776. }
  2777. declare module BABYLON {
  2778. /**
  2779. * The action to be carried out following a trigger
  2780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2781. */
  2782. class Action {
  2783. /** the trigger, with or without parameters, for the action */
  2784. triggerOptions: any;
  2785. /**
  2786. * Trigger for the action
  2787. */
  2788. trigger: number;
  2789. /**
  2790. * Internal only - manager for action
  2791. * @hidden
  2792. */
  2793. _actionManager: ActionManager;
  2794. private _nextActiveAction;
  2795. private _child;
  2796. private _condition?;
  2797. private _triggerParameter;
  2798. /**
  2799. * An event triggered prior to action being executed.
  2800. */
  2801. onBeforeExecuteObservable: Observable<Action>;
  2802. /**
  2803. * Creates a new Action
  2804. * @param triggerOptions the trigger, with or without parameters, for the action
  2805. * @param condition an optional determinant of action
  2806. */
  2807. constructor(
  2808. /** the trigger, with or without parameters, for the action */
  2809. triggerOptions: any, condition?: Condition);
  2810. /**
  2811. * Internal only
  2812. * @hidden
  2813. */
  2814. _prepare(): void;
  2815. /**
  2816. * Gets the trigger parameters
  2817. * @returns the trigger parameters
  2818. */
  2819. getTriggerParameter(): any;
  2820. /**
  2821. * Internal only - executes current action event
  2822. * @hidden
  2823. */
  2824. _executeCurrent(evt?: ActionEvent): void;
  2825. /**
  2826. * Execute placeholder for child classes
  2827. * @param evt optional action event
  2828. */
  2829. execute(evt?: ActionEvent): void;
  2830. /**
  2831. * Skips to next active action
  2832. */
  2833. skipToNextActiveAction(): void;
  2834. /**
  2835. * Adds action to chain of actions, may be a DoNothingAction
  2836. * @param action defines the next action to execute
  2837. * @returns The action passed in
  2838. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2839. */
  2840. then(action: Action): Action;
  2841. /**
  2842. * Internal only
  2843. * @hidden
  2844. */
  2845. _getProperty(propertyPath: string): string;
  2846. /**
  2847. * Internal only
  2848. * @hidden
  2849. */
  2850. _getEffectiveTarget(target: any, propertyPath: string): any;
  2851. /**
  2852. * Serialize placeholder for child classes
  2853. * @param parent of child
  2854. * @returns the serialized object
  2855. */
  2856. serialize(parent: any): any;
  2857. /**
  2858. * Internal only called by serialize
  2859. * @hidden
  2860. */
  2861. protected _serialize(serializedAction: any, parent?: any): any;
  2862. /**
  2863. * Internal only
  2864. * @hidden
  2865. */
  2866. static _SerializeValueAsString: (value: any) => string;
  2867. /**
  2868. * Internal only
  2869. * @hidden
  2870. */
  2871. static _GetTargetProperty: (target: Scene | Node) => {
  2872. name: string;
  2873. targetType: string;
  2874. value: string;
  2875. };
  2876. }
  2877. }
  2878. declare module BABYLON {
  2879. /**
  2880. * ActionEvent is the event being sent when an action is triggered.
  2881. */
  2882. class ActionEvent {
  2883. /** The mesh or sprite that triggered the action */
  2884. source: any;
  2885. /** The X mouse cursor position at the time of the event */
  2886. pointerX: number;
  2887. /** The Y mouse cursor position at the time of the event */
  2888. pointerY: number;
  2889. /** The mesh that is currently pointed at (can be null) */
  2890. meshUnderPointer: Nullable<AbstractMesh>;
  2891. /** the original (browser) event that triggered the ActionEvent */
  2892. sourceEvent?: any;
  2893. /** additional data for the event */
  2894. additionalData?: any;
  2895. /**
  2896. * Creates a new ActionEvent
  2897. * @param source The mesh or sprite that triggered the action
  2898. * @param pointerX The X mouse cursor position at the time of the event
  2899. * @param pointerY The Y mouse cursor position at the time of the event
  2900. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2901. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2902. * @param additionalData additional data for the event
  2903. */
  2904. constructor(
  2905. /** The mesh or sprite that triggered the action */
  2906. source: any,
  2907. /** The X mouse cursor position at the time of the event */
  2908. pointerX: number,
  2909. /** The Y mouse cursor position at the time of the event */
  2910. pointerY: number,
  2911. /** The mesh that is currently pointed at (can be null) */
  2912. meshUnderPointer: Nullable<AbstractMesh>,
  2913. /** the original (browser) event that triggered the ActionEvent */
  2914. sourceEvent?: any,
  2915. /** additional data for the event */
  2916. additionalData?: any);
  2917. /**
  2918. * Helper function to auto-create an ActionEvent from a source mesh.
  2919. * @param source The source mesh that triggered the event
  2920. * @param evt The original (browser) event
  2921. * @param additionalData additional data for the event
  2922. * @returns the new ActionEvent
  2923. */
  2924. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2925. /**
  2926. * Helper function to auto-create an ActionEvent from a source sprite
  2927. * @param source The source sprite that triggered the event
  2928. * @param scene Scene associated with the sprite
  2929. * @param evt The original (browser) event
  2930. * @param additionalData additional data for the event
  2931. * @returns the new ActionEvent
  2932. */
  2933. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2934. /**
  2935. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2936. * @param scene the scene where the event occurred
  2937. * @param evt The original (browser) event
  2938. * @returns the new ActionEvent
  2939. */
  2940. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2941. /**
  2942. * Helper function to auto-create an ActionEvent from a primitive
  2943. * @param prim defines the target primitive
  2944. * @param pointerPos defines the pointer position
  2945. * @param evt The original (browser) event
  2946. * @param additionalData additional data for the event
  2947. * @returns the new ActionEvent
  2948. */
  2949. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2950. }
  2951. /**
  2952. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2953. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2955. */
  2956. class ActionManager {
  2957. /**
  2958. * Nothing
  2959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2960. */
  2961. static readonly NothingTrigger: number;
  2962. /**
  2963. * On pick
  2964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2965. */
  2966. static readonly OnPickTrigger: number;
  2967. /**
  2968. * On left pick
  2969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2970. */
  2971. static readonly OnLeftPickTrigger: number;
  2972. /**
  2973. * On right pick
  2974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2975. */
  2976. static readonly OnRightPickTrigger: number;
  2977. /**
  2978. * On center pick
  2979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2980. */
  2981. static readonly OnCenterPickTrigger: number;
  2982. /**
  2983. * On pick down
  2984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2985. */
  2986. static readonly OnPickDownTrigger: number;
  2987. /**
  2988. * On double pick
  2989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2990. */
  2991. static readonly OnDoublePickTrigger: number;
  2992. /**
  2993. * On pick up
  2994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2995. */
  2996. static readonly OnPickUpTrigger: number;
  2997. /**
  2998. * On pick out.
  2999. * This trigger will only be raised if you also declared a OnPickDown
  3000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3001. */
  3002. static readonly OnPickOutTrigger: number;
  3003. /**
  3004. * On long press
  3005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3006. */
  3007. static readonly OnLongPressTrigger: number;
  3008. /**
  3009. * On pointer over
  3010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3011. */
  3012. static readonly OnPointerOverTrigger: number;
  3013. /**
  3014. * On pointer out
  3015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3016. */
  3017. static readonly OnPointerOutTrigger: number;
  3018. /**
  3019. * On every frame
  3020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3021. */
  3022. static readonly OnEveryFrameTrigger: number;
  3023. /**
  3024. * On intersection enter
  3025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3026. */
  3027. static readonly OnIntersectionEnterTrigger: number;
  3028. /**
  3029. * On intersection exit
  3030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3031. */
  3032. static readonly OnIntersectionExitTrigger: number;
  3033. /**
  3034. * On key down
  3035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3036. */
  3037. static readonly OnKeyDownTrigger: number;
  3038. /**
  3039. * On key up
  3040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3041. */
  3042. static readonly OnKeyUpTrigger: number;
  3043. /** Gets the list of active triggers */
  3044. static Triggers: {
  3045. [key: string]: number;
  3046. };
  3047. /** Gets the list of actions */
  3048. actions: Action[];
  3049. /** Gets the cursor to use when hovering items */
  3050. hoverCursor: string;
  3051. private _scene;
  3052. /**
  3053. * Creates a new action manager
  3054. * @param scene defines the hosting scene
  3055. */
  3056. constructor(scene: Scene);
  3057. /**
  3058. * Releases all associated resources
  3059. */
  3060. dispose(): void;
  3061. /**
  3062. * Gets hosting scene
  3063. * @returns the hosting scene
  3064. */
  3065. getScene(): Scene;
  3066. /**
  3067. * Does this action manager handles actions of any of the given triggers
  3068. * @param triggers defines the triggers to be tested
  3069. * @return a boolean indicating whether one (or more) of the triggers is handled
  3070. */
  3071. hasSpecificTriggers(triggers: number[]): boolean;
  3072. /**
  3073. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3074. * speed.
  3075. * @param triggerA defines the trigger to be tested
  3076. * @param triggerB defines the trigger to be tested
  3077. * @return a boolean indicating whether one (or more) of the triggers is handled
  3078. */
  3079. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3080. /**
  3081. * Does this action manager handles actions of a given trigger
  3082. * @param trigger defines the trigger to be tested
  3083. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3084. * @return whether the trigger is handled
  3085. */
  3086. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3087. /**
  3088. * Does this action manager has pointer triggers
  3089. */
  3090. readonly hasPointerTriggers: boolean;
  3091. /**
  3092. * Does this action manager has pick triggers
  3093. */
  3094. readonly hasPickTriggers: boolean;
  3095. /**
  3096. * Does exist one action manager with at least one trigger
  3097. **/
  3098. static readonly HasTriggers: boolean;
  3099. /**
  3100. * Does exist one action manager with at least one pick trigger
  3101. **/
  3102. static readonly HasPickTriggers: boolean;
  3103. /**
  3104. * Does exist one action manager that handles actions of a given trigger
  3105. * @param trigger defines the trigger to be tested
  3106. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3107. **/
  3108. static HasSpecificTrigger(trigger: number): boolean;
  3109. /**
  3110. * Registers an action to this action manager
  3111. * @param action defines the action to be registered
  3112. * @return the action amended (prepared) after registration
  3113. */
  3114. registerAction(action: Action): Nullable<Action>;
  3115. /**
  3116. * Unregisters an action to this action manager
  3117. * @param action defines the action to be unregistered
  3118. * @return a boolean indicating whether the action has been unregistered
  3119. */
  3120. unregisterAction(action: Action): Boolean;
  3121. /**
  3122. * Process a specific trigger
  3123. * @param trigger defines the trigger to process
  3124. * @param evt defines the event details to be processed
  3125. */
  3126. processTrigger(trigger: number, evt?: ActionEvent): void;
  3127. /** @hidden */
  3128. _getEffectiveTarget(target: any, propertyPath: string): any;
  3129. /** @hidden */
  3130. _getProperty(propertyPath: string): string;
  3131. /**
  3132. * Serialize this manager to a JSON object
  3133. * @param name defines the property name to store this manager
  3134. * @returns a JSON representation of this manager
  3135. */
  3136. serialize(name: string): any;
  3137. /**
  3138. * Creates a new ActionManager from a JSON data
  3139. * @param parsedActions defines the JSON data to read from
  3140. * @param object defines the hosting mesh
  3141. * @param scene defines the hosting scene
  3142. */
  3143. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3144. /**
  3145. * Get a trigger name by index
  3146. * @param trigger defines the trigger index
  3147. * @returns a trigger name
  3148. */
  3149. static GetTriggerName(trigger: number): string;
  3150. }
  3151. }
  3152. declare module BABYLON {
  3153. /**
  3154. * A Condition applied to an Action
  3155. */
  3156. class Condition {
  3157. /**
  3158. * Internal only - manager for action
  3159. * @hidden
  3160. */
  3161. _actionManager: ActionManager;
  3162. /**
  3163. * Internal only
  3164. * @hidden
  3165. */
  3166. _evaluationId: number;
  3167. /**
  3168. * Internal only
  3169. * @hidden
  3170. */
  3171. _currentResult: boolean;
  3172. /**
  3173. * Creates a new Condition
  3174. * @param actionManager the manager of the action the condition is applied to
  3175. */
  3176. constructor(actionManager: ActionManager);
  3177. /**
  3178. * Check if the current condition is valid
  3179. * @returns a boolean
  3180. */
  3181. isValid(): boolean;
  3182. /**
  3183. * Internal only
  3184. * @hidden
  3185. */
  3186. _getProperty(propertyPath: string): string;
  3187. /**
  3188. * Internal only
  3189. * @hidden
  3190. */
  3191. _getEffectiveTarget(target: any, propertyPath: string): any;
  3192. /**
  3193. * Serialize placeholder for child classes
  3194. * @returns the serialized object
  3195. */
  3196. serialize(): any;
  3197. /**
  3198. * Internal only
  3199. * @hidden
  3200. */
  3201. protected _serialize(serializedCondition: any): any;
  3202. }
  3203. /**
  3204. * Defines specific conditional operators as extensions of Condition
  3205. */
  3206. class ValueCondition extends Condition {
  3207. /** path to specify the property of the target the conditional operator uses */
  3208. propertyPath: string;
  3209. /** the value compared by the conditional operator against the current value of the property */
  3210. value: any;
  3211. /** the conditional operator, default ValueCondition.IsEqual */
  3212. operator: number;
  3213. /**
  3214. * Internal only
  3215. * @hidden
  3216. */
  3217. private static _IsEqual;
  3218. /**
  3219. * Internal only
  3220. * @hidden
  3221. */
  3222. private static _IsDifferent;
  3223. /**
  3224. * Internal only
  3225. * @hidden
  3226. */
  3227. private static _IsGreater;
  3228. /**
  3229. * Internal only
  3230. * @hidden
  3231. */
  3232. private static _IsLesser;
  3233. /**
  3234. * returns the number for IsEqual
  3235. */
  3236. static readonly IsEqual: number;
  3237. /**
  3238. * Returns the number for IsDifferent
  3239. */
  3240. static readonly IsDifferent: number;
  3241. /**
  3242. * Returns the number for IsGreater
  3243. */
  3244. static readonly IsGreater: number;
  3245. /**
  3246. * Returns the number for IsLesser
  3247. */
  3248. static readonly IsLesser: number;
  3249. /**
  3250. * Internal only The action manager for the condition
  3251. * @hidden
  3252. */
  3253. _actionManager: ActionManager;
  3254. /**
  3255. * Internal only
  3256. * @hidden
  3257. */
  3258. private _target;
  3259. /**
  3260. * Internal only
  3261. * @hidden
  3262. */
  3263. private _effectiveTarget;
  3264. /**
  3265. * Internal only
  3266. * @hidden
  3267. */
  3268. private _property;
  3269. /**
  3270. * Creates a new ValueCondition
  3271. * @param actionManager manager for the action the condition applies to
  3272. * @param target for the action
  3273. * @param propertyPath path to specify the property of the target the conditional operator uses
  3274. * @param value the value compared by the conditional operator against the current value of the property
  3275. * @param operator the conditional operator, default ValueCondition.IsEqual
  3276. */
  3277. constructor(actionManager: ActionManager, target: any,
  3278. /** path to specify the property of the target the conditional operator uses */
  3279. propertyPath: string,
  3280. /** the value compared by the conditional operator against the current value of the property */
  3281. value: any,
  3282. /** the conditional operator, default ValueCondition.IsEqual */
  3283. operator?: number);
  3284. /**
  3285. * Compares the given value with the property value for the specified conditional operator
  3286. * @returns the result of the comparison
  3287. */
  3288. isValid(): boolean;
  3289. /**
  3290. * Serialize the ValueCondition into a JSON compatible object
  3291. * @returns serialization object
  3292. */
  3293. serialize(): any;
  3294. /**
  3295. * Gets the name of the conditional operator for the ValueCondition
  3296. * @param operator the conditional operator
  3297. * @returns the name
  3298. */
  3299. static GetOperatorName(operator: number): string;
  3300. }
  3301. /**
  3302. * Defines a predicate condition as an extension of Condition
  3303. */
  3304. class PredicateCondition extends Condition {
  3305. /** defines the predicate function used to validate the condition */
  3306. predicate: () => boolean;
  3307. /**
  3308. * Internal only - manager for action
  3309. * @hidden
  3310. */
  3311. _actionManager: ActionManager;
  3312. /**
  3313. * Creates a new PredicateCondition
  3314. * @param actionManager manager for the action the condition applies to
  3315. * @param predicate defines the predicate function used to validate the condition
  3316. */
  3317. constructor(actionManager: ActionManager,
  3318. /** defines the predicate function used to validate the condition */
  3319. predicate: () => boolean);
  3320. /**
  3321. * @returns the validity of the predicate condition
  3322. */
  3323. isValid(): boolean;
  3324. }
  3325. /**
  3326. * Defines a state condition as an extension of Condition
  3327. */
  3328. class StateCondition extends Condition {
  3329. /** Value to compare with target state */
  3330. value: string;
  3331. /**
  3332. * Internal only - manager for action
  3333. * @hidden
  3334. */
  3335. _actionManager: ActionManager;
  3336. /**
  3337. * Internal only
  3338. * @hidden
  3339. */
  3340. private _target;
  3341. /**
  3342. * Creates a new StateCondition
  3343. * @param actionManager manager for the action the condition applies to
  3344. * @param target of the condition
  3345. * @param value to compare with target state
  3346. */
  3347. constructor(actionManager: ActionManager, target: any,
  3348. /** Value to compare with target state */
  3349. value: string);
  3350. /**
  3351. * Gets a boolean indicating if the current condition is met
  3352. * @returns the validity of the state
  3353. */
  3354. isValid(): boolean;
  3355. /**
  3356. * Serialize the StateCondition into a JSON compatible object
  3357. * @returns serialization object
  3358. */
  3359. serialize(): any;
  3360. }
  3361. }
  3362. declare module BABYLON {
  3363. /**
  3364. * This defines an action responsible to toggle a boolean once triggered.
  3365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3366. */
  3367. class SwitchBooleanAction extends Action {
  3368. /**
  3369. * The path to the boolean property in the target object
  3370. */
  3371. propertyPath: string;
  3372. private _target;
  3373. private _effectiveTarget;
  3374. private _property;
  3375. /**
  3376. * Instantiate the action
  3377. * @param triggerOptions defines the trigger options
  3378. * @param target defines the object containing the boolean
  3379. * @param propertyPath defines the path to the boolean property in the target object
  3380. * @param condition defines the trigger related conditions
  3381. */
  3382. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3383. /** @hidden */
  3384. _prepare(): void;
  3385. /**
  3386. * Execute the action toggle the boolean value.
  3387. */
  3388. execute(): void;
  3389. /**
  3390. * Serializes the actions and its related information.
  3391. * @param parent defines the object to serialize in
  3392. * @returns the serialized object
  3393. */
  3394. serialize(parent: any): any;
  3395. }
  3396. /**
  3397. * This defines an action responsible to set a the state field of the target
  3398. * to a desired value once triggered.
  3399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3400. */
  3401. class SetStateAction extends Action {
  3402. /**
  3403. * The value to store in the state field.
  3404. */
  3405. value: string;
  3406. private _target;
  3407. /**
  3408. * Instantiate the action
  3409. * @param triggerOptions defines the trigger options
  3410. * @param target defines the object containing the state property
  3411. * @param value defines the value to store in the state field
  3412. * @param condition defines the trigger related conditions
  3413. */
  3414. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3415. /**
  3416. * Execute the action and store the value on the target state property.
  3417. */
  3418. execute(): void;
  3419. /**
  3420. * Serializes the actions and its related information.
  3421. * @param parent defines the object to serialize in
  3422. * @returns the serialized object
  3423. */
  3424. serialize(parent: any): any;
  3425. }
  3426. /**
  3427. * This defines an action responsible to set a property of the target
  3428. * to a desired value once triggered.
  3429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3430. */
  3431. class SetValueAction extends Action {
  3432. /**
  3433. * The path of the property to set in the target.
  3434. */
  3435. propertyPath: string;
  3436. /**
  3437. * The value to set in the property
  3438. */
  3439. value: any;
  3440. private _target;
  3441. private _effectiveTarget;
  3442. private _property;
  3443. /**
  3444. * Instantiate the action
  3445. * @param triggerOptions defines the trigger options
  3446. * @param target defines the object containing the property
  3447. * @param propertyPath defines the path of the property to set in the target
  3448. * @param value defines the value to set in the property
  3449. * @param condition defines the trigger related conditions
  3450. */
  3451. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3452. /** @hidden */
  3453. _prepare(): void;
  3454. /**
  3455. * Execute the action and set the targetted property to the desired value.
  3456. */
  3457. execute(): void;
  3458. /**
  3459. * Serializes the actions and its related information.
  3460. * @param parent defines the object to serialize in
  3461. * @returns the serialized object
  3462. */
  3463. serialize(parent: any): any;
  3464. }
  3465. /**
  3466. * This defines an action responsible to increment the target value
  3467. * to a desired value once triggered.
  3468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3469. */
  3470. class IncrementValueAction extends Action {
  3471. /**
  3472. * The path of the property to increment in the target.
  3473. */
  3474. propertyPath: string;
  3475. /**
  3476. * The value we should increment the property by.
  3477. */
  3478. value: any;
  3479. private _target;
  3480. private _effectiveTarget;
  3481. private _property;
  3482. /**
  3483. * Instantiate the action
  3484. * @param triggerOptions defines the trigger options
  3485. * @param target defines the object containing the property
  3486. * @param propertyPath defines the path of the property to increment in the target
  3487. * @param value defines the value value we should increment the property by
  3488. * @param condition defines the trigger related conditions
  3489. */
  3490. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3491. /** @hidden */
  3492. _prepare(): void;
  3493. /**
  3494. * Execute the action and increment the target of the value amount.
  3495. */
  3496. execute(): void;
  3497. /**
  3498. * Serializes the actions and its related information.
  3499. * @param parent defines the object to serialize in
  3500. * @returns the serialized object
  3501. */
  3502. serialize(parent: any): any;
  3503. }
  3504. /**
  3505. * This defines an action responsible to start an animation once triggered.
  3506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3507. */
  3508. class PlayAnimationAction extends Action {
  3509. /**
  3510. * Where the animation should start (animation frame)
  3511. */
  3512. from: number;
  3513. /**
  3514. * Where the animation should stop (animation frame)
  3515. */
  3516. to: number;
  3517. /**
  3518. * Define if the animation should loop or stop after the first play.
  3519. */
  3520. loop?: boolean;
  3521. private _target;
  3522. /**
  3523. * Instantiate the action
  3524. * @param triggerOptions defines the trigger options
  3525. * @param target defines the target animation or animation name
  3526. * @param from defines from where the animation should start (animation frame)
  3527. * @param end defines where the animation should stop (animation frame)
  3528. * @param loop defines if the animation should loop or stop after the first play
  3529. * @param condition defines the trigger related conditions
  3530. */
  3531. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3532. /** @hidden */
  3533. _prepare(): void;
  3534. /**
  3535. * Execute the action and play the animation.
  3536. */
  3537. execute(): void;
  3538. /**
  3539. * Serializes the actions and its related information.
  3540. * @param parent defines the object to serialize in
  3541. * @returns the serialized object
  3542. */
  3543. serialize(parent: any): any;
  3544. }
  3545. /**
  3546. * This defines an action responsible to stop an animation once triggered.
  3547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3548. */
  3549. class StopAnimationAction extends Action {
  3550. private _target;
  3551. /**
  3552. * Instantiate the action
  3553. * @param triggerOptions defines the trigger options
  3554. * @param target defines the target animation or animation name
  3555. * @param condition defines the trigger related conditions
  3556. */
  3557. constructor(triggerOptions: any, target: any, condition?: Condition);
  3558. /** @hidden */
  3559. _prepare(): void;
  3560. /**
  3561. * Execute the action and stop the animation.
  3562. */
  3563. execute(): void;
  3564. /**
  3565. * Serializes the actions and its related information.
  3566. * @param parent defines the object to serialize in
  3567. * @returns the serialized object
  3568. */
  3569. serialize(parent: any): any;
  3570. }
  3571. /**
  3572. * This defines an action responsible that does nothing once triggered.
  3573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3574. */
  3575. class DoNothingAction extends Action {
  3576. /**
  3577. * Instantiate the action
  3578. * @param triggerOptions defines the trigger options
  3579. * @param condition defines the trigger related conditions
  3580. */
  3581. constructor(triggerOptions?: any, condition?: Condition);
  3582. /**
  3583. * Execute the action and do nothing.
  3584. */
  3585. execute(): void;
  3586. /**
  3587. * Serializes the actions and its related information.
  3588. * @param parent defines the object to serialize in
  3589. * @returns the serialized object
  3590. */
  3591. serialize(parent: any): any;
  3592. }
  3593. /**
  3594. * This defines an action responsible to trigger several actions once triggered.
  3595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3596. */
  3597. class CombineAction extends Action {
  3598. /**
  3599. * The list of aggregated animations to run.
  3600. */
  3601. children: Action[];
  3602. /**
  3603. * Instantiate the action
  3604. * @param triggerOptions defines the trigger options
  3605. * @param children defines the list of aggregated animations to run
  3606. * @param condition defines the trigger related conditions
  3607. */
  3608. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3609. /** @hidden */
  3610. _prepare(): void;
  3611. /**
  3612. * Execute the action and executes all the aggregated actions.
  3613. */
  3614. execute(evt: ActionEvent): void;
  3615. /**
  3616. * Serializes the actions and its related information.
  3617. * @param parent defines the object to serialize in
  3618. * @returns the serialized object
  3619. */
  3620. serialize(parent: any): any;
  3621. }
  3622. /**
  3623. * This defines an action responsible to run code (external event) once triggered.
  3624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3625. */
  3626. class ExecuteCodeAction extends Action {
  3627. /**
  3628. * The callback function to run.
  3629. */
  3630. func: (evt: ActionEvent) => void;
  3631. /**
  3632. * Instantiate the action
  3633. * @param triggerOptions defines the trigger options
  3634. * @param func defines the callback function to run
  3635. * @param condition defines the trigger related conditions
  3636. */
  3637. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3638. /**
  3639. * Execute the action and run the attached code.
  3640. */
  3641. execute(evt: ActionEvent): void;
  3642. }
  3643. /**
  3644. * This defines an action responsible to set the parent property of the target once triggered.
  3645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3646. */
  3647. class SetParentAction extends Action {
  3648. private _parent;
  3649. private _target;
  3650. /**
  3651. * Instantiate the action
  3652. * @param triggerOptions defines the trigger options
  3653. * @param target defines the target containing the parent property
  3654. * @param parent defines from where the animation should start (animation frame)
  3655. * @param condition defines the trigger related conditions
  3656. */
  3657. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3658. /** @hidden */
  3659. _prepare(): void;
  3660. /**
  3661. * Execute the action and set the parent property.
  3662. */
  3663. execute(): void;
  3664. /**
  3665. * Serializes the actions and its related information.
  3666. * @param parent defines the object to serialize in
  3667. * @returns the serialized object
  3668. */
  3669. serialize(parent: any): any;
  3670. }
  3671. }
  3672. declare module BABYLON {
  3673. /**
  3674. * This defines an action helpful to play a defined sound on a triggered action.
  3675. */
  3676. class PlaySoundAction extends Action {
  3677. private _sound;
  3678. /**
  3679. * Instantiate the action
  3680. * @param triggerOptions defines the trigger options
  3681. * @param sound defines the sound to play
  3682. * @param condition defines the trigger related conditions
  3683. */
  3684. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3685. /** @hidden */
  3686. _prepare(): void;
  3687. /**
  3688. * Execute the action and play the sound.
  3689. */
  3690. execute(): void;
  3691. /**
  3692. * Serializes the actions and its related information.
  3693. * @param parent defines the object to serialize in
  3694. * @returns the serialized object
  3695. */
  3696. serialize(parent: any): any;
  3697. }
  3698. /**
  3699. * This defines an action helpful to stop a defined sound on a triggered action.
  3700. */
  3701. class StopSoundAction extends Action {
  3702. private _sound;
  3703. /**
  3704. * Instantiate the action
  3705. * @param triggerOptions defines the trigger options
  3706. * @param sound defines the sound to stop
  3707. * @param condition defines the trigger related conditions
  3708. */
  3709. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3710. /** @hidden */
  3711. _prepare(): void;
  3712. /**
  3713. * Execute the action and stop the sound.
  3714. */
  3715. execute(): void;
  3716. /**
  3717. * Serializes the actions and its related information.
  3718. * @param parent defines the object to serialize in
  3719. * @returns the serialized object
  3720. */
  3721. serialize(parent: any): any;
  3722. }
  3723. }
  3724. declare module BABYLON {
  3725. /**
  3726. * This defines an action responsible to change the value of a property
  3727. * by interpolating between its current value and the newly set one once triggered.
  3728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3729. */
  3730. class InterpolateValueAction extends Action {
  3731. /**
  3732. * Defines the path of the property where the value should be interpolated
  3733. */
  3734. propertyPath: string;
  3735. /**
  3736. * Defines the target value at the end of the interpolation.
  3737. */
  3738. value: any;
  3739. /**
  3740. * Defines the time it will take for the property to interpolate to the value.
  3741. */
  3742. duration: number;
  3743. /**
  3744. * Defines if the other scene animations should be stopped when the action has been triggered
  3745. */
  3746. stopOtherAnimations?: boolean;
  3747. /**
  3748. * Defines a callback raised once the interpolation animation has been done.
  3749. */
  3750. onInterpolationDone?: () => void;
  3751. /**
  3752. * Observable triggered once the interpolation animation has been done.
  3753. */
  3754. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3755. private _target;
  3756. private _effectiveTarget;
  3757. private _property;
  3758. /**
  3759. * Instantiate the action
  3760. * @param triggerOptions defines the trigger options
  3761. * @param target defines the object containing the value to interpolate
  3762. * @param propertyPath defines the path to the property in the target object
  3763. * @param value defines the target value at the end of the interpolation
  3764. * @param duration deines the time it will take for the property to interpolate to the value.
  3765. * @param condition defines the trigger related conditions
  3766. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3767. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3768. */
  3769. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3770. /** @hidden */
  3771. _prepare(): void;
  3772. /**
  3773. * Execute the action starts the value interpolation.
  3774. */
  3775. execute(): void;
  3776. /**
  3777. * Serializes the actions and its related information.
  3778. * @param parent defines the object to serialize in
  3779. * @returns the serialized object
  3780. */
  3781. serialize(parent: any): any;
  3782. }
  3783. }
  3784. declare module BABYLON {
  3785. /**
  3786. * Class used to store an actual running animation
  3787. */
  3788. class Animatable {
  3789. /** defines the target object */
  3790. target: any;
  3791. /** defines the starting frame number (default is 0) */
  3792. fromFrame: number;
  3793. /** defines the ending frame number (default is 100) */
  3794. toFrame: number;
  3795. /** defines if the animation must loop (default is false) */
  3796. loopAnimation: boolean;
  3797. /** defines a callback to call when animation ends if it is not looping */
  3798. onAnimationEnd?: (() => void) | null | undefined;
  3799. private _localDelayOffset;
  3800. private _pausedDelay;
  3801. private _runtimeAnimations;
  3802. private _paused;
  3803. private _scene;
  3804. private _speedRatio;
  3805. private _weight;
  3806. private _syncRoot;
  3807. /**
  3808. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3809. * This will only apply for non looping animation (default is true)
  3810. */
  3811. disposeOnEnd: boolean;
  3812. /**
  3813. * Gets a boolean indicating if the animation has started
  3814. */
  3815. animationStarted: boolean;
  3816. /**
  3817. * Observer raised when the animation ends
  3818. */
  3819. onAnimationEndObservable: Observable<Animatable>;
  3820. /**
  3821. * Gets the root Animatable used to synchronize and normalize animations
  3822. */
  3823. readonly syncRoot: Animatable;
  3824. /**
  3825. * Gets the current frame of the first RuntimeAnimation
  3826. * Used to synchronize Animatables
  3827. */
  3828. readonly masterFrame: number;
  3829. /**
  3830. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3831. */
  3832. weight: number;
  3833. /**
  3834. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3835. */
  3836. speedRatio: number;
  3837. /**
  3838. * Creates a new Animatable
  3839. * @param scene defines the hosting scene
  3840. * @param target defines the target object
  3841. * @param fromFrame defines the starting frame number (default is 0)
  3842. * @param toFrame defines the ending frame number (default is 100)
  3843. * @param loopAnimation defines if the animation must loop (default is false)
  3844. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3845. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3846. * @param animations defines a group of animation to add to the new Animatable
  3847. */
  3848. constructor(scene: Scene,
  3849. /** defines the target object */
  3850. target: any,
  3851. /** defines the starting frame number (default is 0) */
  3852. fromFrame?: number,
  3853. /** defines the ending frame number (default is 100) */
  3854. toFrame?: number,
  3855. /** defines if the animation must loop (default is false) */
  3856. loopAnimation?: boolean, speedRatio?: number,
  3857. /** defines a callback to call when animation ends if it is not looping */
  3858. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3859. /**
  3860. * Synchronize and normalize current Animatable with a source Animatable
  3861. * This is useful when using animation weights and when animations are not of the same length
  3862. * @param root defines the root Animatable to synchronize with
  3863. * @returns the current Animatable
  3864. */
  3865. syncWith(root: Animatable): Animatable;
  3866. /**
  3867. * Gets the list of runtime animations
  3868. * @returns an array of RuntimeAnimation
  3869. */
  3870. getAnimations(): RuntimeAnimation[];
  3871. /**
  3872. * Adds more animations to the current animatable
  3873. * @param target defines the target of the animations
  3874. * @param animations defines the new animations to add
  3875. */
  3876. appendAnimations(target: any, animations: Animation[]): void;
  3877. /**
  3878. * Gets the source animation for a specific property
  3879. * @param property defines the propertyu to look for
  3880. * @returns null or the source animation for the given property
  3881. */
  3882. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3883. /**
  3884. * Gets the runtime animation for a specific property
  3885. * @param property defines the propertyu to look for
  3886. * @returns null or the runtime animation for the given property
  3887. */
  3888. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3889. /**
  3890. * Resets the animatable to its original state
  3891. */
  3892. reset(): void;
  3893. /**
  3894. * Allows the animatable to blend with current running animations
  3895. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3896. * @param blendingSpeed defines the blending speed to use
  3897. */
  3898. enableBlending(blendingSpeed: number): void;
  3899. /**
  3900. * Disable animation blending
  3901. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3902. */
  3903. disableBlending(): void;
  3904. /**
  3905. * Jump directly to a given frame
  3906. * @param frame defines the frame to jump to
  3907. */
  3908. goToFrame(frame: number): void;
  3909. /**
  3910. * Pause the animation
  3911. */
  3912. pause(): void;
  3913. /**
  3914. * Restart the animation
  3915. */
  3916. restart(): void;
  3917. private _raiseOnAnimationEnd;
  3918. /**
  3919. * Stop and delete the current animation
  3920. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3921. * @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)
  3922. */
  3923. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3924. /**
  3925. * Wait asynchronously for the animation to end
  3926. * @returns a promise which will be fullfilled when the animation ends
  3927. */
  3928. waitAsync(): Promise<Animatable>;
  3929. /** @hidden */
  3930. _animate(delay: number): boolean;
  3931. }
  3932. }
  3933. declare module BABYLON {
  3934. /**
  3935. * Represents the range of an animation
  3936. */
  3937. class AnimationRange {
  3938. /**The name of the animation range**/
  3939. name: string;
  3940. /**The starting frame of the animation */
  3941. from: number;
  3942. /**The ending frame of the animation*/
  3943. to: number;
  3944. /**
  3945. * Initializes the range of an animation
  3946. * @param name The name of the animation range
  3947. * @param from The starting frame of the animation
  3948. * @param to The ending frame of the animation
  3949. */
  3950. constructor(
  3951. /**The name of the animation range**/
  3952. name: string,
  3953. /**The starting frame of the animation */
  3954. from: number,
  3955. /**The ending frame of the animation*/
  3956. to: number);
  3957. /**
  3958. * Makes a copy of the animation range
  3959. * @returns A copy of the animation range
  3960. */
  3961. clone(): AnimationRange;
  3962. }
  3963. /**
  3964. * Composed of a frame, and an action function
  3965. */
  3966. class AnimationEvent {
  3967. /** The frame for which the event is triggered **/
  3968. frame: number;
  3969. /** The event to perform when triggered **/
  3970. action: (currentFrame: number) => void;
  3971. /** Specifies if the event should be triggered only once**/
  3972. onlyOnce?: boolean | undefined;
  3973. /**
  3974. * Specifies if the animation event is done
  3975. */
  3976. isDone: boolean;
  3977. /**
  3978. * Initializes the animation event
  3979. * @param frame The frame for which the event is triggered
  3980. * @param action The event to perform when triggered
  3981. * @param onlyOnce Specifies if the event should be triggered only once
  3982. */
  3983. constructor(
  3984. /** The frame for which the event is triggered **/
  3985. frame: number,
  3986. /** The event to perform when triggered **/
  3987. action: (currentFrame: number) => void,
  3988. /** Specifies if the event should be triggered only once**/
  3989. onlyOnce?: boolean | undefined);
  3990. /** @hidden */
  3991. _clone(): AnimationEvent;
  3992. }
  3993. /**
  3994. * A cursor which tracks a point on a path
  3995. */
  3996. class PathCursor {
  3997. private path;
  3998. /**
  3999. * Stores path cursor callbacks for when an onchange event is triggered
  4000. */
  4001. private _onchange;
  4002. /**
  4003. * The value of the path cursor
  4004. */
  4005. value: number;
  4006. /**
  4007. * The animation array of the path cursor
  4008. */
  4009. animations: Animation[];
  4010. /**
  4011. * Initializes the path cursor
  4012. * @param path The path to track
  4013. */
  4014. constructor(path: Path2);
  4015. /**
  4016. * Gets the cursor point on the path
  4017. * @returns A point on the path cursor at the cursor location
  4018. */
  4019. getPoint(): Vector3;
  4020. /**
  4021. * Moves the cursor ahead by the step amount
  4022. * @param step The amount to move the cursor forward
  4023. * @returns This path cursor
  4024. */
  4025. moveAhead(step?: number): PathCursor;
  4026. /**
  4027. * Moves the cursor behind by the step amount
  4028. * @param step The amount to move the cursor back
  4029. * @returns This path cursor
  4030. */
  4031. moveBack(step?: number): PathCursor;
  4032. /**
  4033. * Moves the cursor by the step amount
  4034. * If the step amount is greater than one, an exception is thrown
  4035. * @param step The amount to move the cursor
  4036. * @returns This path cursor
  4037. */
  4038. move(step: number): PathCursor;
  4039. /**
  4040. * Ensures that the value is limited between zero and one
  4041. * @returns This path cursor
  4042. */
  4043. private ensureLimits;
  4044. /**
  4045. * Runs onchange callbacks on change (used by the animation engine)
  4046. * @returns This path cursor
  4047. */
  4048. private raiseOnChange;
  4049. /**
  4050. * Executes a function on change
  4051. * @param f A path cursor onchange callback
  4052. * @returns This path cursor
  4053. */
  4054. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4055. }
  4056. /**
  4057. * Defines an interface which represents an animation key frame
  4058. */
  4059. interface IAnimationKey {
  4060. /**
  4061. * Frame of the key frame
  4062. */
  4063. frame: number;
  4064. /**
  4065. * Value at the specifies key frame
  4066. */
  4067. value: any;
  4068. /**
  4069. * The input tangent for the cubic hermite spline
  4070. */
  4071. inTangent?: any;
  4072. /**
  4073. * The output tangent for the cubic hermite spline
  4074. */
  4075. outTangent?: any;
  4076. /**
  4077. * The animation interpolation type
  4078. */
  4079. interpolation?: AnimationKeyInterpolation;
  4080. }
  4081. /**
  4082. * Enum for the animation key frame interpolation type
  4083. */
  4084. enum AnimationKeyInterpolation {
  4085. /**
  4086. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4087. */
  4088. STEP = 1
  4089. }
  4090. /**
  4091. * Class used to store any kind of animation
  4092. */
  4093. class Animation {
  4094. /**Name of the animation */
  4095. name: string;
  4096. /**Property to animate */
  4097. targetProperty: string;
  4098. /**The frames per second of the animation */
  4099. framePerSecond: number;
  4100. /**The data type of the animation */
  4101. dataType: number;
  4102. /**The loop mode of the animation */
  4103. loopMode?: number | undefined;
  4104. /**Specifies if blending should be enabled */
  4105. enableBlending?: boolean | undefined;
  4106. /**
  4107. * Use matrix interpolation instead of using direct key value when animating matrices
  4108. */
  4109. static AllowMatricesInterpolation: boolean;
  4110. /**
  4111. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4112. */
  4113. static AllowMatrixDecomposeForInterpolation: boolean;
  4114. /**
  4115. * Stores the key frames of the animation
  4116. */
  4117. private _keys;
  4118. /**
  4119. * Stores the easing function of the animation
  4120. */
  4121. private _easingFunction;
  4122. /**
  4123. * @hidden Internal use only
  4124. */
  4125. _runtimeAnimations: RuntimeAnimation[];
  4126. /**
  4127. * The set of event that will be linked to this animation
  4128. */
  4129. private _events;
  4130. /**
  4131. * Stores an array of target property paths
  4132. */
  4133. targetPropertyPath: string[];
  4134. /**
  4135. * Stores the blending speed of the animation
  4136. */
  4137. blendingSpeed: number;
  4138. /**
  4139. * Stores the animation ranges for the animation
  4140. */
  4141. private _ranges;
  4142. /**
  4143. * @hidden Internal use
  4144. */
  4145. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4146. /**
  4147. * Sets up an animation
  4148. * @param property The property to animate
  4149. * @param animationType The animation type to apply
  4150. * @param framePerSecond The frames per second of the animation
  4151. * @param easingFunction The easing function used in the animation
  4152. * @returns The created animation
  4153. */
  4154. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4155. /**
  4156. * Create and start an animation on a node
  4157. * @param name defines the name of the global animation that will be run on all nodes
  4158. * @param node defines the root node where the animation will take place
  4159. * @param targetProperty defines property to animate
  4160. * @param framePerSecond defines the number of frame per second yo use
  4161. * @param totalFrame defines the number of frames in total
  4162. * @param from defines the initial value
  4163. * @param to defines the final value
  4164. * @param loopMode defines which loop mode you want to use (off by default)
  4165. * @param easingFunction defines the easing function to use (linear by default)
  4166. * @param onAnimationEnd defines the callback to call when animation end
  4167. * @returns the animatable created for this animation
  4168. */
  4169. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4170. /**
  4171. * Create and start an animation on a node and its descendants
  4172. * @param name defines the name of the global animation that will be run on all nodes
  4173. * @param node defines the root node where the animation will take place
  4174. * @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
  4175. * @param targetProperty defines property to animate
  4176. * @param framePerSecond defines the number of frame per second to use
  4177. * @param totalFrame defines the number of frames in total
  4178. * @param from defines the initial value
  4179. * @param to defines the final value
  4180. * @param loopMode defines which loop mode you want to use (off by default)
  4181. * @param easingFunction defines the easing function to use (linear by default)
  4182. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4183. * @returns the list of animatables created for all nodes
  4184. * @example https://www.babylonjs-playground.com/#MH0VLI
  4185. */
  4186. 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[]>;
  4187. /**
  4188. * Creates a new animation, merges it with the existing animations and starts it
  4189. * @param name Name of the animation
  4190. * @param node Node which contains the scene that begins the animations
  4191. * @param targetProperty Specifies which property to animate
  4192. * @param framePerSecond The frames per second of the animation
  4193. * @param totalFrame The total number of frames
  4194. * @param from The frame at the beginning of the animation
  4195. * @param to The frame at the end of the animation
  4196. * @param loopMode Specifies the loop mode of the animation
  4197. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4198. * @param onAnimationEnd Callback to run once the animation is complete
  4199. * @returns Nullable animation
  4200. */
  4201. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4202. /**
  4203. * Transition property of an host to the target Value
  4204. * @param property The property to transition
  4205. * @param targetValue The target Value of the property
  4206. * @param host The object where the property to animate belongs
  4207. * @param scene Scene used to run the animation
  4208. * @param frameRate Framerate (in frame/s) to use
  4209. * @param transition The transition type we want to use
  4210. * @param duration The duration of the animation, in milliseconds
  4211. * @param onAnimationEnd Callback trigger at the end of the animation
  4212. * @returns Nullable animation
  4213. */
  4214. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4215. /**
  4216. * Return the array of runtime animations currently using this animation
  4217. */
  4218. readonly runtimeAnimations: RuntimeAnimation[];
  4219. /**
  4220. * Specifies if any of the runtime animations are currently running
  4221. */
  4222. readonly hasRunningRuntimeAnimations: boolean;
  4223. /**
  4224. * Initializes the animation
  4225. * @param name Name of the animation
  4226. * @param targetProperty Property to animate
  4227. * @param framePerSecond The frames per second of the animation
  4228. * @param dataType The data type of the animation
  4229. * @param loopMode The loop mode of the animation
  4230. * @param enableBlendings Specifies if blending should be enabled
  4231. */
  4232. constructor(
  4233. /**Name of the animation */
  4234. name: string,
  4235. /**Property to animate */
  4236. targetProperty: string,
  4237. /**The frames per second of the animation */
  4238. framePerSecond: number,
  4239. /**The data type of the animation */
  4240. dataType: number,
  4241. /**The loop mode of the animation */
  4242. loopMode?: number | undefined,
  4243. /**Specifies if blending should be enabled */
  4244. enableBlending?: boolean | undefined);
  4245. /**
  4246. * Converts the animation to a string
  4247. * @param fullDetails support for multiple levels of logging within scene loading
  4248. * @returns String form of the animation
  4249. */
  4250. toString(fullDetails?: boolean): string;
  4251. /**
  4252. * Add an event to this animation
  4253. * @param event Event to add
  4254. */
  4255. addEvent(event: AnimationEvent): void;
  4256. /**
  4257. * Remove all events found at the given frame
  4258. * @param frame The frame to remove events from
  4259. */
  4260. removeEvents(frame: number): void;
  4261. /**
  4262. * Retrieves all the events from the animation
  4263. * @returns Events from the animation
  4264. */
  4265. getEvents(): AnimationEvent[];
  4266. /**
  4267. * Creates an animation range
  4268. * @param name Name of the animation range
  4269. * @param from Starting frame of the animation range
  4270. * @param to Ending frame of the animation
  4271. */
  4272. createRange(name: string, from: number, to: number): void;
  4273. /**
  4274. * Deletes an animation range by name
  4275. * @param name Name of the animation range to delete
  4276. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4277. */
  4278. deleteRange(name: string, deleteFrames?: boolean): void;
  4279. /**
  4280. * Gets the animation range by name, or null if not defined
  4281. * @param name Name of the animation range
  4282. * @returns Nullable animation range
  4283. */
  4284. getRange(name: string): Nullable<AnimationRange>;
  4285. /**
  4286. * Gets the key frames from the animation
  4287. * @returns The key frames of the animation
  4288. */
  4289. getKeys(): Array<IAnimationKey>;
  4290. /**
  4291. * Gets the highest frame rate of the animation
  4292. * @returns Highest frame rate of the animation
  4293. */
  4294. getHighestFrame(): number;
  4295. /**
  4296. * Gets the easing function of the animation
  4297. * @returns Easing function of the animation
  4298. */
  4299. getEasingFunction(): IEasingFunction;
  4300. /**
  4301. * Sets the easing function of the animation
  4302. * @param easingFunction A custom mathematical formula for animation
  4303. */
  4304. setEasingFunction(easingFunction: EasingFunction): void;
  4305. /**
  4306. * Interpolates a scalar linearly
  4307. * @param startValue Start value of the animation curve
  4308. * @param endValue End value of the animation curve
  4309. * @param gradient Scalar amount to interpolate
  4310. * @returns Interpolated scalar value
  4311. */
  4312. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4313. /**
  4314. * Interpolates a scalar cubically
  4315. * @param startValue Start value of the animation curve
  4316. * @param outTangent End tangent of the animation
  4317. * @param endValue End value of the animation curve
  4318. * @param inTangent Start tangent of the animation curve
  4319. * @param gradient Scalar amount to interpolate
  4320. * @returns Interpolated scalar value
  4321. */
  4322. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4323. /**
  4324. * Interpolates a quaternion using a spherical linear interpolation
  4325. * @param startValue Start value of the animation curve
  4326. * @param endValue End value of the animation curve
  4327. * @param gradient Scalar amount to interpolate
  4328. * @returns Interpolated quaternion value
  4329. */
  4330. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4331. /**
  4332. * Interpolates a quaternion cubically
  4333. * @param startValue Start value of the animation curve
  4334. * @param outTangent End tangent of the animation curve
  4335. * @param endValue End value of the animation curve
  4336. * @param inTangent Start tangent of the animation curve
  4337. * @param gradient Scalar amount to interpolate
  4338. * @returns Interpolated quaternion value
  4339. */
  4340. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4341. /**
  4342. * Interpolates a Vector3 linearl
  4343. * @param startValue Start value of the animation curve
  4344. * @param endValue End value of the animation curve
  4345. * @param gradient Scalar amount to interpolate
  4346. * @returns Interpolated scalar value
  4347. */
  4348. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4349. /**
  4350. * Interpolates a Vector3 cubically
  4351. * @param startValue Start value of the animation curve
  4352. * @param outTangent End tangent of the animation
  4353. * @param endValue End value of the animation curve
  4354. * @param inTangent Start tangent of the animation curve
  4355. * @param gradient Scalar amount to interpolate
  4356. * @returns InterpolatedVector3 value
  4357. */
  4358. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4359. /**
  4360. * Interpolates a Vector2 linearly
  4361. * @param startValue Start value of the animation curve
  4362. * @param endValue End value of the animation curve
  4363. * @param gradient Scalar amount to interpolate
  4364. * @returns Interpolated Vector2 value
  4365. */
  4366. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4367. /**
  4368. * Interpolates a Vector2 cubically
  4369. * @param startValue Start value of the animation curve
  4370. * @param outTangent End tangent of the animation
  4371. * @param endValue End value of the animation curve
  4372. * @param inTangent Start tangent of the animation curve
  4373. * @param gradient Scalar amount to interpolate
  4374. * @returns Interpolated Vector2 value
  4375. */
  4376. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4377. /**
  4378. * Interpolates a size linearly
  4379. * @param startValue Start value of the animation curve
  4380. * @param endValue End value of the animation curve
  4381. * @param gradient Scalar amount to interpolate
  4382. * @returns Interpolated Size value
  4383. */
  4384. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4385. /**
  4386. * Interpolates a Color3 linearly
  4387. * @param startValue Start value of the animation curve
  4388. * @param endValue End value of the animation curve
  4389. * @param gradient Scalar amount to interpolate
  4390. * @returns Interpolated Color3 value
  4391. */
  4392. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4393. /**
  4394. * @hidden Internal use only
  4395. */
  4396. _getKeyValue(value: any): any;
  4397. /**
  4398. * @hidden Internal use only
  4399. */
  4400. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4401. /**
  4402. * Defines the function to use to interpolate matrices
  4403. * @param startValue defines the start matrix
  4404. * @param endValue defines the end matrix
  4405. * @param gradient defines the gradient between both matrices
  4406. * @param result defines an optional target matrix where to store the interpolation
  4407. * @returns the interpolated matrix
  4408. */
  4409. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4410. /**
  4411. * Makes a copy of the animation
  4412. * @returns Cloned animation
  4413. */
  4414. clone(): Animation;
  4415. /**
  4416. * Sets the key frames of the animation
  4417. * @param values The animation key frames to set
  4418. */
  4419. setKeys(values: Array<IAnimationKey>): void;
  4420. /**
  4421. * Serializes the animation to an object
  4422. * @returns Serialized object
  4423. */
  4424. serialize(): any;
  4425. /**
  4426. * Float animation type
  4427. */
  4428. private static _ANIMATIONTYPE_FLOAT;
  4429. /**
  4430. * Vector3 animation type
  4431. */
  4432. private static _ANIMATIONTYPE_VECTOR3;
  4433. /**
  4434. * Quaternion animation type
  4435. */
  4436. private static _ANIMATIONTYPE_QUATERNION;
  4437. /**
  4438. * Matrix animation type
  4439. */
  4440. private static _ANIMATIONTYPE_MATRIX;
  4441. /**
  4442. * Color3 animation type
  4443. */
  4444. private static _ANIMATIONTYPE_COLOR3;
  4445. /**
  4446. * Vector2 animation type
  4447. */
  4448. private static _ANIMATIONTYPE_VECTOR2;
  4449. /**
  4450. * Size animation type
  4451. */
  4452. private static _ANIMATIONTYPE_SIZE;
  4453. /**
  4454. * Relative Loop Mode
  4455. */
  4456. private static _ANIMATIONLOOPMODE_RELATIVE;
  4457. /**
  4458. * Cycle Loop Mode
  4459. */
  4460. private static _ANIMATIONLOOPMODE_CYCLE;
  4461. /**
  4462. * Constant Loop Mode
  4463. */
  4464. private static _ANIMATIONLOOPMODE_CONSTANT;
  4465. /**
  4466. * Get the float animation type
  4467. */
  4468. static readonly ANIMATIONTYPE_FLOAT: number;
  4469. /**
  4470. * Get the Vector3 animation type
  4471. */
  4472. static readonly ANIMATIONTYPE_VECTOR3: number;
  4473. /**
  4474. * Get the Vector2 animation type
  4475. */
  4476. static readonly ANIMATIONTYPE_VECTOR2: number;
  4477. /**
  4478. * Get the Size animation type
  4479. */
  4480. static readonly ANIMATIONTYPE_SIZE: number;
  4481. /**
  4482. * Get the Quaternion animation type
  4483. */
  4484. static readonly ANIMATIONTYPE_QUATERNION: number;
  4485. /**
  4486. * Get the Matrix animation type
  4487. */
  4488. static readonly ANIMATIONTYPE_MATRIX: number;
  4489. /**
  4490. * Get the Color3 animation type
  4491. */
  4492. static readonly ANIMATIONTYPE_COLOR3: number;
  4493. /**
  4494. * Get the Relative Loop Mode
  4495. */
  4496. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4497. /**
  4498. * Get the Cycle Loop Mode
  4499. */
  4500. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4501. /**
  4502. * Get the Constant Loop Mode
  4503. */
  4504. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4505. /** @hidden */
  4506. static _UniversalLerp(left: any, right: any, amount: number): any;
  4507. /**
  4508. * Parses an animation object and creates an animation
  4509. * @param parsedAnimation Parsed animation object
  4510. * @returns Animation object
  4511. */
  4512. static Parse(parsedAnimation: any): Animation;
  4513. /**
  4514. * Appends the serialized animations from the source animations
  4515. * @param source Source containing the animations
  4516. * @param destination Target to store the animations
  4517. */
  4518. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4519. }
  4520. }
  4521. declare module BABYLON {
  4522. /**
  4523. * This class defines the direct association between an animation and a target
  4524. */
  4525. class TargetedAnimation {
  4526. /**
  4527. * Animation to perform
  4528. */
  4529. animation: Animation;
  4530. /**
  4531. * Target to animate
  4532. */
  4533. target: any;
  4534. }
  4535. /**
  4536. * Use this class to create coordinated animations on multiple targets
  4537. */
  4538. class AnimationGroup implements IDisposable {
  4539. /** The name of the animation group */
  4540. name: string;
  4541. private _scene;
  4542. private _targetedAnimations;
  4543. private _animatables;
  4544. private _from;
  4545. private _to;
  4546. private _isStarted;
  4547. private _speedRatio;
  4548. /**
  4549. * This observable will notify when one animation have ended.
  4550. */
  4551. onAnimationEndObservable: Observable<TargetedAnimation>;
  4552. /**
  4553. * This observable will notify when all animations have ended.
  4554. */
  4555. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4556. /**
  4557. * This observable will notify when all animations have paused.
  4558. */
  4559. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4560. /**
  4561. * Gets the first frame
  4562. */
  4563. readonly from: number;
  4564. /**
  4565. * Gets the last frame
  4566. */
  4567. readonly to: number;
  4568. /**
  4569. * Define if the animations are started
  4570. */
  4571. readonly isStarted: boolean;
  4572. /**
  4573. * Gets or sets the speed ratio to use for all animations
  4574. */
  4575. /**
  4576. * Gets or sets the speed ratio to use for all animations
  4577. */
  4578. speedRatio: number;
  4579. /**
  4580. * Gets the targeted animations for this animation group
  4581. */
  4582. readonly targetedAnimations: Array<TargetedAnimation>;
  4583. /**
  4584. * returning the list of animatables controlled by this animation group.
  4585. */
  4586. readonly animatables: Array<Animatable>;
  4587. /**
  4588. * Instantiates a new Animation Group.
  4589. * This helps managing several animations at once.
  4590. * @see http://doc.babylonjs.com/how_to/group
  4591. * @param name Defines the name of the group
  4592. * @param scene Defines the scene the group belongs to
  4593. */
  4594. constructor(
  4595. /** The name of the animation group */
  4596. name: string, scene?: Nullable<Scene>);
  4597. /**
  4598. * Add an animation (with its target) in the group
  4599. * @param animation defines the animation we want to add
  4600. * @param target defines the target of the animation
  4601. * @returns the TargetedAnimation object
  4602. */
  4603. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4604. /**
  4605. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4606. * It can add constant keys at begin or end
  4607. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4608. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4609. * @returns the animation group
  4610. */
  4611. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4612. /**
  4613. * Start all animations on given targets
  4614. * @param loop defines if animations must loop
  4615. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4616. * @param from defines the from key (optional)
  4617. * @param to defines the to key (optional)
  4618. * @returns the current animation group
  4619. */
  4620. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4621. /**
  4622. * Pause all animations
  4623. * @returns the animation group
  4624. */
  4625. pause(): AnimationGroup;
  4626. /**
  4627. * Play all animations to initial state
  4628. * This function will start() the animations if they were not started or will restart() them if they were paused
  4629. * @param loop defines if animations must loop
  4630. * @returns the animation group
  4631. */
  4632. play(loop?: boolean): AnimationGroup;
  4633. /**
  4634. * Reset all animations to initial state
  4635. * @returns the animation group
  4636. */
  4637. reset(): AnimationGroup;
  4638. /**
  4639. * Restart animations from key 0
  4640. * @returns the animation group
  4641. */
  4642. restart(): AnimationGroup;
  4643. /**
  4644. * Stop all animations
  4645. * @returns the animation group
  4646. */
  4647. stop(): AnimationGroup;
  4648. /**
  4649. * Set animation weight for all animatables
  4650. * @param weight defines the weight to use
  4651. * @return the animationGroup
  4652. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4653. */
  4654. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4655. /**
  4656. * Synchronize and normalize all animatables with a source animatable
  4657. * @param root defines the root animatable to synchronize with
  4658. * @return the animationGroup
  4659. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4660. */
  4661. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4662. /**
  4663. * Goes to a specific frame in this animation group
  4664. * @param frame the frame number to go to
  4665. * @return the animationGroup
  4666. */
  4667. goToFrame(frame: number): AnimationGroup;
  4668. /**
  4669. * Dispose all associated resources
  4670. */
  4671. dispose(): void;
  4672. private _checkAnimationGroupEnded;
  4673. /**
  4674. * Returns a new AnimationGroup object parsed from the source provided.
  4675. * @param parsedAnimationGroup defines the source
  4676. * @param scene defines the scene that will receive the animationGroup
  4677. * @returns a new AnimationGroup
  4678. */
  4679. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4680. /**
  4681. * Returns the string "AnimationGroup"
  4682. * @returns "AnimationGroup"
  4683. */
  4684. getClassName(): string;
  4685. /**
  4686. * Creates a detailled string about the object
  4687. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4688. * @returns a string representing the object
  4689. */
  4690. toString(fullDetails?: boolean): string;
  4691. }
  4692. }
  4693. declare module BABYLON {
  4694. /**
  4695. * Class used to override all child animations of a given target
  4696. */
  4697. class AnimationPropertiesOverride {
  4698. /**
  4699. * Gets or sets a value indicating if animation blending must be used
  4700. */
  4701. enableBlending: boolean;
  4702. /**
  4703. * Gets or sets the blending speed to use when enableBlending is true
  4704. */
  4705. blendingSpeed: number;
  4706. /**
  4707. * Gets or sets the default loop mode to use
  4708. */
  4709. loopMode: number;
  4710. }
  4711. }
  4712. declare module BABYLON {
  4713. /**
  4714. * This represents the main contract an easing function should follow.
  4715. * Easing functions are used throughout the animation system.
  4716. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4717. */
  4718. interface IEasingFunction {
  4719. /**
  4720. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4721. * of the easing function.
  4722. * The link below provides some of the most common examples of easing functions.
  4723. * @see https://easings.net/
  4724. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4725. * @returns the corresponding value on the curve defined by the easing function
  4726. */
  4727. ease(gradient: number): number;
  4728. }
  4729. /**
  4730. * Base class used for every default easing function.
  4731. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4732. */
  4733. class EasingFunction implements IEasingFunction {
  4734. /**
  4735. * Interpolation follows the mathematical formula associated with the easing function.
  4736. */
  4737. static readonly EASINGMODE_EASEIN: number;
  4738. /**
  4739. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4740. */
  4741. static readonly EASINGMODE_EASEOUT: number;
  4742. /**
  4743. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4744. */
  4745. static readonly EASINGMODE_EASEINOUT: number;
  4746. private _easingMode;
  4747. /**
  4748. * Sets the easing mode of the current function.
  4749. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4750. */
  4751. setEasingMode(easingMode: number): void;
  4752. /**
  4753. * Gets the current easing mode.
  4754. * @returns the easing mode
  4755. */
  4756. getEasingMode(): number;
  4757. /**
  4758. * @hidden
  4759. */
  4760. easeInCore(gradient: number): number;
  4761. /**
  4762. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4763. * of the easing function.
  4764. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4765. * @returns the corresponding value on the curve defined by the easing function
  4766. */
  4767. ease(gradient: number): number;
  4768. }
  4769. /**
  4770. * Easing function with a circle shape (see link below).
  4771. * @see https://easings.net/#easeInCirc
  4772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4773. */
  4774. class CircleEase extends EasingFunction implements IEasingFunction {
  4775. /** @hidden */
  4776. easeInCore(gradient: number): number;
  4777. }
  4778. /**
  4779. * Easing function with a ease back shape (see link below).
  4780. * @see https://easings.net/#easeInBack
  4781. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4782. */
  4783. class BackEase extends EasingFunction implements IEasingFunction {
  4784. /** Defines the amplitude of the function */
  4785. amplitude: number;
  4786. /**
  4787. * Instantiates a back ease easing
  4788. * @see https://easings.net/#easeInBack
  4789. * @param amplitude Defines the amplitude of the function
  4790. */
  4791. constructor(
  4792. /** Defines the amplitude of the function */
  4793. amplitude?: number);
  4794. /** @hidden */
  4795. easeInCore(gradient: number): number;
  4796. }
  4797. /**
  4798. * Easing function with a bouncing shape (see link below).
  4799. * @see https://easings.net/#easeInBounce
  4800. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4801. */
  4802. class BounceEase extends EasingFunction implements IEasingFunction {
  4803. /** Defines the number of bounces */
  4804. bounces: number;
  4805. /** Defines the amplitude of the bounce */
  4806. bounciness: number;
  4807. /**
  4808. * Instantiates a bounce easing
  4809. * @see https://easings.net/#easeInBounce
  4810. * @param bounces Defines the number of bounces
  4811. * @param bounciness Defines the amplitude of the bounce
  4812. */
  4813. constructor(
  4814. /** Defines the number of bounces */
  4815. bounces?: number,
  4816. /** Defines the amplitude of the bounce */
  4817. bounciness?: number);
  4818. /** @hidden */
  4819. easeInCore(gradient: number): number;
  4820. }
  4821. /**
  4822. * Easing function with a power of 3 shape (see link below).
  4823. * @see https://easings.net/#easeInCubic
  4824. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4825. */
  4826. class CubicEase extends EasingFunction implements IEasingFunction {
  4827. /** @hidden */
  4828. easeInCore(gradient: number): number;
  4829. }
  4830. /**
  4831. * Easing function with an elastic shape (see link below).
  4832. * @see https://easings.net/#easeInElastic
  4833. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4834. */
  4835. class ElasticEase extends EasingFunction implements IEasingFunction {
  4836. /** Defines the number of oscillations*/
  4837. oscillations: number;
  4838. /** Defines the amplitude of the oscillations*/
  4839. springiness: number;
  4840. /**
  4841. * Instantiates an elastic easing function
  4842. * @see https://easings.net/#easeInElastic
  4843. * @param oscillations Defines the number of oscillations
  4844. * @param springiness Defines the amplitude of the oscillations
  4845. */
  4846. constructor(
  4847. /** Defines the number of oscillations*/
  4848. oscillations?: number,
  4849. /** Defines the amplitude of the oscillations*/
  4850. springiness?: number);
  4851. /** @hidden */
  4852. easeInCore(gradient: number): number;
  4853. }
  4854. /**
  4855. * Easing function with an exponential shape (see link below).
  4856. * @see https://easings.net/#easeInExpo
  4857. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4858. */
  4859. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4860. /** Defines the exponent of the function */
  4861. exponent: number;
  4862. /**
  4863. * Instantiates an exponential easing function
  4864. * @see https://easings.net/#easeInExpo
  4865. * @param exponent Defines the exponent of the function
  4866. */
  4867. constructor(
  4868. /** Defines the exponent of the function */
  4869. exponent?: number);
  4870. /** @hidden */
  4871. easeInCore(gradient: number): number;
  4872. }
  4873. /**
  4874. * Easing function with a power shape (see link below).
  4875. * @see https://easings.net/#easeInQuad
  4876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4877. */
  4878. class PowerEase extends EasingFunction implements IEasingFunction {
  4879. /** Defines the power of the function */
  4880. power: number;
  4881. /**
  4882. * Instantiates an power base easing function
  4883. * @see https://easings.net/#easeInQuad
  4884. * @param power Defines the power of the function
  4885. */
  4886. constructor(
  4887. /** Defines the power of the function */
  4888. power?: number);
  4889. /** @hidden */
  4890. easeInCore(gradient: number): number;
  4891. }
  4892. /**
  4893. * Easing function with a power of 2 shape (see link below).
  4894. * @see https://easings.net/#easeInQuad
  4895. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4896. */
  4897. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4898. /** @hidden */
  4899. easeInCore(gradient: number): number;
  4900. }
  4901. /**
  4902. * Easing function with a power of 4 shape (see link below).
  4903. * @see https://easings.net/#easeInQuart
  4904. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4905. */
  4906. class QuarticEase extends EasingFunction implements IEasingFunction {
  4907. /** @hidden */
  4908. easeInCore(gradient: number): number;
  4909. }
  4910. /**
  4911. * Easing function with a power of 5 shape (see link below).
  4912. * @see https://easings.net/#easeInQuint
  4913. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4914. */
  4915. class QuinticEase extends EasingFunction implements IEasingFunction {
  4916. /** @hidden */
  4917. easeInCore(gradient: number): number;
  4918. }
  4919. /**
  4920. * Easing function with a sin shape (see link below).
  4921. * @see https://easings.net/#easeInSine
  4922. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4923. */
  4924. class SineEase extends EasingFunction implements IEasingFunction {
  4925. /** @hidden */
  4926. easeInCore(gradient: number): number;
  4927. }
  4928. /**
  4929. * Easing function with a bezier shape (see link below).
  4930. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4931. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4932. */
  4933. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4934. /** Defines the x component of the start tangent in the bezier curve */
  4935. x1: number;
  4936. /** Defines the y component of the start tangent in the bezier curve */
  4937. y1: number;
  4938. /** Defines the x component of the end tangent in the bezier curve */
  4939. x2: number;
  4940. /** Defines the y component of the end tangent in the bezier curve */
  4941. y2: number;
  4942. /**
  4943. * Instantiates a bezier function
  4944. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4945. * @param x1 Defines the x component of the start tangent in the bezier curve
  4946. * @param y1 Defines the y component of the start tangent in the bezier curve
  4947. * @param x2 Defines the x component of the end tangent in the bezier curve
  4948. * @param y2 Defines the y component of the end tangent in the bezier curve
  4949. */
  4950. constructor(
  4951. /** Defines the x component of the start tangent in the bezier curve */
  4952. x1?: number,
  4953. /** Defines the y component of the start tangent in the bezier curve */
  4954. y1?: number,
  4955. /** Defines the x component of the end tangent in the bezier curve */
  4956. x2?: number,
  4957. /** Defines the y component of the end tangent in the bezier curve */
  4958. y2?: number);
  4959. /** @hidden */
  4960. easeInCore(gradient: number): number;
  4961. }
  4962. }
  4963. declare module BABYLON {
  4964. /**
  4965. * Defines a runtime animation
  4966. */
  4967. class RuntimeAnimation {
  4968. private _events;
  4969. /**
  4970. * The current frame of the runtime animation
  4971. */
  4972. private _currentFrame;
  4973. /**
  4974. * The animation used by the runtime animation
  4975. */
  4976. private _animation;
  4977. /**
  4978. * The target of the runtime animation
  4979. */
  4980. private _target;
  4981. /**
  4982. * The initiating animatable
  4983. */
  4984. private _host;
  4985. /**
  4986. * The original value of the runtime animation
  4987. */
  4988. private _originalValue;
  4989. /**
  4990. * The original blend value of the runtime animation
  4991. */
  4992. private _originalBlendValue;
  4993. /**
  4994. * The offsets cache of the runtime animation
  4995. */
  4996. private _offsetsCache;
  4997. /**
  4998. * The high limits cache of the runtime animation
  4999. */
  5000. private _highLimitsCache;
  5001. /**
  5002. * Specifies if the runtime animation has been stopped
  5003. */
  5004. private _stopped;
  5005. /**
  5006. * The blending factor of the runtime animation
  5007. */
  5008. private _blendingFactor;
  5009. /**
  5010. * The BabylonJS scene
  5011. */
  5012. private _scene;
  5013. /**
  5014. * The current value of the runtime animation
  5015. */
  5016. private _currentValue;
  5017. /** @hidden */
  5018. _workValue: any;
  5019. /**
  5020. * The active target of the runtime animation
  5021. */
  5022. private _activeTarget;
  5023. /**
  5024. * The target path of the runtime animation
  5025. */
  5026. private _targetPath;
  5027. /**
  5028. * The weight of the runtime animation
  5029. */
  5030. private _weight;
  5031. /**
  5032. * The ratio offset of the runtime animation
  5033. */
  5034. private _ratioOffset;
  5035. /**
  5036. * The previous delay of the runtime animation
  5037. */
  5038. private _previousDelay;
  5039. /**
  5040. * The previous ratio of the runtime animation
  5041. */
  5042. private _previousRatio;
  5043. /**
  5044. * Gets the current frame of the runtime animation
  5045. */
  5046. readonly currentFrame: number;
  5047. /**
  5048. * Gets the weight of the runtime animation
  5049. */
  5050. readonly weight: number;
  5051. /**
  5052. * Gets the current value of the runtime animation
  5053. */
  5054. readonly currentValue: any;
  5055. /**
  5056. * Gets the target path of the runtime animation
  5057. */
  5058. readonly targetPath: string;
  5059. /**
  5060. * Gets the actual target of the runtime animation
  5061. */
  5062. readonly target: any;
  5063. /**
  5064. * Create a new RuntimeAnimation object
  5065. * @param target defines the target of the animation
  5066. * @param animation defines the source animation object
  5067. * @param scene defines the hosting scene
  5068. * @param host defines the initiating Animatable
  5069. */
  5070. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5071. /**
  5072. * Gets the animation from the runtime animation
  5073. */
  5074. readonly animation: Animation;
  5075. /**
  5076. * Resets the runtime animation to the beginning
  5077. * @param restoreOriginal defines whether to restore the target property to the original value
  5078. */
  5079. reset(restoreOriginal?: boolean): void;
  5080. /**
  5081. * Specifies if the runtime animation is stopped
  5082. * @returns Boolean specifying if the runtime animation is stopped
  5083. */
  5084. isStopped(): boolean;
  5085. /**
  5086. * Disposes of the runtime animation
  5087. */
  5088. dispose(): void;
  5089. /**
  5090. * Interpolates the animation from the current frame
  5091. * @param currentFrame The frame to interpolate the animation to
  5092. * @param repeatCount The number of times that the animation should loop
  5093. * @param loopMode The type of looping mode to use
  5094. * @param offsetValue Animation offset value
  5095. * @param highLimitValue The high limit value
  5096. * @returns The interpolated value
  5097. */
  5098. private _interpolate;
  5099. /**
  5100. * Apply the interpolated value to the target
  5101. * @param currentValue defines the value computed by the animation
  5102. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5103. */
  5104. setValue(currentValue: any, weight?: number): void;
  5105. private _setValue;
  5106. /**
  5107. * Gets the loop pmode of the runtime animation
  5108. * @returns Loop Mode
  5109. */
  5110. private _getCorrectLoopMode;
  5111. /**
  5112. * Move the current animation to a given frame
  5113. * @param frame defines the frame to move to
  5114. */
  5115. goToFrame(frame: number): void;
  5116. /**
  5117. * @hidden Internal use only
  5118. */
  5119. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5120. /**
  5121. * Execute the current animation
  5122. * @param delay defines the delay to add to the current frame
  5123. * @param from defines the lower bound of the animation range
  5124. * @param to defines the upper bound of the animation range
  5125. * @param loop defines if the current animation must loop
  5126. * @param speedRatio defines the current speed ratio
  5127. * @param weight defines the weight of the animation (default is -1 so no weight)
  5128. * @returns a boolean indicating if the animation is running
  5129. */
  5130. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5131. }
  5132. }
  5133. declare module BABYLON {
  5134. /**
  5135. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5137. */
  5138. class Analyser {
  5139. /**
  5140. * Gets or sets the smoothing
  5141. * @ignorenaming
  5142. */
  5143. SMOOTHING: number;
  5144. /**
  5145. * Gets or sets the FFT table size
  5146. * @ignorenaming
  5147. */
  5148. FFT_SIZE: number;
  5149. /**
  5150. * Gets or sets the bar graph amplitude
  5151. * @ignorenaming
  5152. */
  5153. BARGRAPHAMPLITUDE: number;
  5154. /**
  5155. * Gets or sets the position of the debug canvas
  5156. * @ignorenaming
  5157. */
  5158. DEBUGCANVASPOS: {
  5159. x: number;
  5160. y: number;
  5161. };
  5162. /**
  5163. * Gets or sets the debug canvas size
  5164. * @ignorenaming
  5165. */
  5166. DEBUGCANVASSIZE: {
  5167. width: number;
  5168. height: number;
  5169. };
  5170. private _byteFreqs;
  5171. private _byteTime;
  5172. private _floatFreqs;
  5173. private _webAudioAnalyser;
  5174. private _debugCanvas;
  5175. private _debugCanvasContext;
  5176. private _scene;
  5177. private _registerFunc;
  5178. private _audioEngine;
  5179. /**
  5180. * Creates a new analyser
  5181. * @param scene defines hosting scene
  5182. */
  5183. constructor(scene: Scene);
  5184. /**
  5185. * Get the number of data values you will have to play with for the visualization
  5186. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5187. * @returns a number
  5188. */
  5189. getFrequencyBinCount(): number;
  5190. /**
  5191. * Gets the current frequency data as a byte array
  5192. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5193. * @returns a Uint8Array
  5194. */
  5195. getByteFrequencyData(): Uint8Array;
  5196. /**
  5197. * Gets the current waveform as a byte array
  5198. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5199. * @returns a Uint8Array
  5200. */
  5201. getByteTimeDomainData(): Uint8Array;
  5202. /**
  5203. * Gets the current frequency data as a float array
  5204. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5205. * @returns a Float32Array
  5206. */
  5207. getFloatFrequencyData(): Float32Array;
  5208. /**
  5209. * Renders the debug canvas
  5210. */
  5211. drawDebugCanvas(): void;
  5212. /**
  5213. * Stops rendering the debug canvas and removes it
  5214. */
  5215. stopDebugCanvas(): void;
  5216. /**
  5217. * Connects two audio nodes
  5218. * @param inputAudioNode defines first node to connect
  5219. * @param outputAudioNode defines second node to connect
  5220. */
  5221. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5222. /**
  5223. * Releases all associated resources
  5224. */
  5225. dispose(): void;
  5226. }
  5227. }
  5228. declare module BABYLON {
  5229. /**
  5230. * This represents an audio engine and it is responsible
  5231. * to play, synchronize and analyse sounds throughout the application.
  5232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5233. */
  5234. interface IAudioEngine extends IDisposable {
  5235. /**
  5236. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5237. */
  5238. readonly canUseWebAudio: boolean;
  5239. /**
  5240. * Gets the current AudioContext if available.
  5241. */
  5242. readonly audioContext: Nullable<AudioContext>;
  5243. /**
  5244. * The master gain node defines the global audio volume of your audio engine.
  5245. */
  5246. readonly masterGain: GainNode;
  5247. /**
  5248. * Gets whether or not mp3 are supported by your browser.
  5249. */
  5250. readonly isMP3supported: boolean;
  5251. /**
  5252. * Gets whether or not ogg are supported by your browser.
  5253. */
  5254. readonly isOGGsupported: boolean;
  5255. /**
  5256. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5257. * @ignoreNaming
  5258. */
  5259. WarnedWebAudioUnsupported: boolean;
  5260. /**
  5261. * Defines if the audio engine relies on a custom unlocked button.
  5262. * In this case, the embedded button will not be displayed.
  5263. */
  5264. useCustomUnlockedButton: boolean;
  5265. /**
  5266. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5267. */
  5268. readonly unlocked: boolean;
  5269. /**
  5270. * Event raised when audio has been unlocked on the browser.
  5271. */
  5272. onAudioUnlockedObservable: Observable<AudioEngine>;
  5273. /**
  5274. * Event raised when audio has been locked on the browser.
  5275. */
  5276. onAudioLockedObservable: Observable<AudioEngine>;
  5277. /**
  5278. * Flags the audio engine in Locked state.
  5279. * This happens due to new browser policies preventing audio to autoplay.
  5280. */
  5281. lock(): void;
  5282. /**
  5283. * Unlocks the audio engine once a user action has been done on the dom.
  5284. * This is helpful to resume play once browser policies have been satisfied.
  5285. */
  5286. unlock(): void;
  5287. }
  5288. /**
  5289. * This represents the default audio engine used in babylon.
  5290. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5291. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5292. */
  5293. class AudioEngine implements IAudioEngine {
  5294. private _audioContext;
  5295. private _audioContextInitialized;
  5296. private _muteButton;
  5297. private _hostElement;
  5298. /**
  5299. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5300. */
  5301. canUseWebAudio: boolean;
  5302. /**
  5303. * The master gain node defines the global audio volume of your audio engine.
  5304. */
  5305. masterGain: GainNode;
  5306. /**
  5307. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5308. * @ignoreNaming
  5309. */
  5310. WarnedWebAudioUnsupported: boolean;
  5311. /**
  5312. * Gets whether or not mp3 are supported by your browser.
  5313. */
  5314. isMP3supported: boolean;
  5315. /**
  5316. * Gets whether or not ogg are supported by your browser.
  5317. */
  5318. isOGGsupported: boolean;
  5319. /**
  5320. * Gets whether audio has been unlocked on the device.
  5321. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5322. * a user interaction has happened.
  5323. */
  5324. unlocked: boolean;
  5325. /**
  5326. * Defines if the audio engine relies on a custom unlocked button.
  5327. * In this case, the embedded button will not be displayed.
  5328. */
  5329. useCustomUnlockedButton: boolean;
  5330. /**
  5331. * Event raised when audio has been unlocked on the browser.
  5332. */
  5333. onAudioUnlockedObservable: Observable<AudioEngine>;
  5334. /**
  5335. * Event raised when audio has been locked on the browser.
  5336. */
  5337. onAudioLockedObservable: Observable<AudioEngine>;
  5338. /**
  5339. * Gets the current AudioContext if available.
  5340. */
  5341. readonly audioContext: Nullable<AudioContext>;
  5342. private _connectedAnalyser;
  5343. /**
  5344. * Instantiates a new audio engine.
  5345. *
  5346. * There should be only one per page as some browsers restrict the number
  5347. * of audio contexts you can create.
  5348. * @param hostElement defines the host element where to display the mute icon if necessary
  5349. */
  5350. constructor(hostElement?: Nullable<HTMLElement>);
  5351. /**
  5352. * Flags the audio engine in Locked state.
  5353. * This happens due to new browser policies preventing audio to autoplay.
  5354. */
  5355. lock(): void;
  5356. /**
  5357. * Unlocks the audio engine once a user action has been done on the dom.
  5358. * This is helpful to resume play once browser policies have been satisfied.
  5359. */
  5360. unlock(): void;
  5361. private _resumeAudioContext;
  5362. private _initializeAudioContext;
  5363. private _tryToRun;
  5364. private _triggerRunningState;
  5365. private _triggerSuspendedState;
  5366. private _displayMuteButton;
  5367. private _moveButtonToTopLeft;
  5368. private _onResize;
  5369. private _hideMuteButton;
  5370. /**
  5371. * Destroy and release the resources associated with the audio ccontext.
  5372. */
  5373. dispose(): void;
  5374. /**
  5375. * Gets the global volume sets on the master gain.
  5376. * @returns the global volume if set or -1 otherwise
  5377. */
  5378. getGlobalVolume(): number;
  5379. /**
  5380. * Sets the global volume of your experience (sets on the master gain).
  5381. * @param newVolume Defines the new global volume of the application
  5382. */
  5383. setGlobalVolume(newVolume: number): void;
  5384. /**
  5385. * Connect the audio engine to an audio analyser allowing some amazing
  5386. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5388. * @param analyser The analyser to connect to the engine
  5389. */
  5390. connectToAnalyser(analyser: Analyser): void;
  5391. }
  5392. }
  5393. declare module BABYLON {
  5394. interface AbstractScene {
  5395. /**
  5396. * The list of sounds used in the scene.
  5397. */
  5398. sounds: Nullable<Array<Sound>>;
  5399. }
  5400. interface Scene {
  5401. /**
  5402. * @hidden
  5403. * Backing field
  5404. */
  5405. _mainSoundTrack: SoundTrack;
  5406. /**
  5407. * The main sound track played by the scene.
  5408. * It cotains your primary collection of sounds.
  5409. */
  5410. mainSoundTrack: SoundTrack;
  5411. /**
  5412. * The list of sound tracks added to the scene
  5413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5414. */
  5415. soundTracks: Nullable<Array<SoundTrack>>;
  5416. /**
  5417. * Gets a sound using a given name
  5418. * @param name defines the name to search for
  5419. * @return the found sound or null if not found at all.
  5420. */
  5421. getSoundByName(name: string): Nullable<Sound>;
  5422. /**
  5423. * Gets or sets if audio support is enabled
  5424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5425. */
  5426. audioEnabled: boolean;
  5427. /**
  5428. * Gets or sets if audio will be output to headphones
  5429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5430. */
  5431. headphone: boolean;
  5432. }
  5433. /**
  5434. * Defines the sound scene component responsible to manage any sounds
  5435. * in a given scene.
  5436. */
  5437. class AudioSceneComponent implements ISceneSerializableComponent {
  5438. /**
  5439. * The component name helpfull to identify the component in the list of scene components.
  5440. */
  5441. readonly name: string;
  5442. /**
  5443. * The scene the component belongs to.
  5444. */
  5445. scene: Scene;
  5446. private _audioEnabled;
  5447. /**
  5448. * Gets whether audio is enabled or not.
  5449. * Please use related enable/disable method to switch state.
  5450. */
  5451. readonly audioEnabled: boolean;
  5452. private _headphone;
  5453. /**
  5454. * Gets whether audio is outputing to headphone or not.
  5455. * Please use the according Switch methods to change output.
  5456. */
  5457. readonly headphone: boolean;
  5458. /**
  5459. * Creates a new instance of the component for the given scene
  5460. * @param scene Defines the scene to register the component in
  5461. */
  5462. constructor(scene: Scene);
  5463. /**
  5464. * Registers the component in a given scene
  5465. */
  5466. register(): void;
  5467. /**
  5468. * Rebuilds the elements related to this component in case of
  5469. * context lost for instance.
  5470. */
  5471. rebuild(): void;
  5472. /**
  5473. * Serializes the component data to the specified json object
  5474. * @param serializationObject The object to serialize to
  5475. */
  5476. serialize(serializationObject: any): void;
  5477. /**
  5478. * Adds all the element from the container to the scene
  5479. * @param container the container holding the elements
  5480. */
  5481. addFromContainer(container: AbstractScene): void;
  5482. /**
  5483. * Removes all the elements in the container from the scene
  5484. * @param container contains the elements to remove
  5485. */
  5486. removeFromContainer(container: AbstractScene): void;
  5487. /**
  5488. * Disposes the component and the associated ressources.
  5489. */
  5490. dispose(): void;
  5491. /**
  5492. * Disables audio in the associated scene.
  5493. */
  5494. disableAudio(): void;
  5495. /**
  5496. * Enables audio in the associated scene.
  5497. */
  5498. enableAudio(): void;
  5499. /**
  5500. * Switch audio to headphone output.
  5501. */
  5502. switchAudioModeForHeadphones(): void;
  5503. /**
  5504. * Switch audio to normal speakers.
  5505. */
  5506. switchAudioModeForNormalSpeakers(): void;
  5507. private _afterRender;
  5508. }
  5509. }
  5510. declare module BABYLON {
  5511. /**
  5512. * Defines a sound that can be played in the application.
  5513. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5515. */
  5516. class Sound {
  5517. /**
  5518. * The name of the sound in the scene.
  5519. */
  5520. name: string;
  5521. /**
  5522. * Does the sound autoplay once loaded.
  5523. */
  5524. autoplay: boolean;
  5525. /**
  5526. * Does the sound loop after it finishes playing once.
  5527. */
  5528. loop: boolean;
  5529. /**
  5530. * Does the sound use a custom attenuation curve to simulate the falloff
  5531. * happening when the source gets further away from the camera.
  5532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5533. */
  5534. useCustomAttenuation: boolean;
  5535. /**
  5536. * The sound track id this sound belongs to.
  5537. */
  5538. soundTrackId: number;
  5539. /**
  5540. * Is this sound currently played.
  5541. */
  5542. isPlaying: boolean;
  5543. /**
  5544. * Is this sound currently paused.
  5545. */
  5546. isPaused: boolean;
  5547. /**
  5548. * Does this sound enables spatial sound.
  5549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5550. */
  5551. spatialSound: boolean;
  5552. /**
  5553. * Define the reference distance the sound should be heard perfectly.
  5554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5555. */
  5556. refDistance: number;
  5557. /**
  5558. * Define the roll off factor of spatial sounds.
  5559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5560. */
  5561. rolloffFactor: number;
  5562. /**
  5563. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5565. */
  5566. maxDistance: number;
  5567. /**
  5568. * Define the distance attenuation model the sound will follow.
  5569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5570. */
  5571. distanceModel: string;
  5572. /**
  5573. * @hidden
  5574. * Back Compat
  5575. **/
  5576. onended: () => any;
  5577. /**
  5578. * Observable event when the current playing sound finishes.
  5579. */
  5580. onEndedObservable: Observable<Sound>;
  5581. private _panningModel;
  5582. private _playbackRate;
  5583. private _streaming;
  5584. private _startTime;
  5585. private _startOffset;
  5586. private _position;
  5587. /** @hidden */
  5588. _positionInEmitterSpace: boolean;
  5589. private _localDirection;
  5590. private _volume;
  5591. private _isReadyToPlay;
  5592. private _isDirectional;
  5593. private _readyToPlayCallback;
  5594. private _audioBuffer;
  5595. private _soundSource;
  5596. private _streamingSource;
  5597. private _soundPanner;
  5598. private _soundGain;
  5599. private _inputAudioNode;
  5600. private _outputAudioNode;
  5601. private _coneInnerAngle;
  5602. private _coneOuterAngle;
  5603. private _coneOuterGain;
  5604. private _scene;
  5605. private _connectedTransformNode;
  5606. private _customAttenuationFunction;
  5607. private _registerFunc;
  5608. private _isOutputConnected;
  5609. private _htmlAudioElement;
  5610. private _urlType;
  5611. /**
  5612. * Create a sound and attach it to a scene
  5613. * @param name Name of your sound
  5614. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5615. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5616. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5617. */
  5618. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5619. /**
  5620. * Release the sound and its associated resources
  5621. */
  5622. dispose(): void;
  5623. /**
  5624. * Gets if the sounds is ready to be played or not.
  5625. * @returns true if ready, otherwise false
  5626. */
  5627. isReady(): boolean;
  5628. private _soundLoaded;
  5629. /**
  5630. * Sets the data of the sound from an audiobuffer
  5631. * @param audioBuffer The audioBuffer containing the data
  5632. */
  5633. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5634. /**
  5635. * Updates the current sounds options such as maxdistance, loop...
  5636. * @param options A JSON object containing values named as the object properties
  5637. */
  5638. updateOptions(options: any): void;
  5639. private _createSpatialParameters;
  5640. private _updateSpatialParameters;
  5641. /**
  5642. * Switch the panning model to HRTF:
  5643. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5645. */
  5646. switchPanningModelToHRTF(): void;
  5647. /**
  5648. * Switch the panning model to Equal Power:
  5649. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5651. */
  5652. switchPanningModelToEqualPower(): void;
  5653. private _switchPanningModel;
  5654. /**
  5655. * Connect this sound to a sound track audio node like gain...
  5656. * @param soundTrackAudioNode the sound track audio node to connect to
  5657. */
  5658. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5659. /**
  5660. * Transform this sound into a directional source
  5661. * @param coneInnerAngle Size of the inner cone in degree
  5662. * @param coneOuterAngle Size of the outer cone in degree
  5663. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5664. */
  5665. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5666. /**
  5667. * Gets or sets the inner angle for the directional cone.
  5668. */
  5669. /**
  5670. * Gets or sets the inner angle for the directional cone.
  5671. */
  5672. directionalConeInnerAngle: number;
  5673. /**
  5674. * Gets or sets the outer angle for the directional cone.
  5675. */
  5676. /**
  5677. * Gets or sets the outer angle for the directional cone.
  5678. */
  5679. directionalConeOuterAngle: number;
  5680. /**
  5681. * Sets the position of the emitter if spatial sound is enabled
  5682. * @param newPosition Defines the new posisiton
  5683. */
  5684. setPosition(newPosition: Vector3): void;
  5685. /**
  5686. * Sets the local direction of the emitter if spatial sound is enabled
  5687. * @param newLocalDirection Defines the new local direction
  5688. */
  5689. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5690. private _updateDirection;
  5691. /** @hidden */
  5692. updateDistanceFromListener(): void;
  5693. /**
  5694. * Sets a new custom attenuation function for the sound.
  5695. * @param callback Defines the function used for the attenuation
  5696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5697. */
  5698. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5699. /**
  5700. * Play the sound
  5701. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5702. * @param offset (optional) Start the sound setting it at a specific time
  5703. */
  5704. play(time?: number, offset?: number): void;
  5705. private _onended;
  5706. /**
  5707. * Stop the sound
  5708. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5709. */
  5710. stop(time?: number): void;
  5711. /**
  5712. * Put the sound in pause
  5713. */
  5714. pause(): void;
  5715. /**
  5716. * Sets a dedicated volume for this sounds
  5717. * @param newVolume Define the new volume of the sound
  5718. * @param time Define in how long the sound should be at this value
  5719. */
  5720. setVolume(newVolume: number, time?: number): void;
  5721. /**
  5722. * Set the sound play back rate
  5723. * @param newPlaybackRate Define the playback rate the sound should be played at
  5724. */
  5725. setPlaybackRate(newPlaybackRate: number): void;
  5726. /**
  5727. * Gets the volume of the sound.
  5728. * @returns the volume of the sound
  5729. */
  5730. getVolume(): number;
  5731. /**
  5732. * Attach the sound to a dedicated mesh
  5733. * @param transformNode The transform node to connect the sound with
  5734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5735. */
  5736. attachToMesh(transformNode: TransformNode): void;
  5737. /**
  5738. * Detach the sound from the previously attached mesh
  5739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5740. */
  5741. detachFromMesh(): void;
  5742. private _onRegisterAfterWorldMatrixUpdate;
  5743. /**
  5744. * Clone the current sound in the scene.
  5745. * @returns the new sound clone
  5746. */
  5747. clone(): Nullable<Sound>;
  5748. /**
  5749. * Gets the current underlying audio buffer containing the data
  5750. * @returns the audio buffer
  5751. */
  5752. getAudioBuffer(): Nullable<AudioBuffer>;
  5753. /**
  5754. * Serializes the Sound in a JSON representation
  5755. * @returns the JSON representation of the sound
  5756. */
  5757. serialize(): any;
  5758. /**
  5759. * Parse a JSON representation of a sound to innstantiate in a given scene
  5760. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5761. * @param scene Define the scene the new parsed sound should be created in
  5762. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5763. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5764. * @returns the newly parsed sound
  5765. */
  5766. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5767. }
  5768. }
  5769. declare module BABYLON {
  5770. /**
  5771. * Options allowed during the creation of a sound track.
  5772. */
  5773. interface ISoundTrackOptions {
  5774. /**
  5775. * The volume the sound track should take during creation
  5776. */
  5777. volume?: number;
  5778. /**
  5779. * Define if the sound track is the main sound track of the scene
  5780. */
  5781. mainTrack?: boolean;
  5782. }
  5783. /**
  5784. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5785. * It will be also used in a future release to apply effects on a specific track.
  5786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5787. */
  5788. class SoundTrack {
  5789. /**
  5790. * The unique identifier of the sound track in the scene.
  5791. */
  5792. id: number;
  5793. /**
  5794. * The list of sounds included in the sound track.
  5795. */
  5796. soundCollection: Array<Sound>;
  5797. private _outputAudioNode;
  5798. private _scene;
  5799. private _isMainTrack;
  5800. private _connectedAnalyser;
  5801. private _options;
  5802. private _isInitialized;
  5803. /**
  5804. * Creates a new sound track.
  5805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5806. * @param scene Define the scene the sound track belongs to
  5807. * @param options
  5808. */
  5809. constructor(scene: Scene, options?: ISoundTrackOptions);
  5810. private _initializeSoundTrackAudioGraph;
  5811. /**
  5812. * Release the sound track and its associated resources
  5813. */
  5814. dispose(): void;
  5815. /**
  5816. * Adds a sound to this sound track
  5817. * @param sound define the cound to add
  5818. * @ignoreNaming
  5819. */
  5820. AddSound(sound: Sound): void;
  5821. /**
  5822. * Removes a sound to this sound track
  5823. * @param sound define the cound to remove
  5824. * @ignoreNaming
  5825. */
  5826. RemoveSound(sound: Sound): void;
  5827. /**
  5828. * Set a global volume for the full sound track.
  5829. * @param newVolume Define the new volume of the sound track
  5830. */
  5831. setVolume(newVolume: number): void;
  5832. /**
  5833. * Switch the panning model to HRTF:
  5834. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5836. */
  5837. switchPanningModelToHRTF(): void;
  5838. /**
  5839. * Switch the panning model to Equal Power:
  5840. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5842. */
  5843. switchPanningModelToEqualPower(): void;
  5844. /**
  5845. * Connect the sound track to an audio analyser allowing some amazing
  5846. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5848. * @param analyser The analyser to connect to the engine
  5849. */
  5850. connectToAnalyser(analyser: Analyser): void;
  5851. }
  5852. }
  5853. declare module BABYLON {
  5854. /**
  5855. * Wraps one or more Sound objects and selects one with random weight for playback.
  5856. */
  5857. class WeightedSound {
  5858. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5859. loop: boolean;
  5860. private _coneInnerAngle;
  5861. private _coneOuterAngle;
  5862. private _volume;
  5863. /** A Sound is currently playing. */
  5864. isPlaying: boolean;
  5865. /** A Sound is currently paused. */
  5866. isPaused: boolean;
  5867. private _sounds;
  5868. private _weights;
  5869. private _currentIndex?;
  5870. /**
  5871. * Creates a new WeightedSound from the list of sounds given.
  5872. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5873. * @param sounds Array of Sounds that will be selected from.
  5874. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5875. */
  5876. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5877. /**
  5878. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5879. */
  5880. /**
  5881. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5882. */
  5883. directionalConeInnerAngle: number;
  5884. /**
  5885. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5886. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5887. */
  5888. /**
  5889. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5890. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5891. */
  5892. directionalConeOuterAngle: number;
  5893. /**
  5894. * Playback volume.
  5895. */
  5896. /**
  5897. * Playback volume.
  5898. */
  5899. volume: number;
  5900. private _onended;
  5901. /**
  5902. * Suspend playback
  5903. */
  5904. pause(): void;
  5905. /**
  5906. * Stop playback
  5907. */
  5908. stop(): void;
  5909. /**
  5910. * Start playback.
  5911. * @param startOffset Position the clip head at a specific time in seconds.
  5912. */
  5913. play(startOffset?: number): void;
  5914. }
  5915. }
  5916. declare module BABYLON {
  5917. /**
  5918. * Interface used to define a behavior
  5919. */
  5920. interface Behavior<T> {
  5921. /** gets or sets behavior's name */
  5922. name: string;
  5923. /**
  5924. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5925. */
  5926. init(): void;
  5927. /**
  5928. * Called when the behavior is attached to a target
  5929. * @param target defines the target where the behavior is attached to
  5930. */
  5931. attach(target: T): void;
  5932. /**
  5933. * Called when the behavior is detached from its target
  5934. */
  5935. detach(): void;
  5936. }
  5937. /**
  5938. * Interface implemented by classes supporting behaviors
  5939. */
  5940. interface IBehaviorAware<T> {
  5941. /**
  5942. * Attach a behavior
  5943. * @param behavior defines the behavior to attach
  5944. * @returns the current host
  5945. */
  5946. addBehavior(behavior: Behavior<T>): T;
  5947. /**
  5948. * Remove a behavior from the current object
  5949. * @param behavior defines the behavior to detach
  5950. * @returns the current host
  5951. */
  5952. removeBehavior(behavior: Behavior<T>): T;
  5953. /**
  5954. * Gets a behavior using its name to search
  5955. * @param name defines the name to search
  5956. * @returns the behavior or null if not found
  5957. */
  5958. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5959. }
  5960. }
  5961. declare module BABYLON {
  5962. /**
  5963. * Class used to store bone information
  5964. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5965. */
  5966. class Bone extends Node {
  5967. /**
  5968. * defines the bone name
  5969. */
  5970. name: string;
  5971. private static _tmpVecs;
  5972. private static _tmpQuat;
  5973. private static _tmpMats;
  5974. /**
  5975. * Gets the list of child bones
  5976. */
  5977. children: Bone[];
  5978. /** Gets the animations associated with this bone */
  5979. animations: Animation[];
  5980. /**
  5981. * Gets or sets bone length
  5982. */
  5983. length: number;
  5984. /**
  5985. * @hidden Internal only
  5986. * Set this value to map this bone to a different index in the transform matrices
  5987. * Set this value to -1 to exclude the bone from the transform matrices
  5988. */
  5989. _index: Nullable<number>;
  5990. private _skeleton;
  5991. private _localMatrix;
  5992. private _restPose;
  5993. private _baseMatrix;
  5994. private _absoluteTransform;
  5995. private _invertedAbsoluteTransform;
  5996. private _parent;
  5997. private _scalingDeterminant;
  5998. private _worldTransform;
  5999. private _localScaling;
  6000. private _localRotation;
  6001. private _localPosition;
  6002. private _needToDecompose;
  6003. private _needToCompose;
  6004. /** @hidden */
  6005. /** @hidden */
  6006. _matrix: Matrix;
  6007. /**
  6008. * Create a new bone
  6009. * @param name defines the bone name
  6010. * @param skeleton defines the parent skeleton
  6011. * @param parentBone defines the parent (can be null if the bone is the root)
  6012. * @param localMatrix defines the local matrix
  6013. * @param restPose defines the rest pose matrix
  6014. * @param baseMatrix defines the base matrix
  6015. * @param index defines index of the bone in the hiearchy
  6016. */
  6017. constructor(
  6018. /**
  6019. * defines the bone name
  6020. */
  6021. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6022. /**
  6023. * Gets the parent skeleton
  6024. * @returns a skeleton
  6025. */
  6026. getSkeleton(): Skeleton;
  6027. /**
  6028. * Gets parent bone
  6029. * @returns a bone or null if the bone is the root of the bone hierarchy
  6030. */
  6031. getParent(): Nullable<Bone>;
  6032. /**
  6033. * Sets the parent bone
  6034. * @param parent defines the parent (can be null if the bone is the root)
  6035. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6036. */
  6037. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6038. /**
  6039. * Gets the local matrix
  6040. * @returns a matrix
  6041. */
  6042. getLocalMatrix(): Matrix;
  6043. /**
  6044. * Gets the base matrix (initial matrix which remains unchanged)
  6045. * @returns a matrix
  6046. */
  6047. getBaseMatrix(): Matrix;
  6048. /**
  6049. * Gets the rest pose matrix
  6050. * @returns a matrix
  6051. */
  6052. getRestPose(): Matrix;
  6053. /**
  6054. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6055. */
  6056. getWorldMatrix(): Matrix;
  6057. /**
  6058. * Sets the local matrix to rest pose matrix
  6059. */
  6060. returnToRest(): void;
  6061. /**
  6062. * Gets the inverse of the absolute transform matrix.
  6063. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6064. * @returns a matrix
  6065. */
  6066. getInvertedAbsoluteTransform(): Matrix;
  6067. /**
  6068. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6069. * @returns a matrix
  6070. */
  6071. getAbsoluteTransform(): Matrix;
  6072. /** Gets or sets current position (in local space) */
  6073. position: Vector3;
  6074. /** Gets or sets current rotation (in local space) */
  6075. rotation: Vector3;
  6076. /** Gets or sets current rotation quaternion (in local space) */
  6077. rotationQuaternion: Quaternion;
  6078. /** Gets or sets current scaling (in local space) */
  6079. scaling: Vector3;
  6080. /**
  6081. * Gets the animation properties override
  6082. */
  6083. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6084. private _decompose;
  6085. private _compose;
  6086. /**
  6087. * Update the base and local matrices
  6088. * @param matrix defines the new base or local matrix
  6089. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6090. * @param updateLocalMatrix defines if the local matrix should be updated
  6091. */
  6092. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6093. /** @hidden */
  6094. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6095. /**
  6096. * Flag the bone as dirty (Forcing it to update everything)
  6097. */
  6098. markAsDirty(): void;
  6099. private _markAsDirtyAndCompose;
  6100. private _markAsDirtyAndDecompose;
  6101. /**
  6102. * Copy an animation range from another bone
  6103. * @param source defines the source bone
  6104. * @param rangeName defines the range name to copy
  6105. * @param frameOffset defines the frame offset
  6106. * @param rescaleAsRequired defines if rescaling must be applied if required
  6107. * @param skelDimensionsRatio defines the scaling ratio
  6108. * @returns true if operation was successful
  6109. */
  6110. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6111. /**
  6112. * Translate the bone in local or world space
  6113. * @param vec The amount to translate the bone
  6114. * @param space The space that the translation is in
  6115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6116. */
  6117. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6118. /**
  6119. * Set the postion of the bone in local or world space
  6120. * @param position The position to set the bone
  6121. * @param space The space that the position is in
  6122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6123. */
  6124. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6125. /**
  6126. * Set the absolute position of the bone (world space)
  6127. * @param position The position to set the bone
  6128. * @param mesh The mesh that this bone is attached to
  6129. */
  6130. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6131. /**
  6132. * Scale the bone on the x, y and z axes (in local space)
  6133. * @param x The amount to scale the bone on the x axis
  6134. * @param y The amount to scale the bone on the y axis
  6135. * @param z The amount to scale the bone on the z axis
  6136. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6137. */
  6138. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6139. /**
  6140. * Set the bone scaling in local space
  6141. * @param scale defines the scaling vector
  6142. */
  6143. setScale(scale: Vector3): void;
  6144. /**
  6145. * Gets the current scaling in local space
  6146. * @returns the current scaling vector
  6147. */
  6148. getScale(): Vector3;
  6149. /**
  6150. * Gets the current scaling in local space and stores it in a target vector
  6151. * @param result defines the target vector
  6152. */
  6153. getScaleToRef(result: Vector3): void;
  6154. /**
  6155. * Set the yaw, pitch, and roll of the bone in local or world space
  6156. * @param yaw The rotation of the bone on the y axis
  6157. * @param pitch The rotation of the bone on the x axis
  6158. * @param roll The rotation of the bone on the z axis
  6159. * @param space The space that the axes of rotation are in
  6160. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6161. */
  6162. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6163. /**
  6164. * Add a rotation to the bone on an axis in local or world space
  6165. * @param axis The axis to rotate the bone on
  6166. * @param amount The amount to rotate the bone
  6167. * @param space The space that the axis is in
  6168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6169. */
  6170. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6171. /**
  6172. * Set the rotation of the bone to a particular axis angle in local or world space
  6173. * @param axis The axis to rotate the bone on
  6174. * @param angle The angle that the bone should be rotated to
  6175. * @param space The space that the axis is in
  6176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6177. */
  6178. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6179. /**
  6180. * Set the euler rotation of the bone in local of world space
  6181. * @param rotation The euler rotation that the bone should be set to
  6182. * @param space The space that the rotation is in
  6183. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6184. */
  6185. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6186. /**
  6187. * Set the quaternion rotation of the bone in local of world space
  6188. * @param quat The quaternion rotation that the bone should be set to
  6189. * @param space The space that the rotation is in
  6190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6191. */
  6192. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6193. /**
  6194. * Set the rotation matrix of the bone in local of world space
  6195. * @param rotMat The rotation matrix that the bone should be set to
  6196. * @param space The space that the rotation is in
  6197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6198. */
  6199. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6200. private _rotateWithMatrix;
  6201. private _getNegativeRotationToRef;
  6202. /**
  6203. * Get the position of the bone in local or world space
  6204. * @param space The space that the returned position is in
  6205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6206. * @returns The position of the bone
  6207. */
  6208. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6209. /**
  6210. * Copy the position of the bone to a vector3 in local or world space
  6211. * @param space The space that the returned position is in
  6212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6213. * @param result The vector3 to copy the position to
  6214. */
  6215. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6216. /**
  6217. * Get the absolute position of the bone (world space)
  6218. * @param mesh The mesh that this bone is attached to
  6219. * @returns The absolute position of the bone
  6220. */
  6221. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6222. /**
  6223. * Copy the absolute position of the bone (world space) to the result param
  6224. * @param mesh The mesh that this bone is attached to
  6225. * @param result The vector3 to copy the absolute position to
  6226. */
  6227. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6228. /**
  6229. * Compute the absolute transforms of this bone and its children
  6230. */
  6231. computeAbsoluteTransforms(): void;
  6232. /**
  6233. * Get the world direction from an axis that is in the local space of the bone
  6234. * @param localAxis The local direction that is used to compute the world direction
  6235. * @param mesh The mesh that this bone is attached to
  6236. * @returns The world direction
  6237. */
  6238. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6239. /**
  6240. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6241. * @param localAxis The local direction that is used to compute the world direction
  6242. * @param mesh The mesh that this bone is attached to
  6243. * @param result The vector3 that the world direction will be copied to
  6244. */
  6245. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6246. /**
  6247. * Get the euler rotation of the bone in local or world space
  6248. * @param space The space that the rotation should be in
  6249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6250. * @returns The euler rotation
  6251. */
  6252. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6253. /**
  6254. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6255. * @param space The space that the rotation should be in
  6256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6257. * @param result The vector3 that the rotation should be copied to
  6258. */
  6259. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6260. /**
  6261. * Get the quaternion rotation of the bone in either local or world space
  6262. * @param space The space that the rotation should be in
  6263. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6264. * @returns The quaternion rotation
  6265. */
  6266. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6267. /**
  6268. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6269. * @param space The space that the rotation should be in
  6270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6271. * @param result The quaternion that the rotation should be copied to
  6272. */
  6273. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6274. /**
  6275. * Get the rotation matrix of the bone in local or world space
  6276. * @param space The space that the rotation should be in
  6277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6278. * @returns The rotation matrix
  6279. */
  6280. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6281. /**
  6282. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6283. * @param space The space that the rotation should be in
  6284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6285. * @param result The quaternion that the rotation should be copied to
  6286. */
  6287. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6288. /**
  6289. * Get the world position of a point that is in the local space of the bone
  6290. * @param position The local position
  6291. * @param mesh The mesh that this bone is attached to
  6292. * @returns The world position
  6293. */
  6294. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6295. /**
  6296. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6297. * @param position The local position
  6298. * @param mesh The mesh that this bone is attached to
  6299. * @param result The vector3 that the world position should be copied to
  6300. */
  6301. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6302. /**
  6303. * Get the local position of a point that is in world space
  6304. * @param position The world position
  6305. * @param mesh The mesh that this bone is attached to
  6306. * @returns The local position
  6307. */
  6308. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6309. /**
  6310. * Get the local position of a point that is in world space and copy it to the result param
  6311. * @param position The world position
  6312. * @param mesh The mesh that this bone is attached to
  6313. * @param result The vector3 that the local position should be copied to
  6314. */
  6315. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6316. }
  6317. }
  6318. declare module BABYLON {
  6319. /**
  6320. * Class used to apply inverse kinematics to bones
  6321. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6322. */
  6323. class BoneIKController {
  6324. private static _tmpVecs;
  6325. private static _tmpQuat;
  6326. private static _tmpMats;
  6327. /**
  6328. * Gets or sets the target mesh
  6329. */
  6330. targetMesh: AbstractMesh;
  6331. /** Gets or sets the mesh used as pole */
  6332. poleTargetMesh: AbstractMesh;
  6333. /**
  6334. * Gets or sets the bone used as pole
  6335. */
  6336. poleTargetBone: Nullable<Bone>;
  6337. /**
  6338. * Gets or sets the target position
  6339. */
  6340. targetPosition: Vector3;
  6341. /**
  6342. * Gets or sets the pole target position
  6343. */
  6344. poleTargetPosition: Vector3;
  6345. /**
  6346. * Gets or sets the pole target local offset
  6347. */
  6348. poleTargetLocalOffset: Vector3;
  6349. /**
  6350. * Gets or sets the pole angle
  6351. */
  6352. poleAngle: number;
  6353. /**
  6354. * Gets or sets the mesh associated with the controller
  6355. */
  6356. mesh: AbstractMesh;
  6357. /**
  6358. * 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)
  6359. */
  6360. slerpAmount: number;
  6361. private _bone1Quat;
  6362. private _bone1Mat;
  6363. private _bone2Ang;
  6364. private _bone1;
  6365. private _bone2;
  6366. private _bone1Length;
  6367. private _bone2Length;
  6368. private _maxAngle;
  6369. private _maxReach;
  6370. private _rightHandedSystem;
  6371. private _bendAxis;
  6372. private _slerping;
  6373. private _adjustRoll;
  6374. /**
  6375. * Gets or sets maximum allowed angle
  6376. */
  6377. maxAngle: number;
  6378. /**
  6379. * Creates a new BoneIKController
  6380. * @param mesh defines the mesh to control
  6381. * @param bone defines the bone to control
  6382. * @param options defines options to set up the controller
  6383. */
  6384. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6385. targetMesh?: AbstractMesh;
  6386. poleTargetMesh?: AbstractMesh;
  6387. poleTargetBone?: Bone;
  6388. poleTargetLocalOffset?: Vector3;
  6389. poleAngle?: number;
  6390. bendAxis?: Vector3;
  6391. maxAngle?: number;
  6392. slerpAmount?: number;
  6393. });
  6394. private _setMaxAngle;
  6395. /**
  6396. * Force the controller to update the bones
  6397. */
  6398. update(): void;
  6399. }
  6400. }
  6401. declare module BABYLON {
  6402. /**
  6403. * Class used to make a bone look toward a point in space
  6404. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6405. */
  6406. class BoneLookController {
  6407. private static _tmpVecs;
  6408. private static _tmpQuat;
  6409. private static _tmpMats;
  6410. /**
  6411. * The target Vector3 that the bone will look at
  6412. */
  6413. target: Vector3;
  6414. /**
  6415. * The mesh that the bone is attached to
  6416. */
  6417. mesh: AbstractMesh;
  6418. /**
  6419. * The bone that will be looking to the target
  6420. */
  6421. bone: Bone;
  6422. /**
  6423. * The up axis of the coordinate system that is used when the bone is rotated
  6424. */
  6425. upAxis: Vector3;
  6426. /**
  6427. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6428. */
  6429. upAxisSpace: Space;
  6430. /**
  6431. * Used to make an adjustment to the yaw of the bone
  6432. */
  6433. adjustYaw: number;
  6434. /**
  6435. * Used to make an adjustment to the pitch of the bone
  6436. */
  6437. adjustPitch: number;
  6438. /**
  6439. * Used to make an adjustment to the roll of the bone
  6440. */
  6441. adjustRoll: number;
  6442. /**
  6443. * 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)
  6444. */
  6445. slerpAmount: number;
  6446. private _minYaw;
  6447. private _maxYaw;
  6448. private _minPitch;
  6449. private _maxPitch;
  6450. private _minYawSin;
  6451. private _minYawCos;
  6452. private _maxYawSin;
  6453. private _maxYawCos;
  6454. private _midYawConstraint;
  6455. private _minPitchTan;
  6456. private _maxPitchTan;
  6457. private _boneQuat;
  6458. private _slerping;
  6459. private _transformYawPitch;
  6460. private _transformYawPitchInv;
  6461. private _firstFrameSkipped;
  6462. private _yawRange;
  6463. private _fowardAxis;
  6464. /**
  6465. * Gets or sets the minimum yaw angle that the bone can look to
  6466. */
  6467. minYaw: number;
  6468. /**
  6469. * Gets or sets the maximum yaw angle that the bone can look to
  6470. */
  6471. maxYaw: number;
  6472. /**
  6473. * Gets or sets the minimum pitch angle that the bone can look to
  6474. */
  6475. minPitch: number;
  6476. /**
  6477. * Gets or sets the maximum pitch angle that the bone can look to
  6478. */
  6479. maxPitch: number;
  6480. /**
  6481. * Create a BoneLookController
  6482. * @param mesh the mesh that the bone belongs to
  6483. * @param bone the bone that will be looking to the target
  6484. * @param target the target Vector3 to look at
  6485. * @param settings optional settings:
  6486. * * maxYaw: the maximum angle the bone will yaw to
  6487. * * minYaw: the minimum angle the bone will yaw to
  6488. * * maxPitch: the maximum angle the bone will pitch to
  6489. * * minPitch: the minimum angle the bone will yaw to
  6490. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6491. * * upAxis: the up axis of the coordinate system
  6492. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6493. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6494. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6495. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6496. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6497. * * adjustRoll: used to make an adjustment to the roll of the bone
  6498. **/
  6499. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6500. maxYaw?: number;
  6501. minYaw?: number;
  6502. maxPitch?: number;
  6503. minPitch?: number;
  6504. slerpAmount?: number;
  6505. upAxis?: Vector3;
  6506. upAxisSpace?: Space;
  6507. yawAxis?: Vector3;
  6508. pitchAxis?: Vector3;
  6509. adjustYaw?: number;
  6510. adjustPitch?: number;
  6511. adjustRoll?: number;
  6512. });
  6513. /**
  6514. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6515. */
  6516. update(): void;
  6517. private _getAngleDiff;
  6518. private _getAngleBetween;
  6519. private _isAngleBetween;
  6520. }
  6521. }
  6522. declare module BABYLON {
  6523. /**
  6524. * Class used to handle skinning animations
  6525. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6526. */
  6527. class Skeleton implements IAnimatable {
  6528. /** defines the skeleton name */
  6529. name: string;
  6530. /** defines the skeleton Id */
  6531. id: string;
  6532. /**
  6533. * Gets the list of child bones
  6534. */
  6535. bones: Bone[];
  6536. /**
  6537. * Gets an estimate of the dimension of the skeleton at rest
  6538. */
  6539. dimensionsAtRest: Vector3;
  6540. /**
  6541. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6542. */
  6543. needInitialSkinMatrix: boolean;
  6544. /**
  6545. * Gets the list of animations attached to this skeleton
  6546. */
  6547. animations: Array<Animation>;
  6548. private _scene;
  6549. private _isDirty;
  6550. private _transformMatrices;
  6551. private _transformMatrixTexture;
  6552. private _meshesWithPoseMatrix;
  6553. private _animatables;
  6554. private _identity;
  6555. private _synchronizedWithMesh;
  6556. private _ranges;
  6557. private _lastAbsoluteTransformsUpdateId;
  6558. private _canUseTextureForBones;
  6559. /**
  6560. * Specifies if the skeleton should be serialized
  6561. */
  6562. doNotSerialize: boolean;
  6563. /**
  6564. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6565. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6566. */
  6567. useTextureToStoreBoneMatrices: boolean;
  6568. private _animationPropertiesOverride;
  6569. /**
  6570. * Gets or sets the animation properties override
  6571. */
  6572. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6573. /**
  6574. * An observable triggered before computing the skeleton's matrices
  6575. */
  6576. onBeforeComputeObservable: Observable<Skeleton>;
  6577. /**
  6578. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6579. */
  6580. readonly isUsingTextureForMatrices: boolean;
  6581. /**
  6582. * Creates a new skeleton
  6583. * @param name defines the skeleton name
  6584. * @param id defines the skeleton Id
  6585. * @param scene defines the hosting scene
  6586. */
  6587. constructor(
  6588. /** defines the skeleton name */
  6589. name: string,
  6590. /** defines the skeleton Id */
  6591. id: string, scene: Scene);
  6592. /**
  6593. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6594. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6595. * @returns a Float32Array containing matrices data
  6596. */
  6597. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6598. /**
  6599. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6600. * @returns a raw texture containing the data
  6601. */
  6602. getTransformMatrixTexture(): Nullable<RawTexture>;
  6603. /**
  6604. * Gets the current hosting scene
  6605. * @returns a scene object
  6606. */
  6607. getScene(): Scene;
  6608. /**
  6609. * Gets a string representing the current skeleton data
  6610. * @param fullDetails defines a boolean indicating if we want a verbose version
  6611. * @returns a string representing the current skeleton data
  6612. */
  6613. toString(fullDetails?: boolean): string;
  6614. /**
  6615. * Get bone's index searching by name
  6616. * @param name defines bone's name to search for
  6617. * @return the indice of the bone. Returns -1 if not found
  6618. */
  6619. getBoneIndexByName(name: string): number;
  6620. /**
  6621. * Creater a new animation range
  6622. * @param name defines the name of the range
  6623. * @param from defines the start key
  6624. * @param to defines the end key
  6625. */
  6626. createAnimationRange(name: string, from: number, to: number): void;
  6627. /**
  6628. * Delete a specific animation range
  6629. * @param name defines the name of the range
  6630. * @param deleteFrames defines if frames must be removed as well
  6631. */
  6632. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6633. /**
  6634. * Gets a specific animation range
  6635. * @param name defines the name of the range to look for
  6636. * @returns the requested animation range or null if not found
  6637. */
  6638. getAnimationRange(name: string): Nullable<AnimationRange>;
  6639. /**
  6640. * Gets the list of all animation ranges defined on this skeleton
  6641. * @returns an array
  6642. */
  6643. getAnimationRanges(): Nullable<AnimationRange>[];
  6644. /**
  6645. * Copy animation range from a source skeleton.
  6646. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6647. * @param source defines the source skeleton
  6648. * @param name defines the name of the range to copy
  6649. * @param rescaleAsRequired defines if rescaling must be applied if required
  6650. * @returns true if operation was successful
  6651. */
  6652. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6653. /**
  6654. * Forces the skeleton to go to rest pose
  6655. */
  6656. returnToRest(): void;
  6657. private _getHighestAnimationFrame;
  6658. /**
  6659. * Begin a specific animation range
  6660. * @param name defines the name of the range to start
  6661. * @param loop defines if looping must be turned on (false by default)
  6662. * @param speedRatio defines the speed ratio to apply (1 by default)
  6663. * @param onAnimationEnd defines a callback which will be called when animation will end
  6664. * @returns a new animatable
  6665. */
  6666. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6667. /** @hidden */
  6668. _markAsDirty(): void;
  6669. /** @hidden */
  6670. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6671. /** @hidden */
  6672. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6673. private _computeTransformMatrices;
  6674. /**
  6675. * Build all resources required to render a skeleton
  6676. */
  6677. prepare(): void;
  6678. /**
  6679. * Gets the list of animatables currently running for this skeleton
  6680. * @returns an array of animatables
  6681. */
  6682. getAnimatables(): IAnimatable[];
  6683. /**
  6684. * Clone the current skeleton
  6685. * @param name defines the name of the new skeleton
  6686. * @param id defines the id of the enw skeleton
  6687. * @returns the new skeleton
  6688. */
  6689. clone(name: string, id: string): Skeleton;
  6690. /**
  6691. * Enable animation blending for this skeleton
  6692. * @param blendingSpeed defines the blending speed to apply
  6693. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6694. */
  6695. enableBlending(blendingSpeed?: number): void;
  6696. /**
  6697. * Releases all resources associated with the current skeleton
  6698. */
  6699. dispose(): void;
  6700. /**
  6701. * Serialize the skeleton in a JSON object
  6702. * @returns a JSON object
  6703. */
  6704. serialize(): any;
  6705. /**
  6706. * Creates a new skeleton from serialized data
  6707. * @param parsedSkeleton defines the serialized data
  6708. * @param scene defines the hosting scene
  6709. * @returns a new skeleton
  6710. */
  6711. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6712. /**
  6713. * Compute all node absolute transforms
  6714. * @param forceUpdate defines if computation must be done even if cache is up to date
  6715. */
  6716. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6717. /**
  6718. * Gets the root pose matrix
  6719. * @returns a matrix
  6720. */
  6721. getPoseMatrix(): Nullable<Matrix>;
  6722. /**
  6723. * Sorts bones per internal index
  6724. */
  6725. sortBones(): void;
  6726. private _sortBones;
  6727. }
  6728. }
  6729. declare module BABYLON {
  6730. /**
  6731. * Class used to store bounding box information
  6732. */
  6733. class BoundingBox implements ICullable {
  6734. /**
  6735. * Gets the 8 vectors representing the bounding box in local space
  6736. */
  6737. readonly vectors: Vector3[];
  6738. /**
  6739. * Gets the center of the bounding box in local space
  6740. */
  6741. readonly center: Vector3;
  6742. /**
  6743. * Gets the center of the bounding box in world space
  6744. */
  6745. readonly centerWorld: Vector3;
  6746. /**
  6747. * Gets the extend size in local space
  6748. */
  6749. readonly extendSize: Vector3;
  6750. /**
  6751. * Gets the extend size in world space
  6752. */
  6753. readonly extendSizeWorld: Vector3;
  6754. /**
  6755. * Gets the OBB (object bounding box) directions
  6756. */
  6757. readonly directions: Vector3[];
  6758. /**
  6759. * Gets the 8 vectors representing the bounding box in world space
  6760. */
  6761. readonly vectorsWorld: Vector3[];
  6762. /**
  6763. * Gets the minimum vector in world space
  6764. */
  6765. readonly minimumWorld: Vector3;
  6766. /**
  6767. * Gets the maximum vector in world space
  6768. */
  6769. readonly maximumWorld: Vector3;
  6770. /**
  6771. * Gets the minimum vector in local space
  6772. */
  6773. readonly minimum: Vector3;
  6774. /**
  6775. * Gets the maximum vector in local space
  6776. */
  6777. readonly maximum: Vector3;
  6778. private _worldMatrix;
  6779. private static readonly TmpVector3;
  6780. /**
  6781. * @hidden
  6782. */
  6783. _tag: number;
  6784. /**
  6785. * Creates a new bounding box
  6786. * @param min defines the minimum vector (in local space)
  6787. * @param max defines the maximum vector (in local space)
  6788. * @param worldMatrix defines the new world matrix
  6789. */
  6790. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6791. /**
  6792. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6793. * @param min defines the new minimum vector (in local space)
  6794. * @param max defines the new maximum vector (in local space)
  6795. * @param worldMatrix defines the new world matrix
  6796. */
  6797. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6798. /**
  6799. * Scale the current bounding box by applying a scale factor
  6800. * @param factor defines the scale factor to apply
  6801. * @returns the current bounding box
  6802. */
  6803. scale(factor: number): BoundingBox;
  6804. /**
  6805. * Gets the world matrix of the bounding box
  6806. * @returns a matrix
  6807. */
  6808. getWorldMatrix(): DeepImmutable<Matrix>;
  6809. /** @hidden */
  6810. _update(world: DeepImmutable<Matrix>): void;
  6811. /**
  6812. * Tests if the bounding box is intersecting the frustum planes
  6813. * @param frustumPlanes defines the frustum planes to test
  6814. * @returns true if there is an intersection
  6815. */
  6816. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6817. /**
  6818. * Tests if the bounding box is entirely inside the frustum planes
  6819. * @param frustumPlanes defines the frustum planes to test
  6820. * @returns true if there is an inclusion
  6821. */
  6822. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6823. /**
  6824. * Tests if a point is inside the bounding box
  6825. * @param point defines the point to test
  6826. * @returns true if the point is inside the bounding box
  6827. */
  6828. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6829. /**
  6830. * Tests if the bounding box intersects with a bounding sphere
  6831. * @param sphere defines the sphere to test
  6832. * @returns true if there is an intersection
  6833. */
  6834. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6835. /**
  6836. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6837. * @param min defines the min vector to use
  6838. * @param max defines the max vector to use
  6839. * @returns true if there is an intersection
  6840. */
  6841. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6842. /**
  6843. * Tests if two bounding boxes are intersections
  6844. * @param box0 defines the first box to test
  6845. * @param box1 defines the second box to test
  6846. * @returns true if there is an intersection
  6847. */
  6848. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6849. /**
  6850. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6851. * @param minPoint defines the minimum vector of the bounding box
  6852. * @param maxPoint defines the maximum vector of the bounding box
  6853. * @param sphereCenter defines the sphere center
  6854. * @param sphereRadius defines the sphere radius
  6855. * @returns true if there is an intersection
  6856. */
  6857. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6858. /**
  6859. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6860. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6861. * @param frustumPlanes defines the frustum planes to test
  6862. * @return true if there is an inclusion
  6863. */
  6864. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6865. /**
  6866. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6867. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6868. * @param frustumPlanes defines the frustum planes to test
  6869. * @return true if there is an intersection
  6870. */
  6871. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6872. }
  6873. }
  6874. declare module BABYLON {
  6875. /**
  6876. * Interface for cullable objects
  6877. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6878. */
  6879. interface ICullable {
  6880. /**
  6881. * Checks if the object or part of the object is in the frustum
  6882. * @param frustumPlanes Camera near/planes
  6883. * @returns true if the object is in frustum otherwise false
  6884. */
  6885. isInFrustum(frustumPlanes: Plane[]): boolean;
  6886. /**
  6887. * Checks if a cullable object (mesh...) is in the camera frustum
  6888. * Unlike isInFrustum this cheks the full bounding box
  6889. * @param frustumPlanes Camera near/planes
  6890. * @returns true if the object is in frustum otherwise false
  6891. */
  6892. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6893. }
  6894. /**
  6895. * Info for a bounding data of a mesh
  6896. */
  6897. class BoundingInfo implements ICullable {
  6898. /**
  6899. * Bounding box for the mesh
  6900. */
  6901. readonly boundingBox: BoundingBox;
  6902. /**
  6903. * Bounding sphere for the mesh
  6904. */
  6905. readonly boundingSphere: BoundingSphere;
  6906. private _isLocked;
  6907. private static readonly TmpVector3;
  6908. /**
  6909. * Constructs bounding info
  6910. * @param minimum min vector of the bounding box/sphere
  6911. * @param maximum max vector of the bounding box/sphere
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6915. /**
  6916. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6917. * @param min defines the new minimum vector (in local space)
  6918. * @param max defines the new maximum vector (in local space)
  6919. * @param worldMatrix defines the new world matrix
  6920. */
  6921. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6922. /**
  6923. * min vector of the bounding box/sphere
  6924. */
  6925. readonly minimum: Vector3;
  6926. /**
  6927. * max vector of the bounding box/sphere
  6928. */
  6929. readonly maximum: Vector3;
  6930. /**
  6931. * If the info is locked and won't be updated to avoid perf overhead
  6932. */
  6933. isLocked: boolean;
  6934. /**
  6935. * Updates the bounding sphere and box
  6936. * @param world world matrix to be used to update
  6937. */
  6938. update(world: DeepImmutable<Matrix>): void;
  6939. /**
  6940. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6941. * @param center New center of the bounding info
  6942. * @param extend New extend of the bounding info
  6943. * @returns the current bounding info
  6944. */
  6945. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6946. /**
  6947. * Scale the current bounding info by applying a scale factor
  6948. * @param factor defines the scale factor to apply
  6949. * @returns the current bounding info
  6950. */
  6951. scale(factor: number): BoundingInfo;
  6952. /**
  6953. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6954. * @param frustumPlanes defines the frustum to test
  6955. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  6956. * @returns true if the bounding info is in the frustum planes
  6957. */
  6958. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6959. /**
  6960. * Gets the world distance between the min and max points of the bounding box
  6961. */
  6962. readonly diagonalLength: number;
  6963. /**
  6964. * Checks if a cullable object (mesh...) is in the camera frustum
  6965. * Unlike isInFrustum this cheks the full bounding box
  6966. * @param frustumPlanes Camera near/planes
  6967. * @returns true if the object is in frustum otherwise false
  6968. */
  6969. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /** @hidden */
  6971. _checkCollision(collider: Collider): boolean;
  6972. /**
  6973. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6974. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6975. * @param point the point to check intersection with
  6976. * @returns if the point intersects
  6977. */
  6978. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6979. /**
  6980. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6981. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6982. * @param boundingInfo the bounding info to check intersection with
  6983. * @param precise if the intersection should be done using OBB
  6984. * @returns if the bounding info intersects
  6985. */
  6986. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6987. }
  6988. }
  6989. declare module BABYLON {
  6990. /**
  6991. * Class used to store bounding sphere information
  6992. */
  6993. class BoundingSphere {
  6994. /**
  6995. * Gets the center of the bounding sphere in local space
  6996. */
  6997. readonly center: Vector3;
  6998. /**
  6999. * Radius of the bounding sphere in local space
  7000. */
  7001. radius: number;
  7002. /**
  7003. * Gets the center of the bounding sphere in world space
  7004. */
  7005. readonly centerWorld: Vector3;
  7006. /**
  7007. * Radius of the bounding sphere in world space
  7008. */
  7009. radiusWorld: number;
  7010. /**
  7011. * Gets the minimum vector in local space
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * Gets the maximum vector in local space
  7016. */
  7017. readonly maximum: Vector3;
  7018. private _worldMatrix;
  7019. private static readonly TmpVector3;
  7020. /**
  7021. * Creates a new bounding sphere
  7022. * @param min defines the minimum vector (in local space)
  7023. * @param max defines the maximum vector (in local space)
  7024. * @param worldMatrix defines the new world matrix
  7025. */
  7026. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7027. /**
  7028. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7029. * @param min defines the new minimum vector (in local space)
  7030. * @param max defines the new maximum vector (in local space)
  7031. * @param worldMatrix defines the new world matrix
  7032. */
  7033. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7034. /**
  7035. * Scale the current bounding sphere by applying a scale factor
  7036. * @param factor defines the scale factor to apply
  7037. * @returns the current bounding box
  7038. */
  7039. scale(factor: number): BoundingSphere;
  7040. /**
  7041. * Gets the world matrix of the bounding box
  7042. * @returns a matrix
  7043. */
  7044. getWorldMatrix(): DeepImmutable<Matrix>;
  7045. /** @hidden */
  7046. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7047. /**
  7048. * Tests if the bounding sphere is intersecting the frustum planes
  7049. * @param frustumPlanes defines the frustum planes to test
  7050. * @returns true if there is an intersection
  7051. */
  7052. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7053. /**
  7054. * Tests if a point is inside the bounding sphere
  7055. * @param point defines the point to test
  7056. * @returns true if the point is inside the bounding sphere
  7057. */
  7058. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7059. /**
  7060. * Checks if two sphere intersct
  7061. * @param sphere0 sphere 0
  7062. * @param sphere1 sphere 1
  7063. * @returns true if the speres intersect
  7064. */
  7065. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7066. }
  7067. }
  7068. declare module BABYLON {
  7069. /**
  7070. * Class representing a ray with position and direction
  7071. */
  7072. class Ray {
  7073. /** origin point */
  7074. origin: Vector3;
  7075. /** direction */
  7076. direction: Vector3;
  7077. /** length of the ray */
  7078. length: number;
  7079. private static readonly TmpVector3;
  7080. private _tmpRay;
  7081. /**
  7082. * Creates a new ray
  7083. * @param origin origin point
  7084. * @param direction direction
  7085. * @param length length of the ray
  7086. */
  7087. constructor(
  7088. /** origin point */
  7089. origin: Vector3,
  7090. /** direction */
  7091. direction: Vector3,
  7092. /** length of the ray */
  7093. length?: number);
  7094. /**
  7095. * Checks if the ray intersects a box
  7096. * @param minimum bound of the box
  7097. * @param maximum bound of the box
  7098. * @param intersectionTreshold extra extend to be added to the box in all direction
  7099. * @returns if the box was hit
  7100. */
  7101. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  7102. /**
  7103. * Checks if the ray intersects a box
  7104. * @param box the bounding box to check
  7105. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  7106. * @returns if the box was hit
  7107. */
  7108. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  7109. /**
  7110. * If the ray hits a sphere
  7111. * @param sphere the bounding sphere to check
  7112. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  7113. * @returns true if it hits the sphere
  7114. */
  7115. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  7116. /**
  7117. * If the ray hits a triange
  7118. * @param vertex0 triangle vertex
  7119. * @param vertex1 triangle vertex
  7120. * @param vertex2 triangle vertex
  7121. * @returns intersection information if hit
  7122. */
  7123. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  7124. /**
  7125. * Checks if ray intersects a plane
  7126. * @param plane the plane to check
  7127. * @returns the distance away it was hit
  7128. */
  7129. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  7130. /**
  7131. * Checks if ray intersects a mesh
  7132. * @param mesh the mesh to check
  7133. * @param fastCheck if only the bounding box should checked
  7134. * @returns picking info of the intersecton
  7135. */
  7136. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  7137. /**
  7138. * Checks if ray intersects a mesh
  7139. * @param meshes the meshes to check
  7140. * @param fastCheck if only the bounding box should checked
  7141. * @param results array to store result in
  7142. * @returns Array of picking infos
  7143. */
  7144. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7145. private _comparePickingInfo;
  7146. private static smallnum;
  7147. private static rayl;
  7148. /**
  7149. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7150. * @param sega the first point of the segment to test the intersection against
  7151. * @param segb the second point of the segment to test the intersection against
  7152. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7153. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7154. */
  7155. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  7156. /**
  7157. * Update the ray from viewport position
  7158. * @param x position
  7159. * @param y y position
  7160. * @param viewportWidth viewport width
  7161. * @param viewportHeight viewport height
  7162. * @param world world matrix
  7163. * @param view view matrix
  7164. * @param projection projection matrix
  7165. * @returns this ray updated
  7166. */
  7167. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7168. /**
  7169. * Creates a ray with origin and direction of 0,0,0
  7170. * @returns the new ray
  7171. */
  7172. static Zero(): Ray;
  7173. /**
  7174. * Creates a new ray from screen space and viewport
  7175. * @param x position
  7176. * @param y y position
  7177. * @param viewportWidth viewport width
  7178. * @param viewportHeight viewport height
  7179. * @param world world matrix
  7180. * @param view view matrix
  7181. * @param projection projection matrix
  7182. * @returns new ray
  7183. */
  7184. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7185. /**
  7186. * 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
  7187. * transformed to the given world matrix.
  7188. * @param origin The origin point
  7189. * @param end The end point
  7190. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7191. * @returns the new ray
  7192. */
  7193. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  7194. /**
  7195. * Transforms a ray by a matrix
  7196. * @param ray ray to transform
  7197. * @param matrix matrix to apply
  7198. * @returns the resulting new ray
  7199. */
  7200. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  7201. /**
  7202. * Transforms a ray by a matrix
  7203. * @param ray ray to transform
  7204. * @param matrix matrix to apply
  7205. * @param result ray to store result in
  7206. */
  7207. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  7208. }
  7209. }
  7210. declare module BABYLON {
  7211. /**
  7212. * This represents an orbital type of camera.
  7213. *
  7214. * 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.
  7215. * 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.
  7216. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7217. */
  7218. class ArcRotateCamera extends TargetCamera {
  7219. /**
  7220. * Defines the rotation angle of the camera along the longitudinal axis.
  7221. */
  7222. alpha: number;
  7223. /**
  7224. * Defines the rotation angle of the camera along the latitudinal axis.
  7225. */
  7226. beta: number;
  7227. /**
  7228. * Defines the radius of the camera from it s target point.
  7229. */
  7230. radius: number;
  7231. protected _target: Vector3;
  7232. protected _targetHost: Nullable<AbstractMesh>;
  7233. /**
  7234. * Defines the target point of the camera.
  7235. * The camera looks towards it form the radius distance.
  7236. */
  7237. target: Vector3;
  7238. /**
  7239. * Current inertia value on the longitudinal axis.
  7240. * The bigger this number the longer it will take for the camera to stop.
  7241. */
  7242. inertialAlphaOffset: number;
  7243. /**
  7244. * Current inertia value on the latitudinal axis.
  7245. * The bigger this number the longer it will take for the camera to stop.
  7246. */
  7247. inertialBetaOffset: number;
  7248. /**
  7249. * Current inertia value on the radius axis.
  7250. * The bigger this number the longer it will take for the camera to stop.
  7251. */
  7252. inertialRadiusOffset: number;
  7253. /**
  7254. * Minimum allowed angle on the longitudinal axis.
  7255. * This can help limiting how the Camera is able to move in the scene.
  7256. */
  7257. lowerAlphaLimit: Nullable<number>;
  7258. /**
  7259. * Maximum allowed angle on the longitudinal axis.
  7260. * This can help limiting how the Camera is able to move in the scene.
  7261. */
  7262. upperAlphaLimit: Nullable<number>;
  7263. /**
  7264. * Minimum allowed angle on the latitudinal axis.
  7265. * This can help limiting how the Camera is able to move in the scene.
  7266. */
  7267. lowerBetaLimit: number;
  7268. /**
  7269. * Maximum allowed angle on the latitudinal axis.
  7270. * This can help limiting how the Camera is able to move in the scene.
  7271. */
  7272. upperBetaLimit: number;
  7273. /**
  7274. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7275. * This can help limiting how the Camera is able to move in the scene.
  7276. */
  7277. lowerRadiusLimit: Nullable<number>;
  7278. /**
  7279. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7280. * This can help limiting how the Camera is able to move in the scene.
  7281. */
  7282. upperRadiusLimit: Nullable<number>;
  7283. /**
  7284. * Defines the current inertia value used during panning of the camera along the X axis.
  7285. */
  7286. inertialPanningX: number;
  7287. /**
  7288. * Defines the current inertia value used during panning of the camera along the Y axis.
  7289. */
  7290. inertialPanningY: number;
  7291. /**
  7292. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7293. * Basically if your fingers moves away from more than this distance you will be considered
  7294. * in pinch mode.
  7295. */
  7296. pinchToPanMaxDistance: number;
  7297. /**
  7298. * Defines the maximum distance the camera can pan.
  7299. * This could help keeping the cammera always in your scene.
  7300. */
  7301. panningDistanceLimit: Nullable<number>;
  7302. /**
  7303. * Defines the target of the camera before paning.
  7304. */
  7305. panningOriginTarget: Vector3;
  7306. /**
  7307. * Defines the value of the inertia used during panning.
  7308. * 0 would mean stop inertia and one would mean no decelleration at all.
  7309. */
  7310. panningInertia: number;
  7311. /**
  7312. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7313. */
  7314. angularSensibilityX: number;
  7315. /**
  7316. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7317. */
  7318. angularSensibilityY: number;
  7319. /**
  7320. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7321. */
  7322. pinchPrecision: number;
  7323. /**
  7324. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7325. * It will be used instead of pinchDeltaPrecision if different from 0.
  7326. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7327. */
  7328. pinchDeltaPercentage: number;
  7329. /**
  7330. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7331. */
  7332. panningSensibility: number;
  7333. /**
  7334. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7335. */
  7336. keysUp: number[];
  7337. /**
  7338. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7339. */
  7340. keysDown: number[];
  7341. /**
  7342. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7343. */
  7344. keysLeft: number[];
  7345. /**
  7346. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7347. */
  7348. keysRight: number[];
  7349. /**
  7350. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7351. */
  7352. wheelPrecision: number;
  7353. /**
  7354. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7355. * It will be used instead of pinchDeltaPrecision if different from 0.
  7356. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7357. */
  7358. wheelDeltaPercentage: number;
  7359. /**
  7360. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7361. */
  7362. zoomOnFactor: number;
  7363. /**
  7364. * Defines a screen offset for the camera position.
  7365. */
  7366. targetScreenOffset: Vector2;
  7367. /**
  7368. * Allows the camera to be completely reversed.
  7369. * If false the camera can not arrive upside down.
  7370. */
  7371. allowUpsideDown: boolean;
  7372. /**
  7373. * Define if double tap/click is used to restore the previously saved state of the camera.
  7374. */
  7375. useInputToRestoreState: boolean;
  7376. /** @hidden */
  7377. _viewMatrix: Matrix;
  7378. /** @hidden */
  7379. _useCtrlForPanning: boolean;
  7380. /** @hidden */
  7381. _panningMouseButton: number;
  7382. /**
  7383. * Defines the inpute associated to the camera.
  7384. */
  7385. inputs: ArcRotateCameraInputsManager;
  7386. /** @hidden */
  7387. _reset: () => void;
  7388. /**
  7389. * Defines the allowed panning axis.
  7390. */
  7391. panningAxis: Vector3;
  7392. protected _localDirection: Vector3;
  7393. protected _transformedDirection: Vector3;
  7394. private _bouncingBehavior;
  7395. /**
  7396. * Gets the bouncing behavior of the camera if it has been enabled.
  7397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7398. */
  7399. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7400. /**
  7401. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7403. */
  7404. useBouncingBehavior: boolean;
  7405. private _framingBehavior;
  7406. /**
  7407. * Gets the framing behavior of the camera if it has been enabled.
  7408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7409. */
  7410. readonly framingBehavior: Nullable<FramingBehavior>;
  7411. /**
  7412. * Defines if the framing behavior of the camera is enabled on the camera.
  7413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7414. */
  7415. useFramingBehavior: boolean;
  7416. private _autoRotationBehavior;
  7417. /**
  7418. * Gets the auto rotation behavior of the camera if it has been enabled.
  7419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7420. */
  7421. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7422. /**
  7423. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7424. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7425. */
  7426. useAutoRotationBehavior: boolean;
  7427. /**
  7428. * Observable triggered when the mesh target has been changed on the camera.
  7429. */
  7430. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7431. /**
  7432. * Event raised when the camera is colliding with a mesh.
  7433. */
  7434. onCollide: (collidedMesh: AbstractMesh) => void;
  7435. /**
  7436. * Defines whether the camera should check collision with the objects oh the scene.
  7437. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7438. */
  7439. checkCollisions: boolean;
  7440. /**
  7441. * Defines the collision radius of the camera.
  7442. * This simulates a sphere around the camera.
  7443. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7444. */
  7445. collisionRadius: Vector3;
  7446. protected _collider: Collider;
  7447. protected _previousPosition: Vector3;
  7448. protected _collisionVelocity: Vector3;
  7449. protected _newPosition: Vector3;
  7450. protected _previousAlpha: number;
  7451. protected _previousBeta: number;
  7452. protected _previousRadius: number;
  7453. protected _collisionTriggered: boolean;
  7454. protected _targetBoundingCenter: Nullable<Vector3>;
  7455. private _computationVector;
  7456. /**
  7457. * Instantiates a new ArcRotateCamera in a given scene
  7458. * @param name Defines the name of the camera
  7459. * @param alpha Defines the camera rotation along the logitudinal axis
  7460. * @param beta Defines the camera rotation along the latitudinal axis
  7461. * @param radius Defines the camera distance from its target
  7462. * @param target Defines the camera target
  7463. * @param scene Defines the scene the camera belongs to
  7464. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7465. */
  7466. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7467. /** @hidden */
  7468. _initCache(): void;
  7469. /** @hidden */
  7470. _updateCache(ignoreParentClass?: boolean): void;
  7471. protected _getTargetPosition(): Vector3;
  7472. private _storedAlpha;
  7473. private _storedBeta;
  7474. private _storedRadius;
  7475. private _storedTarget;
  7476. /**
  7477. * Stores the current state of the camera (alpha, beta, radius and target)
  7478. * @returns the camera itself
  7479. */
  7480. storeState(): Camera;
  7481. /**
  7482. * @hidden
  7483. * Restored camera state. You must call storeState() first
  7484. */
  7485. _restoreStateValues(): boolean;
  7486. /** @hidden */
  7487. _isSynchronizedViewMatrix(): boolean;
  7488. /**
  7489. * Attached controls to the current camera.
  7490. * @param element Defines the element the controls should be listened from
  7491. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7492. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7493. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7494. */
  7495. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7496. /**
  7497. * Detach the current controls from the camera.
  7498. * The camera will stop reacting to inputs.
  7499. * @param element Defines the element to stop listening the inputs from
  7500. */
  7501. detachControl(element: HTMLElement): void;
  7502. /** @hidden */
  7503. _checkInputs(): void;
  7504. protected _checkLimits(): void;
  7505. /**
  7506. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7507. */
  7508. rebuildAnglesAndRadius(): void;
  7509. /**
  7510. * Use a position to define the current camera related information like aplha, beta and radius
  7511. * @param position Defines the position to set the camera at
  7512. */
  7513. setPosition(position: Vector3): void;
  7514. /**
  7515. * Defines the target the camera should look at.
  7516. * This will automatically adapt alpha beta and radius to fit within the new target.
  7517. * @param target Defines the new target as a Vector or a mesh
  7518. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7519. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7520. */
  7521. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7522. /** @hidden */
  7523. _getViewMatrix(): Matrix;
  7524. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7525. /**
  7526. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7527. * @param meshes Defines the mesh to zoom on
  7528. * @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)
  7529. */
  7530. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7531. /**
  7532. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7533. * The target will be changed but the radius
  7534. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7535. * @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)
  7536. */
  7537. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7538. min: Vector3;
  7539. max: Vector3;
  7540. distance: number;
  7541. }, doNotUpdateMaxZ?: boolean): void;
  7542. /**
  7543. * @override
  7544. * Override Camera.createRigCamera
  7545. */
  7546. createRigCamera(name: string, cameraIndex: number): Camera;
  7547. /**
  7548. * @hidden
  7549. * @override
  7550. * Override Camera._updateRigCameras
  7551. */
  7552. _updateRigCameras(): void;
  7553. /**
  7554. * Destroy the camera and release the current resources hold by it.
  7555. */
  7556. dispose(): void;
  7557. /**
  7558. * Gets the current object class name.
  7559. * @return the class name
  7560. */
  7561. getClassName(): string;
  7562. }
  7563. }
  7564. declare module BABYLON {
  7565. /**
  7566. * Default Inputs manager for the ArcRotateCamera.
  7567. * It groups all the default supported inputs for ease of use.
  7568. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7569. */
  7570. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7571. /**
  7572. * Instantiates a new ArcRotateCameraInputsManager.
  7573. * @param camera Defines the camera the inputs belong to
  7574. */
  7575. constructor(camera: ArcRotateCamera);
  7576. /**
  7577. * Add mouse wheel input support to the input manager.
  7578. * @returns the current input manager
  7579. */
  7580. addMouseWheel(): ArcRotateCameraInputsManager;
  7581. /**
  7582. * Add pointers input support to the input manager.
  7583. * @returns the current input manager
  7584. */
  7585. addPointers(): ArcRotateCameraInputsManager;
  7586. /**
  7587. * Add keyboard input support to the input manager.
  7588. * @returns the current input manager
  7589. */
  7590. addKeyboard(): ArcRotateCameraInputsManager;
  7591. /**
  7592. * Add orientation input support to the input manager.
  7593. * @returns the current input manager
  7594. */
  7595. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7596. }
  7597. }
  7598. declare module BABYLON {
  7599. /**
  7600. * This is the base class of all the camera used in the application.
  7601. * @see http://doc.babylonjs.com/features/cameras
  7602. */
  7603. class Camera extends Node {
  7604. /**
  7605. * This is the default projection mode used by the cameras.
  7606. * It helps recreating a feeling of perspective and better appreciate depth.
  7607. * This is the best way to simulate real life cameras.
  7608. */
  7609. static readonly PERSPECTIVE_CAMERA: number;
  7610. /**
  7611. * This helps creating camera with an orthographic mode.
  7612. * 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.
  7613. */
  7614. static readonly ORTHOGRAPHIC_CAMERA: number;
  7615. /**
  7616. * This is the default FOV mode for perspective cameras.
  7617. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7618. */
  7619. static readonly FOVMODE_VERTICAL_FIXED: number;
  7620. /**
  7621. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7622. */
  7623. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7624. /**
  7625. * This specifies ther is no need for a camera rig.
  7626. * Basically only one eye is rendered corresponding to the camera.
  7627. */
  7628. static readonly RIG_MODE_NONE: number;
  7629. /**
  7630. * Simulates a camera Rig with one blue eye and one red eye.
  7631. * This can be use with 3d blue and red glasses.
  7632. */
  7633. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7634. /**
  7635. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7636. */
  7637. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7638. /**
  7639. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7640. */
  7641. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7642. /**
  7643. * Defines that both eyes of the camera will be rendered over under each other.
  7644. */
  7645. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7646. /**
  7647. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7648. */
  7649. static readonly RIG_MODE_VR: number;
  7650. /**
  7651. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7652. */
  7653. static readonly RIG_MODE_WEBVR: number;
  7654. /**
  7655. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7656. */
  7657. static readonly RIG_MODE_CUSTOM: number;
  7658. /**
  7659. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7660. */
  7661. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7662. /**
  7663. * @hidden
  7664. * Might be removed once multiview will be a thing
  7665. */
  7666. static UseAlternateWebVRRendering: boolean;
  7667. /**
  7668. * Define the input manager associated with the camera.
  7669. */
  7670. inputs: CameraInputsManager<Camera>;
  7671. /**
  7672. * Define the current local position of the camera in the scene
  7673. */
  7674. position: Vector3;
  7675. /**
  7676. * The vector the camera should consider as up.
  7677. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7678. */
  7679. upVector: Vector3;
  7680. /**
  7681. * Define the current limit on the left side for an orthographic camera
  7682. * In scene unit
  7683. */
  7684. orthoLeft: Nullable<number>;
  7685. /**
  7686. * Define the current limit on the right side for an orthographic camera
  7687. * In scene unit
  7688. */
  7689. orthoRight: Nullable<number>;
  7690. /**
  7691. * Define the current limit on the bottom side for an orthographic camera
  7692. * In scene unit
  7693. */
  7694. orthoBottom: Nullable<number>;
  7695. /**
  7696. * Define the current limit on the top side for an orthographic camera
  7697. * In scene unit
  7698. */
  7699. orthoTop: Nullable<number>;
  7700. /**
  7701. * Field Of View is set in Radians. (default is 0.8)
  7702. */
  7703. fov: number;
  7704. /**
  7705. * Define the minimum distance the camera can see from.
  7706. * This is important to note that the depth buffer are not infinite and the closer it starts
  7707. * the more your scene might encounter depth fighting issue.
  7708. */
  7709. minZ: number;
  7710. /**
  7711. * Define the maximum distance the camera can see to.
  7712. * This is important to note that the depth buffer are not infinite and the further it end
  7713. * the more your scene might encounter depth fighting issue.
  7714. */
  7715. maxZ: number;
  7716. /**
  7717. * Define the default inertia of the camera.
  7718. * This helps giving a smooth feeling to the camera movement.
  7719. */
  7720. inertia: number;
  7721. /**
  7722. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7723. */
  7724. mode: number;
  7725. /**
  7726. * Define wether the camera is intermediate.
  7727. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7728. */
  7729. isIntermediate: boolean;
  7730. /**
  7731. * Define the viewport of the camera.
  7732. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7733. */
  7734. viewport: Viewport;
  7735. /**
  7736. * Restricts the camera to viewing objects with the same layerMask.
  7737. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7738. */
  7739. layerMask: number;
  7740. /**
  7741. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7742. */
  7743. fovMode: number;
  7744. /**
  7745. * Rig mode of the camera.
  7746. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7747. * This is normally controlled byt the camera themselves as internal use.
  7748. */
  7749. cameraRigMode: number;
  7750. /**
  7751. * Defines the distance between both "eyes" in case of a RIG
  7752. */
  7753. interaxialDistance: number;
  7754. /**
  7755. * Defines if stereoscopic rendering is done side by side or over under.
  7756. */
  7757. isStereoscopicSideBySide: boolean;
  7758. /**
  7759. * 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
  7760. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7761. * else in the scene.
  7762. */
  7763. customRenderTargets: RenderTargetTexture[];
  7764. /**
  7765. * When set, the camera will render to this render target instead of the default canvas
  7766. */
  7767. outputRenderTarget: Nullable<RenderTargetTexture>;
  7768. /**
  7769. * Observable triggered when the camera view matrix has changed.
  7770. */
  7771. onViewMatrixChangedObservable: Observable<Camera>;
  7772. /**
  7773. * Observable triggered when the camera Projection matrix has changed.
  7774. */
  7775. onProjectionMatrixChangedObservable: Observable<Camera>;
  7776. /**
  7777. * Observable triggered when the inputs have been processed.
  7778. */
  7779. onAfterCheckInputsObservable: Observable<Camera>;
  7780. /**
  7781. * Observable triggered when reset has been called and applied to the camera.
  7782. */
  7783. onRestoreStateObservable: Observable<Camera>;
  7784. /** @hidden */
  7785. _cameraRigParams: any;
  7786. /** @hidden */
  7787. _rigCameras: Camera[];
  7788. /** @hidden */
  7789. _rigPostProcess: Nullable<PostProcess>;
  7790. protected _webvrViewMatrix: Matrix;
  7791. /** @hidden */
  7792. _skipRendering: boolean;
  7793. /** @hidden */
  7794. _alternateCamera: Camera;
  7795. /** @hidden */
  7796. _projectionMatrix: Matrix;
  7797. /** @hidden */
  7798. _postProcesses: Nullable<PostProcess>[];
  7799. /** @hidden */
  7800. _activeMeshes: SmartArray<AbstractMesh>;
  7801. protected _globalPosition: Vector3;
  7802. /** hidden */
  7803. _computedViewMatrix: Matrix;
  7804. private _doNotComputeProjectionMatrix;
  7805. private _transformMatrix;
  7806. private _frustumPlanes;
  7807. private _refreshFrustumPlanes;
  7808. private _storedFov;
  7809. private _stateStored;
  7810. /**
  7811. * Instantiates a new camera object.
  7812. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7813. * @see http://doc.babylonjs.com/features/cameras
  7814. * @param name Defines the name of the camera in the scene
  7815. * @param position Defines the position of the camera
  7816. * @param scene Defines the scene the camera belongs too
  7817. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7818. */
  7819. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7820. /**
  7821. * Store current camera state (fov, position, etc..)
  7822. * @returns the camera
  7823. */
  7824. storeState(): Camera;
  7825. /**
  7826. * Restores the camera state values if it has been stored. You must call storeState() first
  7827. */
  7828. protected _restoreStateValues(): boolean;
  7829. /**
  7830. * Restored camera state. You must call storeState() first.
  7831. * @returns true if restored and false otherwise
  7832. */
  7833. restoreState(): boolean;
  7834. /**
  7835. * Gets the class name of the camera.
  7836. * @returns the class name
  7837. */
  7838. getClassName(): string;
  7839. /**
  7840. * Gets a string representation of the camera usefull for debug purpose.
  7841. * @param fullDetails Defines that a more verboe level of logging is required
  7842. * @returns the string representation
  7843. */
  7844. toString(fullDetails?: boolean): string;
  7845. /**
  7846. * Gets the current world space position of the camera.
  7847. */
  7848. readonly globalPosition: Vector3;
  7849. /**
  7850. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7851. * @returns the active meshe list
  7852. */
  7853. getActiveMeshes(): SmartArray<AbstractMesh>;
  7854. /**
  7855. * Check wether a mesh is part of the current active mesh list of the camera
  7856. * @param mesh Defines the mesh to check
  7857. * @returns true if active, false otherwise
  7858. */
  7859. isActiveMesh(mesh: Mesh): boolean;
  7860. /**
  7861. * Is this camera ready to be used/rendered
  7862. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7863. * @return true if the camera is ready
  7864. */
  7865. isReady(completeCheck?: boolean): boolean;
  7866. /** @hidden */
  7867. _initCache(): void;
  7868. /** @hidden */
  7869. _updateCache(ignoreParentClass?: boolean): void;
  7870. /** @hidden */
  7871. _isSynchronized(): boolean;
  7872. /** @hidden */
  7873. _isSynchronizedViewMatrix(): boolean;
  7874. /** @hidden */
  7875. _isSynchronizedProjectionMatrix(): boolean;
  7876. /**
  7877. * Attach the input controls to a specific dom element to get the input from.
  7878. * @param element Defines the element the controls should be listened from
  7879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7880. */
  7881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7882. /**
  7883. * Detach the current controls from the specified dom element.
  7884. * @param element Defines the element to stop listening the inputs from
  7885. */
  7886. detachControl(element: HTMLElement): void;
  7887. /**
  7888. * Update the camera state according to the different inputs gathered during the frame.
  7889. */
  7890. update(): void;
  7891. /** @hidden */
  7892. _checkInputs(): void;
  7893. /** @hidden */
  7894. readonly rigCameras: Camera[];
  7895. /**
  7896. * Gets the post process used by the rig cameras
  7897. */
  7898. readonly rigPostProcess: Nullable<PostProcess>;
  7899. /**
  7900. * Internal, gets the first post proces.
  7901. * @returns the first post process to be run on this camera.
  7902. */
  7903. _getFirstPostProcess(): Nullable<PostProcess>;
  7904. private _cascadePostProcessesToRigCams;
  7905. /**
  7906. * Attach a post process to the camera.
  7907. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7908. * @param postProcess The post process to attach to the camera
  7909. * @param insertAt The position of the post process in case several of them are in use in the scene
  7910. * @returns the position the post process has been inserted at
  7911. */
  7912. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7913. /**
  7914. * Detach a post process to the camera.
  7915. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7916. * @param postProcess The post process to detach from the camera
  7917. */
  7918. detachPostProcess(postProcess: PostProcess): void;
  7919. /**
  7920. * Gets the current world matrix of the camera
  7921. */
  7922. getWorldMatrix(): Matrix;
  7923. /** @hidden */
  7924. protected _getViewMatrix(): Matrix;
  7925. /**
  7926. * Gets the current view matrix of the camera.
  7927. * @param force forces the camera to recompute the matrix without looking at the cached state
  7928. * @returns the view matrix
  7929. */
  7930. getViewMatrix(force?: boolean): Matrix;
  7931. /**
  7932. * Freeze the projection matrix.
  7933. * It will prevent the cache check of the camera projection compute and can speed up perf
  7934. * if no parameter of the camera are meant to change
  7935. * @param projection Defines manually a projection if necessary
  7936. */
  7937. freezeProjectionMatrix(projection?: Matrix): void;
  7938. /**
  7939. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7940. */
  7941. unfreezeProjectionMatrix(): void;
  7942. /**
  7943. * Gets the current projection matrix of the camera.
  7944. * @param force forces the camera to recompute the matrix without looking at the cached state
  7945. * @returns the projection matrix
  7946. */
  7947. getProjectionMatrix(force?: boolean): Matrix;
  7948. /**
  7949. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7950. * @returns a Matrix
  7951. */
  7952. getTransformationMatrix(): Matrix;
  7953. private _updateFrustumPlanes;
  7954. /**
  7955. * Checks if a cullable object (mesh...) is in the camera frustum
  7956. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7957. * @param target The object to check
  7958. * @returns true if the object is in frustum otherwise false
  7959. */
  7960. isInFrustum(target: ICullable): boolean;
  7961. /**
  7962. * Checks if a cullable object (mesh...) is in the camera frustum
  7963. * Unlike isInFrustum this cheks the full bounding box
  7964. * @param target The object to check
  7965. * @returns true if the object is in frustum otherwise false
  7966. */
  7967. isCompletelyInFrustum(target: ICullable): boolean;
  7968. /**
  7969. * Gets a ray in the forward direction from the camera.
  7970. * @param length Defines the length of the ray to create
  7971. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7972. * @param origin Defines the start point of the ray which defaults to the camera position
  7973. * @returns the forward ray
  7974. */
  7975. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7976. /**
  7977. * Releases resources associated with this node.
  7978. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7979. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7980. */
  7981. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7982. /**
  7983. * Gets the left camera of a rig setup in case of Rigged Camera
  7984. */
  7985. readonly leftCamera: Nullable<FreeCamera>;
  7986. /**
  7987. * Gets the right camera of a rig setup in case of Rigged Camera
  7988. */
  7989. readonly rightCamera: Nullable<FreeCamera>;
  7990. /**
  7991. * Gets the left camera target of a rig setup in case of Rigged Camera
  7992. * @returns the target position
  7993. */
  7994. getLeftTarget(): Nullable<Vector3>;
  7995. /**
  7996. * Gets the right camera target of a rig setup in case of Rigged Camera
  7997. * @returns the target position
  7998. */
  7999. getRightTarget(): Nullable<Vector3>;
  8000. /**
  8001. * @hidden
  8002. */
  8003. setCameraRigMode(mode: number, rigParams: any): void;
  8004. private _getVRProjectionMatrix;
  8005. protected _updateCameraRotationMatrix(): void;
  8006. protected _updateWebVRCameraRotationMatrix(): void;
  8007. /**
  8008. * This function MUST be overwritten by the different WebVR cameras available.
  8009. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8010. */
  8011. protected _getWebVRProjectionMatrix(): Matrix;
  8012. /**
  8013. * This function MUST be overwritten by the different WebVR cameras available.
  8014. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8015. */
  8016. protected _getWebVRViewMatrix(): Matrix;
  8017. /** @hidden */
  8018. setCameraRigParameter(name: string, value: any): void;
  8019. /**
  8020. * needs to be overridden by children so sub has required properties to be copied
  8021. * @hidden
  8022. */
  8023. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8024. /**
  8025. * May need to be overridden by children
  8026. * @hidden
  8027. */
  8028. _updateRigCameras(): void;
  8029. /** @hidden */
  8030. _setupInputs(): void;
  8031. /**
  8032. * Serialiaze the camera setup to a json represention
  8033. * @returns the JSON representation
  8034. */
  8035. serialize(): any;
  8036. /**
  8037. * Clones the current camera.
  8038. * @param name The cloned camera name
  8039. * @returns the cloned camera
  8040. */
  8041. clone(name: string): Camera;
  8042. /**
  8043. * Gets the direction of the camera relative to a given local axis.
  8044. * @param localAxis Defines the reference axis to provide a relative direction.
  8045. * @return the direction
  8046. */
  8047. getDirection(localAxis: Vector3): Vector3;
  8048. /**
  8049. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8050. * @param localAxis Defines the reference axis to provide a relative direction.
  8051. * @param result Defines the vector to store the result in
  8052. */
  8053. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8054. /**
  8055. * Gets a camera constructor for a given camera type
  8056. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8057. * @param name The name of the camera the result will be able to instantiate
  8058. * @param scene The scene the result will construct the camera in
  8059. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8060. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8061. * @returns a factory method to construc the camera
  8062. */
  8063. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8064. /**
  8065. * Compute the world matrix of the camera.
  8066. * @returns the camera workd matrix
  8067. */
  8068. computeWorldMatrix(): Matrix;
  8069. /**
  8070. * Parse a JSON and creates the camera from the parsed information
  8071. * @param parsedCamera The JSON to parse
  8072. * @param scene The scene to instantiate the camera in
  8073. * @returns the newly constructed camera
  8074. */
  8075. static Parse(parsedCamera: any, scene: Scene): Camera;
  8076. }
  8077. }
  8078. declare module BABYLON {
  8079. /**
  8080. * @ignore
  8081. * This is a list of all the different input types that are available in the application.
  8082. * Fo instance: ArcRotateCameraGamepadInput...
  8083. */
  8084. var CameraInputTypes: {};
  8085. /**
  8086. * This is the contract to implement in order to create a new input class.
  8087. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8088. */
  8089. interface ICameraInput<TCamera extends Camera> {
  8090. /**
  8091. * Defines the camera the input is attached to.
  8092. */
  8093. camera: Nullable<TCamera>;
  8094. /**
  8095. * Gets the class name of the current intput.
  8096. * @returns the class name
  8097. */
  8098. getClassName(): string;
  8099. /**
  8100. * Get the friendly name associated with the input class.
  8101. * @returns the input friendly name
  8102. */
  8103. getSimpleName(): string;
  8104. /**
  8105. * Attach the input controls to a specific dom element to get the input from.
  8106. * @param element Defines the element the controls should be listened from
  8107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8108. */
  8109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8110. /**
  8111. * Detach the current controls from the specified dom element.
  8112. * @param element Defines the element to stop listening the inputs from
  8113. */
  8114. detachControl(element: Nullable<HTMLElement>): void;
  8115. /**
  8116. * Update the current camera state depending on the inputs that have been used this frame.
  8117. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8118. */
  8119. checkInputs?: () => void;
  8120. }
  8121. /**
  8122. * Represents a map of input types to input instance or input index to input instance.
  8123. */
  8124. interface CameraInputsMap<TCamera extends Camera> {
  8125. /**
  8126. * Accessor to the input by input type.
  8127. */
  8128. [name: string]: ICameraInput<TCamera>;
  8129. /**
  8130. * Accessor to the input by input index.
  8131. */
  8132. [idx: number]: ICameraInput<TCamera>;
  8133. }
  8134. /**
  8135. * This represents the input manager used within a camera.
  8136. * It helps dealing with all the different kind of input attached to a camera.
  8137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8138. */
  8139. class CameraInputsManager<TCamera extends Camera> {
  8140. /**
  8141. * Defines the list of inputs attahed to the camera.
  8142. */
  8143. attached: CameraInputsMap<TCamera>;
  8144. /**
  8145. * Defines the dom element the camera is collecting inputs from.
  8146. * This is null if the controls have not been attached.
  8147. */
  8148. attachedElement: Nullable<HTMLElement>;
  8149. /**
  8150. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8151. */
  8152. noPreventDefault: boolean;
  8153. /**
  8154. * Defined the camera the input manager belongs to.
  8155. */
  8156. camera: TCamera;
  8157. /**
  8158. * Update the current camera state depending on the inputs that have been used this frame.
  8159. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8160. */
  8161. checkInputs: () => void;
  8162. /**
  8163. * Instantiate a new Camera Input Manager.
  8164. * @param camera Defines the camera the input manager blongs to
  8165. */
  8166. constructor(camera: TCamera);
  8167. /**
  8168. * Add an input method to a camera
  8169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8170. * @param input camera input method
  8171. */
  8172. add(input: ICameraInput<TCamera>): void;
  8173. /**
  8174. * Remove a specific input method from a camera
  8175. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8176. * @param inputToRemove camera input method
  8177. */
  8178. remove(inputToRemove: ICameraInput<TCamera>): void;
  8179. /**
  8180. * Remove a specific input type from a camera
  8181. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8182. * @param inputType the type of the input to remove
  8183. */
  8184. removeByType(inputType: string): void;
  8185. private _addCheckInputs;
  8186. /**
  8187. * Attach the input controls to the currently attached dom element to listen the events from.
  8188. * @param input Defines the input to attach
  8189. */
  8190. attachInput(input: ICameraInput<TCamera>): void;
  8191. /**
  8192. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8193. * @param element Defines the dom element to collect the events from
  8194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8195. */
  8196. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8197. /**
  8198. * Detach the current manager inputs controls from a specific dom element.
  8199. * @param element Defines the dom element to collect the events from
  8200. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8201. */
  8202. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8203. /**
  8204. * Rebuild the dynamic inputCheck function from the current list of
  8205. * defined inputs in the manager.
  8206. */
  8207. rebuildInputCheck(): void;
  8208. /**
  8209. * Remove all attached input methods from a camera
  8210. */
  8211. clear(): void;
  8212. /**
  8213. * Serialize the current input manager attached to a camera.
  8214. * This ensures than once parsed,
  8215. * the input associated to the camera will be identical to the current ones
  8216. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8217. */
  8218. serialize(serializedCamera: any): void;
  8219. /**
  8220. * Parses an input manager serialized JSON to restore the previous list of inputs
  8221. * and states associated to a camera.
  8222. * @param parsedCamera Defines the JSON to parse
  8223. */
  8224. parse(parsedCamera: any): void;
  8225. }
  8226. }
  8227. declare module BABYLON {
  8228. /**
  8229. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8230. * being tilted forward or back and left or right.
  8231. */
  8232. class DeviceOrientationCamera extends FreeCamera {
  8233. private _initialQuaternion;
  8234. private _quaternionCache;
  8235. /**
  8236. * Creates a new device orientation camera
  8237. * @param name The name of the camera
  8238. * @param position The start position camera
  8239. * @param scene The scene the camera belongs to
  8240. */
  8241. constructor(name: string, position: Vector3, scene: Scene);
  8242. /**
  8243. * Gets the current instance class name ("DeviceOrientationCamera").
  8244. * This helps avoiding instanceof at run time.
  8245. * @returns the class name
  8246. */
  8247. getClassName(): string;
  8248. /**
  8249. * @hidden
  8250. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8251. */
  8252. _checkInputs(): void;
  8253. /**
  8254. * Reset the camera to its default orientation on the specified axis only.
  8255. * @param axis The axis to reset
  8256. */
  8257. resetToCurrentRotation(axis?: Axis): void;
  8258. }
  8259. }
  8260. declare module BABYLON {
  8261. /**
  8262. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8263. * such as in a 3D Space Shooter or a Flight Simulator.
  8264. */
  8265. class FlyCamera extends TargetCamera {
  8266. /**
  8267. * Define the collision ellipsoid of the camera.
  8268. * This is helpful for simulating a camera body, like a player's body.
  8269. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8270. */
  8271. ellipsoid: Vector3;
  8272. /**
  8273. * Define an offset for the position of the ellipsoid around the camera.
  8274. * This can be helpful if the camera is attached away from the player's body center,
  8275. * such as at its head.
  8276. */
  8277. ellipsoidOffset: Vector3;
  8278. /**
  8279. * Enable or disable collisions of the camera with the rest of the scene objects.
  8280. */
  8281. checkCollisions: boolean;
  8282. /**
  8283. * Enable or disable gravity on the camera.
  8284. */
  8285. applyGravity: boolean;
  8286. /**
  8287. * Define the current direction the camera is moving to.
  8288. */
  8289. cameraDirection: Vector3;
  8290. /**
  8291. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8292. * This overrides and empties cameraRotation.
  8293. */
  8294. rotationQuaternion: BABYLON.Quaternion;
  8295. /**
  8296. * Track Roll to maintain the wanted Rolling when looking around.
  8297. */
  8298. _trackRoll: number;
  8299. /**
  8300. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8301. */
  8302. rollCorrect: number;
  8303. /**
  8304. * Mimic a banked turn, Rolling the camera when Yawing.
  8305. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8306. */
  8307. bankedTurn: boolean;
  8308. /**
  8309. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8310. */
  8311. bankedTurnLimit: number;
  8312. /**
  8313. * Value of 0 disables the banked Roll.
  8314. * Value of 1 is equal to the Yaw angle in radians.
  8315. */
  8316. bankedTurnMultiplier: number;
  8317. /**
  8318. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8319. */
  8320. inputs: FlyCameraInputsManager;
  8321. /**
  8322. * Gets the input sensibility for mouse input.
  8323. * Higher values reduce sensitivity.
  8324. */
  8325. /**
  8326. * Sets the input sensibility for a mouse input.
  8327. * Higher values reduce sensitivity.
  8328. */
  8329. angularSensibility: number;
  8330. /**
  8331. * Get the keys for camera movement forward.
  8332. */
  8333. /**
  8334. * Set the keys for camera movement forward.
  8335. */
  8336. keysForward: number[];
  8337. /**
  8338. * Get the keys for camera movement backward.
  8339. */
  8340. keysBackward: number[];
  8341. /**
  8342. * Get the keys for camera movement up.
  8343. */
  8344. /**
  8345. * Set the keys for camera movement up.
  8346. */
  8347. keysUp: number[];
  8348. /**
  8349. * Get the keys for camera movement down.
  8350. */
  8351. /**
  8352. * Set the keys for camera movement down.
  8353. */
  8354. keysDown: number[];
  8355. /**
  8356. * Get the keys for camera movement left.
  8357. */
  8358. /**
  8359. * Set the keys for camera movement left.
  8360. */
  8361. keysLeft: number[];
  8362. /**
  8363. * Set the keys for camera movement right.
  8364. */
  8365. /**
  8366. * Set the keys for camera movement right.
  8367. */
  8368. keysRight: number[];
  8369. /**
  8370. * Event raised when the camera collides with a mesh in the scene.
  8371. */
  8372. onCollide: (collidedMesh: AbstractMesh) => void;
  8373. private _collider;
  8374. private _needMoveForGravity;
  8375. private _oldPosition;
  8376. private _diffPosition;
  8377. private _newPosition;
  8378. /** @hidden */
  8379. _localDirection: Vector3;
  8380. /** @hidden */
  8381. _transformedDirection: Vector3;
  8382. /**
  8383. * Instantiates a FlyCamera.
  8384. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8385. * such as in a 3D Space Shooter or a Flight Simulator.
  8386. * @param name Define the name of the camera in the scene.
  8387. * @param position Define the starting position of the camera in the scene.
  8388. * @param scene Define the scene the camera belongs to.
  8389. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8390. */
  8391. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8392. /**
  8393. * Attach a control to the HTML DOM element.
  8394. * @param element Defines the element that listens to the input events.
  8395. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8396. */
  8397. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8398. /**
  8399. * Detach a control from the HTML DOM element.
  8400. * The camera will stop reacting to that input.
  8401. * @param element Defines the element that listens to the input events.
  8402. */
  8403. detachControl(element: HTMLElement): void;
  8404. private _collisionMask;
  8405. /**
  8406. * Get the mask that the camera ignores in collision events.
  8407. */
  8408. /**
  8409. * Set the mask that the camera ignores in collision events.
  8410. */
  8411. collisionMask: number;
  8412. /** @hidden */
  8413. _collideWithWorld(displacement: Vector3): void;
  8414. /** @hidden */
  8415. private _onCollisionPositionChange;
  8416. /** @hidden */
  8417. _checkInputs(): void;
  8418. /** @hidden */
  8419. _decideIfNeedsToMove(): boolean;
  8420. /** @hidden */
  8421. _updatePosition(): void;
  8422. /**
  8423. * Restore the Roll to its target value at the rate specified.
  8424. * @param rate - Higher means slower restoring.
  8425. * @hidden
  8426. */
  8427. restoreRoll(rate: number): void;
  8428. /**
  8429. * Destroy the camera and release the current resources held by it.
  8430. */
  8431. dispose(): void;
  8432. /**
  8433. * Get the current object class name.
  8434. * @returns the class name.
  8435. */
  8436. getClassName(): string;
  8437. }
  8438. }
  8439. declare module BABYLON {
  8440. /**
  8441. * Default Inputs manager for the FlyCamera.
  8442. * It groups all the default supported inputs for ease of use.
  8443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8444. */
  8445. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8446. /**
  8447. * Instantiates a new FlyCameraInputsManager.
  8448. * @param camera Defines the camera the inputs belong to.
  8449. */
  8450. constructor(camera: FlyCamera);
  8451. /**
  8452. * Add keyboard input support to the input manager.
  8453. * @returns the new FlyCameraKeyboardMoveInput().
  8454. */
  8455. addKeyboard(): FlyCameraInputsManager;
  8456. /**
  8457. * Add mouse input support to the input manager.
  8458. * @param touchEnabled Enable touch screen support.
  8459. * @returns the new FlyCameraMouseInput().
  8460. */
  8461. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8462. }
  8463. }
  8464. declare module BABYLON {
  8465. /**
  8466. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8467. * an arc rotate version arcFollowCamera are available.
  8468. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8469. */
  8470. class FollowCamera extends TargetCamera {
  8471. /**
  8472. * Distance the follow camera should follow an object at
  8473. */
  8474. radius: number;
  8475. /**
  8476. * Define a rotation offset between the camera and the object it follows
  8477. */
  8478. rotationOffset: number;
  8479. /**
  8480. * Define a height offset between the camera and the object it follows.
  8481. * It can help following an object from the top (like a car chaing a plane)
  8482. */
  8483. heightOffset: number;
  8484. /**
  8485. * Define how fast the camera can accelerate to follow it s target.
  8486. */
  8487. cameraAcceleration: number;
  8488. /**
  8489. * Define the speed limit of the camera following an object.
  8490. */
  8491. maxCameraSpeed: number;
  8492. /**
  8493. * Define the target of the camera.
  8494. */
  8495. lockedTarget: Nullable<AbstractMesh>;
  8496. /**
  8497. * Instantiates the follow camera.
  8498. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8499. * @param name Define the name of the camera in the scene
  8500. * @param position Define the position of the camera
  8501. * @param scene Define the scene the camera belong to
  8502. * @param lockedTarget Define the target of the camera
  8503. */
  8504. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8505. private _follow;
  8506. /** @hidden */
  8507. _checkInputs(): void;
  8508. /**
  8509. * Gets the camera class name.
  8510. * @returns the class name
  8511. */
  8512. getClassName(): string;
  8513. }
  8514. /**
  8515. * Arc Rotate version of the follow camera.
  8516. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8517. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8518. */
  8519. class ArcFollowCamera extends TargetCamera {
  8520. /** The longitudinal angle of the camera */
  8521. alpha: number;
  8522. /** The latitudinal angle of the camera */
  8523. beta: number;
  8524. /** The radius of the camera from its target */
  8525. radius: number;
  8526. /** Define the camera target (the messh it should follow) */
  8527. target: Nullable<AbstractMesh>;
  8528. private _cartesianCoordinates;
  8529. /**
  8530. * Instantiates a new ArcFollowCamera
  8531. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8532. * @param name Define the name of the camera
  8533. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8534. * @param beta Define the rotation angle of the camera around the elevation axis
  8535. * @param radius Define the radius of the camera from its target point
  8536. * @param target Define the target of the camera
  8537. * @param scene Define the scene the camera belongs to
  8538. */
  8539. constructor(name: string,
  8540. /** The longitudinal angle of the camera */
  8541. alpha: number,
  8542. /** The latitudinal angle of the camera */
  8543. beta: number,
  8544. /** The radius of the camera from its target */
  8545. radius: number,
  8546. /** Define the camera target (the messh it should follow) */
  8547. target: Nullable<AbstractMesh>, scene: Scene);
  8548. private _follow;
  8549. /** @hidden */
  8550. _checkInputs(): void;
  8551. /**
  8552. * Returns the class name of the object.
  8553. * It is mostly used internally for serialization purposes.
  8554. */
  8555. getClassName(): string;
  8556. }
  8557. }
  8558. declare module BABYLON {
  8559. /**
  8560. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8561. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8562. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8563. */
  8564. class FreeCamera extends TargetCamera {
  8565. /**
  8566. * Define the collision ellipsoid of the camera.
  8567. * This is helpful to simulate a camera body like the player body around the camera
  8568. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8569. */
  8570. ellipsoid: Vector3;
  8571. /**
  8572. * Define an offset for the position of the ellipsoid around the camera.
  8573. * This can be helpful to determine the center of the body near the gravity center of the body
  8574. * instead of its head.
  8575. */
  8576. ellipsoidOffset: Vector3;
  8577. /**
  8578. * Enable or disable collisions of the camera with the rest of the scene objects.
  8579. */
  8580. checkCollisions: boolean;
  8581. /**
  8582. * Enable or disable gravity on the camera.
  8583. */
  8584. applyGravity: boolean;
  8585. /**
  8586. * Define the input manager associated to the camera.
  8587. */
  8588. inputs: FreeCameraInputsManager;
  8589. /**
  8590. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8591. * Higher values reduce sensitivity.
  8592. */
  8593. /**
  8594. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8595. * Higher values reduce sensitivity.
  8596. */
  8597. angularSensibility: number;
  8598. /**
  8599. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8600. */
  8601. keysUp: number[];
  8602. /**
  8603. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8604. */
  8605. keysDown: number[];
  8606. /**
  8607. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8608. */
  8609. keysLeft: number[];
  8610. /**
  8611. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8612. */
  8613. keysRight: number[];
  8614. /**
  8615. * Event raised when the camera collide with a mesh in the scene.
  8616. */
  8617. onCollide: (collidedMesh: AbstractMesh) => void;
  8618. private _collider;
  8619. private _needMoveForGravity;
  8620. private _oldPosition;
  8621. private _diffPosition;
  8622. private _newPosition;
  8623. /** @hidden */
  8624. _localDirection: Vector3;
  8625. /** @hidden */
  8626. _transformedDirection: Vector3;
  8627. /**
  8628. * Instantiates a Free Camera.
  8629. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8630. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8631. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8632. * @param name Define the name of the camera in the scene
  8633. * @param position Define the start position of the camera in the scene
  8634. * @param scene Define the scene the camera belongs to
  8635. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8636. */
  8637. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8638. /**
  8639. * Attached controls to the current camera.
  8640. * @param element Defines the element the controls should be listened from
  8641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8642. */
  8643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8644. /**
  8645. * Detach the current controls from the camera.
  8646. * The camera will stop reacting to inputs.
  8647. * @param element Defines the element to stop listening the inputs from
  8648. */
  8649. detachControl(element: HTMLElement): void;
  8650. private _collisionMask;
  8651. /**
  8652. * Define a collision mask to limit the list of object the camera can collide with
  8653. */
  8654. collisionMask: number;
  8655. /** @hidden */
  8656. _collideWithWorld(displacement: Vector3): void;
  8657. private _onCollisionPositionChange;
  8658. /** @hidden */
  8659. _checkInputs(): void;
  8660. /** @hidden */
  8661. _decideIfNeedsToMove(): boolean;
  8662. /** @hidden */
  8663. _updatePosition(): void;
  8664. /**
  8665. * Destroy the camera and release the current resources hold by it.
  8666. */
  8667. dispose(): void;
  8668. /**
  8669. * Gets the current object class name.
  8670. * @return the class name
  8671. */
  8672. getClassName(): string;
  8673. }
  8674. }
  8675. declare module BABYLON {
  8676. /**
  8677. * Default Inputs manager for the FreeCamera.
  8678. * It groups all the default supported inputs for ease of use.
  8679. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8680. */
  8681. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8682. /**
  8683. * Instantiates a new FreeCameraInputsManager.
  8684. * @param camera Defines the camera the inputs belong to
  8685. */
  8686. constructor(camera: FreeCamera);
  8687. /**
  8688. * Add keyboard input support to the input manager.
  8689. * @returns the current input manager
  8690. */
  8691. addKeyboard(): FreeCameraInputsManager;
  8692. /**
  8693. * Add mouse input support to the input manager.
  8694. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8695. * @returns the current input manager
  8696. */
  8697. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8698. /**
  8699. * Add orientation input support to the input manager.
  8700. * @returns the current input manager
  8701. */
  8702. addDeviceOrientation(): FreeCameraInputsManager;
  8703. /**
  8704. * Add touch input support to the input manager.
  8705. * @returns the current input manager
  8706. */
  8707. addTouch(): FreeCameraInputsManager;
  8708. /**
  8709. * Add virtual joystick input support to the input manager.
  8710. * @returns the current input manager
  8711. */
  8712. addVirtualJoystick(): FreeCameraInputsManager;
  8713. }
  8714. }
  8715. declare module BABYLON {
  8716. /**
  8717. * This represents a FPS type of camera. This is only here for back compat purpose.
  8718. * Please use the UniversalCamera instead as both are identical.
  8719. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8720. */
  8721. class GamepadCamera extends UniversalCamera {
  8722. /**
  8723. * Instantiates a new Gamepad Camera
  8724. * This represents a FPS type of camera. This is only here for back compat purpose.
  8725. * Please use the UniversalCamera instead as both are identical.
  8726. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8727. * @param name Define the name of the camera in the scene
  8728. * @param position Define the start position of the camera in the scene
  8729. * @param scene Define the scene the camera belongs to
  8730. */
  8731. constructor(name: string, position: Vector3, scene: Scene);
  8732. /**
  8733. * Gets the current object class name.
  8734. * @return the class name
  8735. */
  8736. getClassName(): string;
  8737. }
  8738. }
  8739. declare module BABYLON {
  8740. /**
  8741. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8742. * This is the base of the follow, arc rotate cameras and Free camera
  8743. * @see http://doc.babylonjs.com/features/cameras
  8744. */
  8745. class TargetCamera extends Camera {
  8746. /**
  8747. * Define the current direction the camera is moving to
  8748. */
  8749. cameraDirection: Vector3;
  8750. /**
  8751. * Define the current rotation the camera is rotating to
  8752. */
  8753. cameraRotation: Vector2;
  8754. /**
  8755. * When set, the up vector of the camera will be updated by the rotation of the camera
  8756. */
  8757. updateUpVectorFromRotation: boolean;
  8758. private _tmpQuaternion;
  8759. /**
  8760. * Define the current rotation of the camera
  8761. */
  8762. rotation: Vector3;
  8763. /**
  8764. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8765. */
  8766. rotationQuaternion: Quaternion;
  8767. /**
  8768. * Define the current speed of the camera
  8769. */
  8770. speed: number;
  8771. /**
  8772. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8773. * around all axis.
  8774. */
  8775. noRotationConstraint: boolean;
  8776. /**
  8777. * Define the current target of the camera as an object or a position.
  8778. */
  8779. lockedTarget: any;
  8780. /** @hidden */
  8781. _currentTarget: Vector3;
  8782. /** @hidden */
  8783. _viewMatrix: Matrix;
  8784. /** @hidden */
  8785. _camMatrix: Matrix;
  8786. /** @hidden */
  8787. _cameraTransformMatrix: Matrix;
  8788. /** @hidden */
  8789. _cameraRotationMatrix: Matrix;
  8790. private _rigCamTransformMatrix;
  8791. /** @hidden */
  8792. _referencePoint: Vector3;
  8793. /** @hidden */
  8794. _transformedReferencePoint: Vector3;
  8795. protected _globalCurrentTarget: Vector3;
  8796. protected _globalCurrentUpVector: Vector3;
  8797. /** @hidden */
  8798. _reset: () => void;
  8799. private _defaultUp;
  8800. /**
  8801. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8802. * This is the base of the follow, arc rotate cameras and Free camera
  8803. * @see http://doc.babylonjs.com/features/cameras
  8804. * @param name Defines the name of the camera in the scene
  8805. * @param position Defines the start position of the camera in the scene
  8806. * @param scene Defines the scene the camera belongs to
  8807. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8808. */
  8809. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8810. /**
  8811. * Gets the position in front of the camera at a given distance.
  8812. * @param distance The distance from the camera we want the position to be
  8813. * @returns the position
  8814. */
  8815. getFrontPosition(distance: number): Vector3;
  8816. /** @hidden */
  8817. _getLockedTargetPosition(): Nullable<Vector3>;
  8818. private _storedPosition;
  8819. private _storedRotation;
  8820. private _storedRotationQuaternion;
  8821. /**
  8822. * Store current camera state of the camera (fov, position, rotation, etc..)
  8823. * @returns the camera
  8824. */
  8825. storeState(): Camera;
  8826. /**
  8827. * Restored camera state. You must call storeState() first
  8828. * @returns whether it was successful or not
  8829. * @hidden
  8830. */
  8831. _restoreStateValues(): boolean;
  8832. /** @hidden */
  8833. _initCache(): void;
  8834. /** @hidden */
  8835. _updateCache(ignoreParentClass?: boolean): void;
  8836. /** @hidden */
  8837. _isSynchronizedViewMatrix(): boolean;
  8838. /** @hidden */
  8839. _computeLocalCameraSpeed(): number;
  8840. /** @hidden */
  8841. setTarget(target: Vector3): void;
  8842. /**
  8843. * Return the current target position of the camera. This value is expressed in local space.
  8844. * @returns the target position
  8845. */
  8846. getTarget(): Vector3;
  8847. /** @hidden */
  8848. _decideIfNeedsToMove(): boolean;
  8849. /** @hidden */
  8850. _updatePosition(): void;
  8851. /** @hidden */
  8852. _checkInputs(): void;
  8853. protected _updateCameraRotationMatrix(): void;
  8854. /**
  8855. * 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)
  8856. * @returns the current camera
  8857. */
  8858. private _rotateUpVectorWithCameraRotationMatrix;
  8859. private _cachedRotationZ;
  8860. private _cachedQuaternionRotationZ;
  8861. /** @hidden */
  8862. _getViewMatrix(): Matrix;
  8863. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8864. /**
  8865. * @hidden
  8866. */
  8867. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8868. /**
  8869. * @hidden
  8870. */
  8871. _updateRigCameras(): void;
  8872. private _getRigCamPosition;
  8873. /**
  8874. * Gets the current object class name.
  8875. * @return the class name
  8876. */
  8877. getClassName(): string;
  8878. }
  8879. }
  8880. declare module BABYLON {
  8881. /**
  8882. * This represents a FPS type of camera controlled by touch.
  8883. * This is like a universal camera minus the Gamepad controls.
  8884. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8885. */
  8886. class TouchCamera extends FreeCamera {
  8887. /**
  8888. * Defines the touch sensibility for rotation.
  8889. * The higher the faster.
  8890. */
  8891. touchAngularSensibility: number;
  8892. /**
  8893. * Defines the touch sensibility for move.
  8894. * The higher the faster.
  8895. */
  8896. touchMoveSensibility: number;
  8897. /**
  8898. * Instantiates a new touch camera.
  8899. * This represents a FPS type of camera controlled by touch.
  8900. * This is like a universal camera minus the Gamepad controls.
  8901. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8902. * @param name Define the name of the camera in the scene
  8903. * @param position Define the start position of the camera in the scene
  8904. * @param scene Define the scene the camera belongs to
  8905. */
  8906. constructor(name: string, position: Vector3, scene: Scene);
  8907. /**
  8908. * Gets the current object class name.
  8909. * @return the class name
  8910. */
  8911. getClassName(): string;
  8912. /** @hidden */
  8913. _setupInputs(): void;
  8914. }
  8915. }
  8916. declare module BABYLON {
  8917. /**
  8918. * 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,
  8919. * which still works and will still be found in many Playgrounds.
  8920. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8921. */
  8922. class UniversalCamera extends TouchCamera {
  8923. /**
  8924. * Defines the gamepad rotation sensiblity.
  8925. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8926. */
  8927. gamepadAngularSensibility: number;
  8928. /**
  8929. * Defines the gamepad move sensiblity.
  8930. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8931. */
  8932. gamepadMoveSensibility: number;
  8933. /**
  8934. * 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,
  8935. * which still works and will still be found in many Playgrounds.
  8936. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8937. * @param name Define the name of the camera in the scene
  8938. * @param position Define the start position of the camera in the scene
  8939. * @param scene Define the scene the camera belongs to
  8940. */
  8941. constructor(name: string, position: Vector3, scene: Scene);
  8942. /**
  8943. * Gets the current object class name.
  8944. * @return the class name
  8945. */
  8946. getClassName(): string;
  8947. }
  8948. }
  8949. declare module BABYLON {
  8950. /**
  8951. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8952. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8953. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8954. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8955. */
  8956. class VirtualJoysticksCamera extends FreeCamera {
  8957. /**
  8958. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  8959. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8960. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8961. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8962. * @param name Define the name of the camera in the scene
  8963. * @param position Define the start position of the camera in the scene
  8964. * @param scene Define the scene the camera belongs to
  8965. */
  8966. constructor(name: string, position: Vector3, scene: Scene);
  8967. /**
  8968. * Gets the current object class name.
  8969. * @return the class name
  8970. */
  8971. getClassName(): string;
  8972. }
  8973. }
  8974. interface VRDisplay extends EventTarget {
  8975. /**
  8976. * Dictionary of capabilities describing the VRDisplay.
  8977. */
  8978. readonly capabilities: VRDisplayCapabilities;
  8979. /**
  8980. * z-depth defining the far plane of the eye view frustum
  8981. * enables mapping of values in the render target depth
  8982. * attachment to scene coordinates. Initially set to 10000.0.
  8983. */
  8984. depthFar: number;
  8985. /**
  8986. * z-depth defining the near plane of the eye view frustum
  8987. * enables mapping of values in the render target depth
  8988. * attachment to scene coordinates. Initially set to 0.01.
  8989. */
  8990. depthNear: number;
  8991. /**
  8992. * An identifier for this distinct VRDisplay. Used as an
  8993. * association point in the Gamepad API.
  8994. */
  8995. readonly displayId: number;
  8996. /**
  8997. * A display name, a user-readable name identifying it.
  8998. */
  8999. readonly displayName: string;
  9000. readonly isConnected: boolean;
  9001. readonly isPresenting: boolean;
  9002. /**
  9003. * If this VRDisplay supports room-scale experiences, the optional
  9004. * stage attribute contains details on the room-scale parameters.
  9005. */
  9006. readonly stageParameters: VRStageParameters | null;
  9007. /**
  9008. * Passing the value returned by `requestAnimationFrame` to
  9009. * `cancelAnimationFrame` will unregister the callback.
  9010. * @param handle Define the hanle of the request to cancel
  9011. */
  9012. cancelAnimationFrame(handle: number): void;
  9013. /**
  9014. * Stops presenting to the VRDisplay.
  9015. * @returns a promise to know when it stopped
  9016. */
  9017. exitPresent(): Promise<void>;
  9018. /**
  9019. * Return the current VREyeParameters for the given eye.
  9020. * @param whichEye Define the eye we want the parameter for
  9021. * @returns the eye parameters
  9022. */
  9023. getEyeParameters(whichEye: string): VREyeParameters;
  9024. /**
  9025. * Populates the passed VRFrameData with the information required to render
  9026. * the current frame.
  9027. * @param frameData Define the data structure to populate
  9028. * @returns true if ok otherwise false
  9029. */
  9030. getFrameData(frameData: VRFrameData): boolean;
  9031. /**
  9032. * Get the layers currently being presented.
  9033. * @returns the list of VR layers
  9034. */
  9035. getLayers(): VRLayer[];
  9036. /**
  9037. * Return a VRPose containing the future predicted pose of the VRDisplay
  9038. * when the current frame will be presented. The value returned will not
  9039. * change until JavaScript has returned control to the browser.
  9040. *
  9041. * The VRPose will contain the position, orientation, velocity,
  9042. * and acceleration of each of these properties.
  9043. * @returns the pose object
  9044. */
  9045. getPose(): VRPose;
  9046. /**
  9047. * Return the current instantaneous pose of the VRDisplay, with no
  9048. * prediction applied.
  9049. * @returns the current instantaneous pose
  9050. */
  9051. getImmediatePose(): VRPose;
  9052. /**
  9053. * The callback passed to `requestAnimationFrame` will be called
  9054. * any time a new frame should be rendered. When the VRDisplay is
  9055. * presenting the callback will be called at the native refresh
  9056. * rate of the HMD. When not presenting this function acts
  9057. * identically to how window.requestAnimationFrame acts. Content should
  9058. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9059. * asynchronously from other displays and at differing refresh rates.
  9060. * @param callback Define the eaction to run next frame
  9061. * @returns the request handle it
  9062. */
  9063. requestAnimationFrame(callback: FrameRequestCallback): number;
  9064. /**
  9065. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9066. * Repeat calls while already presenting will update the VRLayers being displayed.
  9067. * @param layers Define the list of layer to present
  9068. * @returns a promise to know when the request has been fulfilled
  9069. */
  9070. requestPresent(layers: VRLayer[]): Promise<void>;
  9071. /**
  9072. * Reset the pose for this display, treating its current position and
  9073. * orientation as the "origin/zero" values. VRPose.position,
  9074. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9075. * updated when calling resetPose(). This should be called in only
  9076. * sitting-space experiences.
  9077. */
  9078. resetPose(): void;
  9079. /**
  9080. * The VRLayer provided to the VRDisplay will be captured and presented
  9081. * in the HMD. Calling this function has the same effect on the source
  9082. * canvas as any other operation that uses its source image, and canvases
  9083. * created without preserveDrawingBuffer set to true will be cleared.
  9084. * @param pose Define the pose to submit
  9085. */
  9086. submitFrame(pose?: VRPose): void;
  9087. }
  9088. declare var VRDisplay: {
  9089. prototype: VRDisplay;
  9090. new (): VRDisplay;
  9091. };
  9092. interface VRLayer {
  9093. leftBounds?: number[] | Float32Array | null;
  9094. rightBounds?: number[] | Float32Array | null;
  9095. source?: HTMLCanvasElement | null;
  9096. }
  9097. interface VRDisplayCapabilities {
  9098. readonly canPresent: boolean;
  9099. readonly hasExternalDisplay: boolean;
  9100. readonly hasOrientation: boolean;
  9101. readonly hasPosition: boolean;
  9102. readonly maxLayers: number;
  9103. }
  9104. interface VREyeParameters {
  9105. /** @deprecated */
  9106. readonly fieldOfView: VRFieldOfView;
  9107. readonly offset: Float32Array;
  9108. readonly renderHeight: number;
  9109. readonly renderWidth: number;
  9110. }
  9111. interface VRFieldOfView {
  9112. readonly downDegrees: number;
  9113. readonly leftDegrees: number;
  9114. readonly rightDegrees: number;
  9115. readonly upDegrees: number;
  9116. }
  9117. interface VRFrameData {
  9118. readonly leftProjectionMatrix: Float32Array;
  9119. readonly leftViewMatrix: Float32Array;
  9120. readonly pose: VRPose;
  9121. readonly rightProjectionMatrix: Float32Array;
  9122. readonly rightViewMatrix: Float32Array;
  9123. readonly timestamp: number;
  9124. }
  9125. interface VRPose {
  9126. readonly angularAcceleration: Float32Array | null;
  9127. readonly angularVelocity: Float32Array | null;
  9128. readonly linearAcceleration: Float32Array | null;
  9129. readonly linearVelocity: Float32Array | null;
  9130. readonly orientation: Float32Array | null;
  9131. readonly position: Float32Array | null;
  9132. readonly timestamp: number;
  9133. }
  9134. interface VRStageParameters {
  9135. sittingToStandingTransform?: Float32Array;
  9136. sizeX?: number;
  9137. sizeY?: number;
  9138. }
  9139. interface Navigator {
  9140. getVRDisplays(): Promise<VRDisplay[]>;
  9141. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9142. }
  9143. interface Window {
  9144. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9145. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9146. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9147. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9148. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9149. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9150. }
  9151. interface Gamepad {
  9152. readonly displayId: number;
  9153. }
  9154. declare module BABYLON {
  9155. /** @hidden */
  9156. class Collider {
  9157. /** Define if a collision was found */
  9158. collisionFound: boolean;
  9159. /**
  9160. * Define last intersection point in local space
  9161. */
  9162. intersectionPoint: Vector3;
  9163. /**
  9164. * Define last collided mesh
  9165. */
  9166. collidedMesh: Nullable<AbstractMesh>;
  9167. private _collisionPoint;
  9168. private _planeIntersectionPoint;
  9169. private _tempVector;
  9170. private _tempVector2;
  9171. private _tempVector3;
  9172. private _tempVector4;
  9173. private _edge;
  9174. private _baseToVertex;
  9175. private _destinationPoint;
  9176. private _slidePlaneNormal;
  9177. private _displacementVector;
  9178. /** @hidden */
  9179. _radius: Vector3;
  9180. /** @hidden */
  9181. _retry: number;
  9182. private _velocity;
  9183. private _basePoint;
  9184. private _epsilon;
  9185. /** @hidden */
  9186. _velocityWorldLength: number;
  9187. /** @hidden */
  9188. _basePointWorld: Vector3;
  9189. private _velocityWorld;
  9190. private _normalizedVelocity;
  9191. /** @hidden */
  9192. _initialVelocity: Vector3;
  9193. /** @hidden */
  9194. _initialPosition: Vector3;
  9195. private _nearestDistance;
  9196. private _collisionMask;
  9197. collisionMask: number;
  9198. /**
  9199. * Gets the plane normal used to compute the sliding response (in local space)
  9200. */
  9201. readonly slidePlaneNormal: Vector3;
  9202. /** @hidden */
  9203. _initialize(source: Vector3, dir: Vector3, e: number): void;
  9204. /** @hidden */
  9205. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  9206. /** @hidden */
  9207. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  9208. /** @hidden */
  9209. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  9210. /** @hidden */
  9211. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  9212. /** @hidden */
  9213. _getResponse(pos: Vector3, vel: Vector3): void;
  9214. }
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. var CollisionWorker: string;
  9219. /** @hidden */
  9220. interface ICollisionCoordinator {
  9221. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9222. init(scene: Scene): void;
  9223. destroy(): void;
  9224. onMeshAdded(mesh: AbstractMesh): void;
  9225. onMeshUpdated(mesh: AbstractMesh): void;
  9226. onMeshRemoved(mesh: AbstractMesh): void;
  9227. onGeometryAdded(geometry: Geometry): void;
  9228. onGeometryUpdated(geometry: Geometry): void;
  9229. onGeometryDeleted(geometry: Geometry): void;
  9230. }
  9231. /** @hidden */
  9232. interface SerializedMesh {
  9233. id: string;
  9234. name: string;
  9235. uniqueId: number;
  9236. geometryId: Nullable<string>;
  9237. sphereCenter: Array<number>;
  9238. sphereRadius: number;
  9239. boxMinimum: Array<number>;
  9240. boxMaximum: Array<number>;
  9241. worldMatrixFromCache: any;
  9242. subMeshes: Array<SerializedSubMesh>;
  9243. checkCollisions: boolean;
  9244. }
  9245. /** @hidden */
  9246. interface SerializedSubMesh {
  9247. position: number;
  9248. verticesStart: number;
  9249. verticesCount: number;
  9250. indexStart: number;
  9251. indexCount: number;
  9252. hasMaterial: boolean;
  9253. sphereCenter: Array<number>;
  9254. sphereRadius: number;
  9255. boxMinimum: Array<number>;
  9256. boxMaximum: Array<number>;
  9257. }
  9258. /**
  9259. * Interface describing the value associated with a geometry.
  9260. * @hidden
  9261. */
  9262. interface SerializedGeometry {
  9263. /**
  9264. * Defines the unique ID of the geometry
  9265. */
  9266. id: string;
  9267. /**
  9268. * Defines the array containing the positions
  9269. */
  9270. positions: Float32Array;
  9271. /**
  9272. * Defines the array containing the indices
  9273. */
  9274. indices: Uint32Array;
  9275. /**
  9276. * Defines the array containing the normals
  9277. */
  9278. normals: Float32Array;
  9279. }
  9280. /** @hidden */
  9281. interface BabylonMessage {
  9282. taskType: WorkerTaskType;
  9283. payload: InitPayload | CollidePayload | UpdatePayload;
  9284. }
  9285. /** @hidden */
  9286. interface SerializedColliderToWorker {
  9287. position: Array<number>;
  9288. velocity: Array<number>;
  9289. radius: Array<number>;
  9290. }
  9291. /** Defines supported task for worker process */
  9292. enum WorkerTaskType {
  9293. /** Initialization */
  9294. INIT = 0,
  9295. /** Update of geometry */
  9296. UPDATE = 1,
  9297. /** Evaluate collision */
  9298. COLLIDE = 2
  9299. }
  9300. /** @hidden */
  9301. interface WorkerReply {
  9302. error: WorkerReplyType;
  9303. taskType: WorkerTaskType;
  9304. payload?: any;
  9305. }
  9306. /** @hidden */
  9307. interface CollisionReplyPayload {
  9308. newPosition: Array<number>;
  9309. collisionId: number;
  9310. collidedMeshUniqueId: number;
  9311. }
  9312. /** @hidden */
  9313. interface InitPayload {
  9314. }
  9315. /** @hidden */
  9316. interface CollidePayload {
  9317. collisionId: number;
  9318. collider: SerializedColliderToWorker;
  9319. maximumRetry: number;
  9320. excludedMeshUniqueId: Nullable<number>;
  9321. }
  9322. /** @hidden */
  9323. interface UpdatePayload {
  9324. updatedMeshes: {
  9325. [n: number]: SerializedMesh;
  9326. };
  9327. updatedGeometries: {
  9328. [s: string]: SerializedGeometry;
  9329. };
  9330. removedMeshes: Array<number>;
  9331. removedGeometries: Array<string>;
  9332. }
  9333. /** Defines kind of replies returned by worker */
  9334. enum WorkerReplyType {
  9335. /** Success */
  9336. SUCCESS = 0,
  9337. /** Unkown error */
  9338. UNKNOWN_ERROR = 1
  9339. }
  9340. /** @hidden */
  9341. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  9342. private _scene;
  9343. private _scaledPosition;
  9344. private _scaledVelocity;
  9345. private _collisionsCallbackArray;
  9346. private _init;
  9347. private _runningUpdated;
  9348. private _worker;
  9349. private _addUpdateMeshesList;
  9350. private _addUpdateGeometriesList;
  9351. private _toRemoveMeshesArray;
  9352. private _toRemoveGeometryArray;
  9353. constructor();
  9354. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  9355. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  9356. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9357. init(scene: Scene): void;
  9358. destroy(): void;
  9359. onMeshAdded(mesh: AbstractMesh): void;
  9360. onMeshUpdated: (transformNode: TransformNode) => void;
  9361. onMeshRemoved(mesh: AbstractMesh): void;
  9362. onGeometryAdded(geometry: Geometry): void;
  9363. onGeometryUpdated: (geometry: Geometry) => void;
  9364. onGeometryDeleted(geometry: Geometry): void;
  9365. private _afterRender;
  9366. private _onMessageFromWorker;
  9367. }
  9368. /** @hidden */
  9369. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  9370. private _scene;
  9371. private _scaledPosition;
  9372. private _scaledVelocity;
  9373. private _finalPosition;
  9374. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9375. init(scene: Scene): void;
  9376. destroy(): void;
  9377. onMeshAdded(mesh: AbstractMesh): void;
  9378. onMeshUpdated(mesh: AbstractMesh): void;
  9379. onMeshRemoved(mesh: AbstractMesh): void;
  9380. onGeometryAdded(geometry: Geometry): void;
  9381. onGeometryUpdated(geometry: Geometry): void;
  9382. onGeometryDeleted(geometry: Geometry): void;
  9383. private _collideWithWorld;
  9384. }
  9385. }
  9386. declare function importScripts(...urls: string[]): void;
  9387. declare const safePostMessage: any;
  9388. declare module BABYLON {
  9389. /** @hidden */
  9390. var WorkerIncluded: boolean;
  9391. /** @hidden */
  9392. class CollisionCache {
  9393. private _meshes;
  9394. private _geometries;
  9395. getMeshes(): {
  9396. [n: number]: SerializedMesh;
  9397. };
  9398. getGeometries(): {
  9399. [s: number]: SerializedGeometry;
  9400. };
  9401. getMesh(id: any): SerializedMesh;
  9402. addMesh(mesh: SerializedMesh): void;
  9403. removeMesh(uniqueId: number): void;
  9404. getGeometry(id: string): SerializedGeometry;
  9405. addGeometry(geometry: SerializedGeometry): void;
  9406. removeGeometry(id: string): void;
  9407. }
  9408. /** @hidden */
  9409. class CollideWorker {
  9410. collider: Collider;
  9411. private _collisionCache;
  9412. private finalPosition;
  9413. private collisionsScalingMatrix;
  9414. private collisionTranformationMatrix;
  9415. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  9416. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  9417. private checkCollision;
  9418. private processCollisionsForSubMeshes;
  9419. private collideForSubMesh;
  9420. private checkSubmeshCollision;
  9421. }
  9422. /** @hidden */
  9423. interface ICollisionDetector {
  9424. onInit(payload: InitPayload): void;
  9425. onUpdate(payload: UpdatePayload): void;
  9426. onCollision(payload: CollidePayload): void;
  9427. }
  9428. /** @hidden */
  9429. class CollisionDetectorTransferable implements ICollisionDetector {
  9430. private _collisionCache;
  9431. onInit(payload: InitPayload): void;
  9432. onUpdate(payload: UpdatePayload): void;
  9433. onCollision(payload: CollidePayload): void;
  9434. }
  9435. }
  9436. declare module BABYLON {
  9437. /**
  9438. * @hidden
  9439. */
  9440. class IntersectionInfo {
  9441. bu: Nullable<number>;
  9442. bv: Nullable<number>;
  9443. distance: number;
  9444. faceId: number;
  9445. subMeshId: number;
  9446. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  9447. }
  9448. /**
  9449. * Information about the result of picking within a scene
  9450. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  9451. */
  9452. class PickingInfo {
  9453. /**
  9454. * If the pick collided with an object
  9455. */
  9456. hit: boolean;
  9457. /**
  9458. * Distance away where the pick collided
  9459. */
  9460. distance: number;
  9461. /**
  9462. * The location of pick collision
  9463. */
  9464. pickedPoint: Nullable<Vector3>;
  9465. /**
  9466. * The mesh corresponding the the pick collision
  9467. */
  9468. pickedMesh: Nullable<AbstractMesh>;
  9469. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9470. bu: number;
  9471. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9472. bv: number;
  9473. /** The id of the face on the mesh that was picked */
  9474. faceId: number;
  9475. /** Id of the the submesh that was picked */
  9476. subMeshId: number;
  9477. /** If a sprite was picked, this will be the sprite the pick collided with */
  9478. pickedSprite: Nullable<Sprite>;
  9479. /**
  9480. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9481. */
  9482. originMesh: Nullable<AbstractMesh>;
  9483. /**
  9484. * The ray that was used to perform the picking.
  9485. */
  9486. ray: Nullable<Ray>;
  9487. /**
  9488. * Gets the normal correspodning to the face the pick collided with
  9489. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9490. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9491. * @returns The normal correspodning to the face the pick collided with
  9492. */
  9493. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9494. /**
  9495. * Gets the texture coordinates of where the pick occured
  9496. * @returns the vector containing the coordnates of the texture
  9497. */
  9498. getTextureCoordinates(): Nullable<Vector2>;
  9499. }
  9500. }
  9501. /**
  9502. * Module Debug contains the (visual) components to debug a scene correctly
  9503. */
  9504. declare module BABYLON.Debug {
  9505. /**
  9506. * The Axes viewer will show 3 axes in a specific point in space
  9507. */
  9508. class AxesViewer {
  9509. private _xline;
  9510. private _yline;
  9511. private _zline;
  9512. private _xmesh;
  9513. private _ymesh;
  9514. private _zmesh;
  9515. /**
  9516. * Gets the hosting scene
  9517. */
  9518. scene: Nullable<Scene>;
  9519. /**
  9520. * Gets or sets a number used to scale line length
  9521. */
  9522. scaleLines: number;
  9523. /**
  9524. * Creates a new AxesViewer
  9525. * @param scene defines the hosting scene
  9526. * @param scaleLines defines a number used to scale line length (1 by default)
  9527. */
  9528. constructor(scene: Scene, scaleLines?: number);
  9529. /**
  9530. * Force the viewer to update
  9531. * @param position defines the position of the viewer
  9532. * @param xaxis defines the x axis of the viewer
  9533. * @param yaxis defines the y axis of the viewer
  9534. * @param zaxis defines the z axis of the viewer
  9535. */
  9536. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9537. /** Releases resources */
  9538. dispose(): void;
  9539. }
  9540. }
  9541. declare module BABYLON.Debug {
  9542. /**
  9543. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9544. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9545. */
  9546. class BoneAxesViewer extends AxesViewer {
  9547. /**
  9548. * Gets or sets the target mesh where to display the axes viewer
  9549. */
  9550. mesh: Nullable<Mesh>;
  9551. /**
  9552. * Gets or sets the target bone where to display the axes viewer
  9553. */
  9554. bone: Nullable<Bone>;
  9555. /** Gets current position */
  9556. pos: Vector3;
  9557. /** Gets direction of X axis */
  9558. xaxis: Vector3;
  9559. /** Gets direction of Y axis */
  9560. yaxis: Vector3;
  9561. /** Gets direction of Z axis */
  9562. zaxis: Vector3;
  9563. /**
  9564. * Creates a new BoneAxesViewer
  9565. * @param scene defines the hosting scene
  9566. * @param bone defines the target bone
  9567. * @param mesh defines the target mesh
  9568. * @param scaleLines defines a scaling factor for line length (1 by default)
  9569. */
  9570. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9571. /**
  9572. * Force the viewer to update
  9573. */
  9574. update(): void;
  9575. /** Releases resources */
  9576. dispose(): void;
  9577. }
  9578. }
  9579. declare module BABYLON {
  9580. interface Scene {
  9581. /**
  9582. * @hidden
  9583. * Backing field
  9584. */
  9585. _debugLayer: DebugLayer;
  9586. /**
  9587. * Gets the debug layer (aka Inspector) associated with the scene
  9588. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9589. */
  9590. debugLayer: DebugLayer;
  9591. }
  9592. /**
  9593. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9594. * what is happening in your scene
  9595. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9596. */
  9597. class DebugLayer {
  9598. /**
  9599. * Define the url to get the inspector script from.
  9600. * By default it uses the babylonjs CDN.
  9601. * @ignoreNaming
  9602. */
  9603. static InspectorURL: string;
  9604. private _scene;
  9605. private _inspector;
  9606. private BJSINSPECTOR;
  9607. /**
  9608. * Observable triggered when a property is changed through the inspector.
  9609. */
  9610. onPropertyChangedObservable: Observable<{
  9611. object: any;
  9612. property: string;
  9613. value: any;
  9614. initialValue: any;
  9615. }>;
  9616. /**
  9617. * Instantiates a new debug layer.
  9618. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9619. * what is happening in your scene
  9620. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9621. * @param scene Defines the scene to inspect
  9622. */
  9623. constructor(scene: Scene);
  9624. /** Creates the inspector window. */
  9625. private _createInspector;
  9626. /**
  9627. * Get if the inspector is visible or not.
  9628. * @returns true if visible otherwise, false
  9629. */
  9630. isVisible(): boolean;
  9631. /**
  9632. * Hide the inspector and close its window.
  9633. */
  9634. hide(): void;
  9635. /**
  9636. *
  9637. * Launch the debugLayer.
  9638. *
  9639. * initialTab:
  9640. * | Value | Tab Name |
  9641. * | --- | --- |
  9642. * | 0 | Scene |
  9643. * | 1 | Console |
  9644. * | 2 | Stats |
  9645. * | 3 | Textures |
  9646. * | 4 | Mesh |
  9647. * | 5 | Light |
  9648. * | 6 | Material |
  9649. * | 7 | GLTF |
  9650. * | 8 | GUI |
  9651. * | 9 | Physics |
  9652. * | 10 | Camera |
  9653. * | 11 | Audio |
  9654. *
  9655. * @param config Define the configuration of the inspector
  9656. */
  9657. show(config?: {
  9658. popup?: boolean;
  9659. initialTab?: number | string;
  9660. parentElement?: HTMLElement;
  9661. newColors?: {
  9662. backgroundColor?: string;
  9663. backgroundColorLighter?: string;
  9664. backgroundColorLighter2?: string;
  9665. backgroundColorLighter3?: string;
  9666. color?: string;
  9667. colorTop?: string;
  9668. colorBot?: string;
  9669. };
  9670. }): void;
  9671. /**
  9672. * Gets the active tab
  9673. * @return the index of the active tab or -1 if the inspector is hidden
  9674. */
  9675. getActiveTab(): number;
  9676. }
  9677. }
  9678. declare module BABYLON.Debug {
  9679. /**
  9680. * Used to show the physics impostor around the specific mesh
  9681. */
  9682. class PhysicsViewer {
  9683. /** @hidden */
  9684. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9685. /** @hidden */
  9686. protected _meshes: Array<Nullable<AbstractMesh>>;
  9687. /** @hidden */
  9688. protected _scene: Nullable<Scene>;
  9689. /** @hidden */
  9690. protected _numMeshes: number;
  9691. /** @hidden */
  9692. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9693. private _renderFunction;
  9694. private _debugBoxMesh;
  9695. private _debugSphereMesh;
  9696. private _debugMaterial;
  9697. /**
  9698. * Creates a new PhysicsViewer
  9699. * @param scene defines the hosting scene
  9700. */
  9701. constructor(scene: Scene);
  9702. /** @hidden */
  9703. protected _updateDebugMeshes(): void;
  9704. /**
  9705. * Renders a specified physic impostor
  9706. * @param impostor defines the impostor to render
  9707. */
  9708. showImpostor(impostor: PhysicsImpostor): void;
  9709. /**
  9710. * Hides a specified physic impostor
  9711. * @param impostor defines the impostor to hide
  9712. */
  9713. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9714. private _getDebugMaterial;
  9715. private _getDebugBoxMesh;
  9716. private _getDebugSphereMesh;
  9717. private _getDebugMesh;
  9718. /** Releases all resources */
  9719. dispose(): void;
  9720. }
  9721. }
  9722. declare module BABYLON {
  9723. /**
  9724. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9725. * in order to better appreciate the issue one might have.
  9726. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9727. */
  9728. class RayHelper {
  9729. /**
  9730. * Defines the ray we are currently tryin to visualize.
  9731. */
  9732. ray: Nullable<Ray>;
  9733. private _renderPoints;
  9734. private _renderLine;
  9735. private _renderFunction;
  9736. private _scene;
  9737. private _updateToMeshFunction;
  9738. private _attachedToMesh;
  9739. private _meshSpaceDirection;
  9740. private _meshSpaceOrigin;
  9741. /**
  9742. * Helper function to create a colored helper in a scene in one line.
  9743. * @param ray Defines the ray we are currently tryin to visualize
  9744. * @param scene Defines the scene the ray is used in
  9745. * @param color Defines the color we want to see the ray in
  9746. * @returns The newly created ray helper.
  9747. */
  9748. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9749. /**
  9750. * Instantiate a new ray helper.
  9751. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9752. * in order to better appreciate the issue one might have.
  9753. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9754. * @param ray Defines the ray we are currently tryin to visualize
  9755. */
  9756. constructor(ray: Ray);
  9757. /**
  9758. * Shows the ray we are willing to debug.
  9759. * @param scene Defines the scene the ray needs to be rendered in
  9760. * @param color Defines the color the ray needs to be rendered in
  9761. */
  9762. show(scene: Scene, color?: Color3): void;
  9763. /**
  9764. * Hides the ray we are debugging.
  9765. */
  9766. hide(): void;
  9767. private _render;
  9768. /**
  9769. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9770. * @param mesh Defines the mesh we want the helper attached to
  9771. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9772. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9773. * @param length Defines the length of the ray
  9774. */
  9775. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9776. /**
  9777. * Detach the ray helper from the mesh it has previously been attached to.
  9778. */
  9779. detachFromMesh(): void;
  9780. private _updateToMesh;
  9781. /**
  9782. * Dispose the helper and release its associated resources.
  9783. */
  9784. dispose(): void;
  9785. }
  9786. }
  9787. declare module BABYLON.Debug {
  9788. /**
  9789. * Class used to render a debug view of a given skeleton
  9790. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9791. */
  9792. class SkeletonViewer {
  9793. /** defines the skeleton to render */
  9794. skeleton: Skeleton;
  9795. /** defines the mesh attached to the skeleton */
  9796. mesh: AbstractMesh;
  9797. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9798. autoUpdateBonesMatrices: boolean;
  9799. /** defines the rendering group id to use with the viewer */
  9800. renderingGroupId: number;
  9801. /** defines an optional utility layer to render the helper on */
  9802. utilityLayerRenderer?: UtilityLayerRenderer | undefined;
  9803. /** Gets or sets the color used to render the skeleton */
  9804. color: Color3;
  9805. private _scene;
  9806. private _debugLines;
  9807. private _debugMesh;
  9808. private _isEnabled;
  9809. private _renderFunction;
  9810. /**
  9811. * Returns the mesh used to render the bones
  9812. */
  9813. readonly debugMesh: Nullable<LinesMesh>;
  9814. /**
  9815. * Creates a new SkeletonViewer
  9816. * @param skeleton defines the skeleton to render
  9817. * @param mesh defines the mesh attached to the skeleton
  9818. * @param scene defines the hosting scene
  9819. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9820. * @param renderingGroupId defines the rendering group id to use with the viewer
  9821. * @param utilityLayerRenderer defines an optional utility layer to render the helper on
  9822. */
  9823. constructor(
  9824. /** defines the skeleton to render */
  9825. skeleton: Skeleton,
  9826. /** defines the mesh attached to the skeleton */
  9827. mesh: AbstractMesh, scene: Scene,
  9828. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9829. autoUpdateBonesMatrices?: boolean,
  9830. /** defines the rendering group id to use with the viewer */
  9831. renderingGroupId?: number,
  9832. /** defines an optional utility layer to render the helper on */
  9833. utilityLayerRenderer?: UtilityLayerRenderer | undefined);
  9834. /** Gets or sets a boolean indicating if the viewer is enabled */
  9835. isEnabled: boolean;
  9836. private _getBonePosition;
  9837. private _getLinesForBonesWithLength;
  9838. private _getLinesForBonesNoLength;
  9839. /** Update the viewer to sync with current skeleton state */
  9840. update(): void;
  9841. /** Release associated resources */
  9842. dispose(): void;
  9843. }
  9844. }
  9845. declare module BABYLON {
  9846. /**
  9847. * Interface for attribute information associated with buffer instanciation
  9848. */
  9849. class InstancingAttributeInfo {
  9850. /**
  9851. * Index/offset of the attribute in the vertex shader
  9852. */
  9853. index: number;
  9854. /**
  9855. * size of the attribute, 1, 2, 3 or 4
  9856. */
  9857. attributeSize: number;
  9858. /**
  9859. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9860. * default is FLOAT
  9861. */
  9862. attribyteType: number;
  9863. /**
  9864. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9865. */
  9866. normalized: boolean;
  9867. /**
  9868. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9869. */
  9870. offset: number;
  9871. /**
  9872. * Name of the GLSL attribute, for debugging purpose only
  9873. */
  9874. attributeName: string;
  9875. }
  9876. /**
  9877. * Define options used to create a render target texture
  9878. */
  9879. class RenderTargetCreationOptions {
  9880. /**
  9881. * Specifies is mipmaps must be generated
  9882. */
  9883. generateMipMaps?: boolean;
  9884. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9885. generateDepthBuffer?: boolean;
  9886. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9887. generateStencilBuffer?: boolean;
  9888. /** Defines texture type (int by default) */
  9889. type?: number;
  9890. /** Defines sampling mode (trilinear by default) */
  9891. samplingMode?: number;
  9892. /** Defines format (RGBA by default) */
  9893. format?: number;
  9894. }
  9895. /**
  9896. * Define options used to create a depth texture
  9897. */
  9898. class DepthTextureCreationOptions {
  9899. /** Specifies whether or not a stencil should be allocated in the texture */
  9900. generateStencil?: boolean;
  9901. /** Specifies whether or not bilinear filtering is enable on the texture */
  9902. bilinearFiltering?: boolean;
  9903. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9904. comparisonFunction?: number;
  9905. /** Specifies if the created texture is a cube texture */
  9906. isCube?: boolean;
  9907. }
  9908. /**
  9909. * Class used to describe the capabilities of the engine relatively to the current browser
  9910. */
  9911. class EngineCapabilities {
  9912. /** Maximum textures units per fragment shader */
  9913. maxTexturesImageUnits: number;
  9914. /** Maximum texture units per vertex shader */
  9915. maxVertexTextureImageUnits: number;
  9916. /** Maximum textures units in the entire pipeline */
  9917. maxCombinedTexturesImageUnits: number;
  9918. /** Maximum texture size */
  9919. maxTextureSize: number;
  9920. /** Maximum cube texture size */
  9921. maxCubemapTextureSize: number;
  9922. /** Maximum render texture size */
  9923. maxRenderTextureSize: number;
  9924. /** Maximum number of vertex attributes */
  9925. maxVertexAttribs: number;
  9926. /** Maximum number of varyings */
  9927. maxVaryingVectors: number;
  9928. /** Maximum number of uniforms per vertex shader */
  9929. maxVertexUniformVectors: number;
  9930. /** Maximum number of uniforms per fragment shader */
  9931. maxFragmentUniformVectors: number;
  9932. /** Defines if standard derivates (dx/dy) are supported */
  9933. standardDerivatives: boolean;
  9934. /** Defines if s3tc texture compression is supported */
  9935. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9936. /** Defines if pvrtc texture compression is supported */
  9937. pvrtc: any;
  9938. /** Defines if etc1 texture compression is supported */
  9939. etc1: any;
  9940. /** Defines if etc2 texture compression is supported */
  9941. etc2: any;
  9942. /** Defines if astc texture compression is supported */
  9943. astc: any;
  9944. /** Defines if float textures are supported */
  9945. textureFloat: boolean;
  9946. /** Defines if vertex array objects are supported */
  9947. vertexArrayObject: boolean;
  9948. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9949. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9950. /** Gets the maximum level of anisotropy supported */
  9951. maxAnisotropy: number;
  9952. /** Defines if instancing is supported */
  9953. instancedArrays: boolean;
  9954. /** Defines if 32 bits indices are supported */
  9955. uintIndices: boolean;
  9956. /** Defines if high precision shaders are supported */
  9957. highPrecisionShaderSupported: boolean;
  9958. /** Defines if depth reading in the fragment shader is supported */
  9959. fragmentDepthSupported: boolean;
  9960. /** Defines if float texture linear filtering is supported*/
  9961. textureFloatLinearFiltering: boolean;
  9962. /** Defines if rendering to float textures is supported */
  9963. textureFloatRender: boolean;
  9964. /** Defines if half float textures are supported*/
  9965. textureHalfFloat: boolean;
  9966. /** Defines if half float texture linear filtering is supported*/
  9967. textureHalfFloatLinearFiltering: boolean;
  9968. /** Defines if rendering to half float textures is supported */
  9969. textureHalfFloatRender: boolean;
  9970. /** Defines if textureLOD shader command is supported */
  9971. textureLOD: boolean;
  9972. /** Defines if draw buffers extension is supported */
  9973. drawBuffersExtension: boolean;
  9974. /** Defines if depth textures are supported */
  9975. depthTextureExtension: boolean;
  9976. /** Defines if float color buffer are supported */
  9977. colorBufferFloat: boolean;
  9978. /** Gets disjoint timer query extension (null if not supported) */
  9979. timerQuery: EXT_disjoint_timer_query;
  9980. /** Defines if timestamp can be used with timer query */
  9981. canUseTimestampForTimerQuery: boolean;
  9982. /** Function used to let the system compiles shaders in background */
  9983. parallelShaderCompile: {
  9984. MAX_SHADER_COMPILER_THREADS_KHR: number;
  9985. maxShaderCompilerThreadsKHR: (thread: number) => void;
  9986. COMPLETION_STATUS_KHR: number;
  9987. };
  9988. }
  9989. /** Interface defining initialization parameters for Engine class */
  9990. interface EngineOptions extends WebGLContextAttributes {
  9991. /**
  9992. * Defines if the engine should no exceed a specified device ratio
  9993. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9994. */
  9995. limitDeviceRatio?: number;
  9996. /**
  9997. * Defines if webvr should be enabled automatically
  9998. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9999. */
  10000. autoEnableWebVR?: boolean;
  10001. /**
  10002. * Defines if webgl2 should be turned off even if supported
  10003. * @see http://doc.babylonjs.com/features/webgl2
  10004. */
  10005. disableWebGL2Support?: boolean;
  10006. /**
  10007. * Defines if webaudio should be initialized as well
  10008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10009. */
  10010. audioEngine?: boolean;
  10011. /**
  10012. * Defines if animations should run using a deterministic lock step
  10013. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10014. */
  10015. deterministicLockstep?: boolean;
  10016. /** Defines the maximum steps to use with deterministic lock step mode */
  10017. lockstepMaxSteps?: number;
  10018. /**
  10019. * Defines that engine should ignore context lost events
  10020. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10021. */
  10022. doNotHandleContextLost?: boolean;
  10023. }
  10024. /**
  10025. * Defines the interface used by display changed events
  10026. */
  10027. interface IDisplayChangedEventArgs {
  10028. /** Gets the vrDisplay object (if any) */
  10029. vrDisplay: Nullable<any>;
  10030. /** Gets a boolean indicating if webVR is supported */
  10031. vrSupported: boolean;
  10032. }
  10033. /**
  10034. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10035. */
  10036. class Engine {
  10037. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10038. static ExceptionList: ({
  10039. key: string;
  10040. capture: string;
  10041. captureConstraint: number;
  10042. targets: string[];
  10043. } | {
  10044. key: string;
  10045. capture: null;
  10046. captureConstraint: null;
  10047. targets: string[];
  10048. })[];
  10049. /** Gets the list of created engines */
  10050. static Instances: Engine[];
  10051. /**
  10052. * Gets the latest created engine
  10053. */
  10054. static readonly LastCreatedEngine: Nullable<Engine>;
  10055. /**
  10056. * Gets the latest created scene
  10057. */
  10058. static readonly LastCreatedScene: Nullable<Scene>;
  10059. /**
  10060. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10061. * @param flag defines which part of the materials must be marked as dirty
  10062. * @param predicate defines a predicate used to filter which materials should be affected
  10063. */
  10064. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10065. /**
  10066. * Hidden
  10067. */
  10068. static _TextureLoaders: IInternalTextureLoader[];
  10069. /** Defines that alpha blending is disabled */
  10070. static readonly ALPHA_DISABLE: number;
  10071. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10072. static readonly ALPHA_ADD: number;
  10073. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10074. static readonly ALPHA_COMBINE: number;
  10075. /** Defines that alpha blending to DEST - SRC * DEST */
  10076. static readonly ALPHA_SUBTRACT: number;
  10077. /** Defines that alpha blending to SRC * DEST */
  10078. static readonly ALPHA_MULTIPLY: number;
  10079. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10080. static readonly ALPHA_MAXIMIZED: number;
  10081. /** Defines that alpha blending to SRC + DEST */
  10082. static readonly ALPHA_ONEONE: number;
  10083. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10084. static readonly ALPHA_PREMULTIPLIED: number;
  10085. /**
  10086. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10087. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10088. */
  10089. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10090. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10091. static readonly ALPHA_INTERPOLATE: number;
  10092. /**
  10093. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10094. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10095. */
  10096. static readonly ALPHA_SCREENMODE: number;
  10097. /** Defines that the ressource is not delayed*/
  10098. static readonly DELAYLOADSTATE_NONE: number;
  10099. /** Defines that the ressource was successfully delay loaded */
  10100. static readonly DELAYLOADSTATE_LOADED: number;
  10101. /** Defines that the ressource is currently delay loading */
  10102. static readonly DELAYLOADSTATE_LOADING: number;
  10103. /** Defines that the ressource is delayed and has not started loading */
  10104. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10105. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10106. static readonly NEVER: number;
  10107. /** 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 */
  10108. static readonly ALWAYS: number;
  10109. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10110. static readonly LESS: number;
  10111. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10112. static readonly EQUAL: number;
  10113. /** 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 */
  10114. static readonly LEQUAL: number;
  10115. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10116. static readonly GREATER: number;
  10117. /** 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 */
  10118. static readonly GEQUAL: number;
  10119. /** 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 */
  10120. static readonly NOTEQUAL: number;
  10121. /** Passed to stencilOperation to specify that stencil value must be kept */
  10122. static readonly KEEP: number;
  10123. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10124. static readonly REPLACE: number;
  10125. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10126. static readonly INCR: number;
  10127. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10128. static readonly DECR: number;
  10129. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10130. static readonly INVERT: number;
  10131. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10132. static readonly INCR_WRAP: number;
  10133. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10134. static readonly DECR_WRAP: number;
  10135. /** Texture is not repeating outside of 0..1 UVs */
  10136. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10137. /** Texture is repeating outside of 0..1 UVs */
  10138. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10139. /** Texture is repeating and mirrored */
  10140. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10141. /** ALPHA */
  10142. static readonly TEXTUREFORMAT_ALPHA: number;
  10143. /** LUMINANCE */
  10144. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10145. /** LUMINANCE_ALPHA */
  10146. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10147. /** RGB */
  10148. static readonly TEXTUREFORMAT_RGB: number;
  10149. /** RGBA */
  10150. static readonly TEXTUREFORMAT_RGBA: number;
  10151. /** RED */
  10152. static readonly TEXTUREFORMAT_RED: number;
  10153. /** RED (2nd reference) */
  10154. static readonly TEXTUREFORMAT_R: number;
  10155. /** RG */
  10156. static readonly TEXTUREFORMAT_RG: number;
  10157. /** RED_INTEGER */
  10158. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10159. /** RED_INTEGER (2nd reference) */
  10160. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10161. /** RG_INTEGER */
  10162. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10163. /** RGB_INTEGER */
  10164. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10165. /** RGBA_INTEGER */
  10166. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10167. /** UNSIGNED_BYTE */
  10168. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10169. /** UNSIGNED_BYTE (2nd reference) */
  10170. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10171. /** FLOAT */
  10172. static readonly TEXTURETYPE_FLOAT: number;
  10173. /** HALF_FLOAT */
  10174. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10175. /** BYTE */
  10176. static readonly TEXTURETYPE_BYTE: number;
  10177. /** SHORT */
  10178. static readonly TEXTURETYPE_SHORT: number;
  10179. /** UNSIGNED_SHORT */
  10180. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10181. /** INT */
  10182. static readonly TEXTURETYPE_INT: number;
  10183. /** UNSIGNED_INT */
  10184. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10185. /** UNSIGNED_SHORT_4_4_4_4 */
  10186. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10187. /** UNSIGNED_SHORT_5_5_5_1 */
  10188. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10189. /** UNSIGNED_SHORT_5_6_5 */
  10190. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10191. /** UNSIGNED_INT_2_10_10_10_REV */
  10192. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10193. /** UNSIGNED_INT_24_8 */
  10194. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10195. /** UNSIGNED_INT_10F_11F_11F_REV */
  10196. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10197. /** UNSIGNED_INT_5_9_9_9_REV */
  10198. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10199. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10200. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10201. /** nearest is mag = nearest and min = nearest and mip = linear */
  10202. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10203. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10204. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10205. /** Trilinear is mag = linear and min = linear and mip = linear */
  10206. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10207. /** nearest is mag = nearest and min = nearest and mip = linear */
  10208. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10209. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10210. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10211. /** Trilinear is mag = linear and min = linear and mip = linear */
  10212. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10213. /** mag = nearest and min = nearest and mip = nearest */
  10214. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10215. /** mag = nearest and min = linear and mip = nearest */
  10216. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10217. /** mag = nearest and min = linear and mip = linear */
  10218. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10219. /** mag = nearest and min = linear and mip = none */
  10220. static readonly TEXTURE_NEAREST_LINEAR: number;
  10221. /** mag = nearest and min = nearest and mip = none */
  10222. static readonly TEXTURE_NEAREST_NEAREST: number;
  10223. /** mag = linear and min = nearest and mip = nearest */
  10224. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10225. /** mag = linear and min = nearest and mip = linear */
  10226. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10227. /** mag = linear and min = linear and mip = none */
  10228. static readonly TEXTURE_LINEAR_LINEAR: number;
  10229. /** mag = linear and min = nearest and mip = none */
  10230. static readonly TEXTURE_LINEAR_NEAREST: number;
  10231. /** Explicit coordinates mode */
  10232. static readonly TEXTURE_EXPLICIT_MODE: number;
  10233. /** Spherical coordinates mode */
  10234. static readonly TEXTURE_SPHERICAL_MODE: number;
  10235. /** Planar coordinates mode */
  10236. static readonly TEXTURE_PLANAR_MODE: number;
  10237. /** Cubic coordinates mode */
  10238. static readonly TEXTURE_CUBIC_MODE: number;
  10239. /** Projection coordinates mode */
  10240. static readonly TEXTURE_PROJECTION_MODE: number;
  10241. /** Skybox coordinates mode */
  10242. static readonly TEXTURE_SKYBOX_MODE: number;
  10243. /** Inverse Cubic coordinates mode */
  10244. static readonly TEXTURE_INVCUBIC_MODE: number;
  10245. /** Equirectangular coordinates mode */
  10246. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10247. /** Equirectangular Fixed coordinates mode */
  10248. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10249. /** Equirectangular Fixed Mirrored coordinates mode */
  10250. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10251. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10252. static readonly SCALEMODE_FLOOR: number;
  10253. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10254. static readonly SCALEMODE_NEAREST: number;
  10255. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10256. static readonly SCALEMODE_CEILING: number;
  10257. /**
  10258. * Returns the current version of the framework
  10259. */
  10260. static readonly Version: string;
  10261. /**
  10262. * Returns a string describing the current engine
  10263. */
  10264. readonly description: string;
  10265. /**
  10266. * Gets or sets the epsilon value used by collision engine
  10267. */
  10268. static CollisionsEpsilon: number;
  10269. /**
  10270. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10271. */
  10272. static CodeRepository: string;
  10273. /**
  10274. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10275. */
  10276. static ShadersRepository: string;
  10277. /**
  10278. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10279. */
  10280. forcePOTTextures: boolean;
  10281. /**
  10282. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10283. */
  10284. isFullscreen: boolean;
  10285. /**
  10286. * Gets a boolean indicating if the pointer is currently locked
  10287. */
  10288. isPointerLock: boolean;
  10289. /**
  10290. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10291. */
  10292. cullBackFaces: boolean;
  10293. /**
  10294. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10295. */
  10296. renderEvenInBackground: boolean;
  10297. /**
  10298. * Gets or sets a boolean indicating that cache can be kept between frames
  10299. */
  10300. preventCacheWipeBetweenFrames: boolean;
  10301. /**
  10302. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10303. **/
  10304. enableOfflineSupport: boolean;
  10305. /**
  10306. * 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)
  10307. **/
  10308. disableManifestCheck: boolean;
  10309. /**
  10310. * Gets the list of created scenes
  10311. */
  10312. scenes: Scene[];
  10313. /**
  10314. * Event raised when a new scene is created
  10315. */
  10316. onNewSceneAddedObservable: Observable<Scene>;
  10317. /**
  10318. * Gets the list of created postprocesses
  10319. */
  10320. postProcesses: PostProcess[];
  10321. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10322. validateShaderPrograms: boolean;
  10323. /**
  10324. * Observable event triggered each time the rendering canvas is resized
  10325. */
  10326. onResizeObservable: Observable<Engine>;
  10327. /**
  10328. * Observable event triggered each time the canvas loses focus
  10329. */
  10330. onCanvasBlurObservable: Observable<Engine>;
  10331. /**
  10332. * Observable event triggered each time the canvas gains focus
  10333. */
  10334. onCanvasFocusObservable: Observable<Engine>;
  10335. /**
  10336. * Observable event triggered each time the canvas receives pointerout event
  10337. */
  10338. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10339. /**
  10340. * Observable event triggered before each texture is initialized
  10341. */
  10342. onBeforeTextureInitObservable: Observable<Texture>;
  10343. private _vrDisplay;
  10344. private _vrSupported;
  10345. private _oldSize;
  10346. private _oldHardwareScaleFactor;
  10347. private _vrExclusivePointerMode;
  10348. private _webVRInitPromise;
  10349. /**
  10350. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10351. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10352. */
  10353. readonly isInVRExclusivePointerMode: boolean;
  10354. /**
  10355. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10356. */
  10357. disableUniformBuffers: boolean;
  10358. /** @hidden */
  10359. _uniformBuffers: UniformBuffer[];
  10360. /**
  10361. * Gets a boolean indicating that the engine supports uniform buffers
  10362. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10363. */
  10364. readonly supportsUniformBuffers: boolean;
  10365. /**
  10366. * Observable raised when the engine begins a new frame
  10367. */
  10368. onBeginFrameObservable: Observable<Engine>;
  10369. /**
  10370. * If set, will be used to request the next animation frame for the render loop
  10371. */
  10372. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10373. /**
  10374. * Observable raised when the engine ends the current frame
  10375. */
  10376. onEndFrameObservable: Observable<Engine>;
  10377. /**
  10378. * Observable raised when the engine is about to compile a shader
  10379. */
  10380. onBeforeShaderCompilationObservable: Observable<Engine>;
  10381. /**
  10382. * Observable raised when the engine has jsut compiled a shader
  10383. */
  10384. onAfterShaderCompilationObservable: Observable<Engine>;
  10385. /** @hidden */
  10386. _gl: WebGLRenderingContext;
  10387. private _renderingCanvas;
  10388. private _windowIsBackground;
  10389. private _webGLVersion;
  10390. /**
  10391. * Gets a boolean indicating that only power of 2 textures are supported
  10392. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10393. */
  10394. readonly needPOTTextures: boolean;
  10395. /** @hidden */
  10396. _badOS: boolean;
  10397. /** @hidden */
  10398. _badDesktopOS: boolean;
  10399. /**
  10400. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10401. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10402. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10403. */
  10404. disableTextureBindingOptimization: boolean;
  10405. /**
  10406. * Gets the audio engine
  10407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10408. * @ignorenaming
  10409. */
  10410. static audioEngine: IAudioEngine;
  10411. /**
  10412. * Default AudioEngine factory responsible of creating the Audio Engine.
  10413. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10414. */
  10415. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10416. /**
  10417. * Default offline support factory responsible of creating a tool used to store data locally.
  10418. * By default, this will create a Database object if the workload has been embedded.
  10419. */
  10420. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10421. private _onFocus;
  10422. private _onBlur;
  10423. private _onCanvasPointerOut;
  10424. private _onCanvasBlur;
  10425. private _onCanvasFocus;
  10426. private _onFullscreenChange;
  10427. private _onPointerLockChange;
  10428. private _onVRDisplayPointerRestricted;
  10429. private _onVRDisplayPointerUnrestricted;
  10430. private _onVrDisplayConnect;
  10431. private _onVrDisplayDisconnect;
  10432. private _onVrDisplayPresentChange;
  10433. /**
  10434. * Observable signaled when VR display mode changes
  10435. */
  10436. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10437. /**
  10438. * Observable signaled when VR request present is complete
  10439. */
  10440. onVRRequestPresentComplete: Observable<boolean>;
  10441. /**
  10442. * Observable signaled when VR request present starts
  10443. */
  10444. onVRRequestPresentStart: Observable<Engine>;
  10445. private _hardwareScalingLevel;
  10446. /** @hidden */
  10447. protected _caps: EngineCapabilities;
  10448. private _pointerLockRequested;
  10449. private _isStencilEnable;
  10450. private _colorWrite;
  10451. private _loadingScreen;
  10452. /** @hidden */
  10453. _drawCalls: PerfCounter;
  10454. /** @hidden */
  10455. _textureCollisions: PerfCounter;
  10456. private _glVersion;
  10457. private _glRenderer;
  10458. private _glVendor;
  10459. private _videoTextureSupported;
  10460. private _renderingQueueLaunched;
  10461. private _activeRenderLoops;
  10462. private _deterministicLockstep;
  10463. private _lockstepMaxSteps;
  10464. /**
  10465. * Observable signaled when a context lost event is raised
  10466. */
  10467. onContextLostObservable: Observable<Engine>;
  10468. /**
  10469. * Observable signaled when a context restored event is raised
  10470. */
  10471. onContextRestoredObservable: Observable<Engine>;
  10472. private _onContextLost;
  10473. private _onContextRestored;
  10474. private _contextWasLost;
  10475. private _doNotHandleContextLost;
  10476. /**
  10477. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10479. */
  10480. doNotHandleContextLost: boolean;
  10481. private _performanceMonitor;
  10482. private _fps;
  10483. private _deltaTime;
  10484. /**
  10485. * Turn this value on if you want to pause FPS computation when in background
  10486. */
  10487. disablePerformanceMonitorInBackground: boolean;
  10488. /**
  10489. * Gets the performance monitor attached to this engine
  10490. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10491. */
  10492. readonly performanceMonitor: PerformanceMonitor;
  10493. /** @hidden */
  10494. protected _depthCullingState: _DepthCullingState;
  10495. /** @hidden */
  10496. protected _stencilState: _StencilState;
  10497. /** @hidden */
  10498. protected _alphaState: _AlphaState;
  10499. /** @hidden */
  10500. protected _alphaMode: number;
  10501. protected _internalTexturesCache: InternalTexture[];
  10502. /** @hidden */
  10503. protected _activeChannel: number;
  10504. private _currentTextureChannel;
  10505. /** @hidden */
  10506. protected _boundTexturesCache: {
  10507. [key: string]: Nullable<InternalTexture>;
  10508. };
  10509. /** @hidden */
  10510. protected _currentEffect: Nullable<Effect>;
  10511. /** @hidden */
  10512. protected _currentProgram: Nullable<WebGLProgram>;
  10513. private _compiledEffects;
  10514. private _vertexAttribArraysEnabled;
  10515. /** @hidden */
  10516. protected _cachedViewport: Nullable<Viewport>;
  10517. private _cachedVertexArrayObject;
  10518. /** @hidden */
  10519. protected _cachedVertexBuffers: any;
  10520. /** @hidden */
  10521. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10522. /** @hidden */
  10523. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10524. /** @hidden */
  10525. protected _currentRenderTarget: Nullable<InternalTexture>;
  10526. private _uintIndicesCurrentlySet;
  10527. private _currentBoundBuffer;
  10528. /** @hidden */
  10529. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10530. private _currentBufferPointers;
  10531. private _currentInstanceLocations;
  10532. private _currentInstanceBuffers;
  10533. private _textureUnits;
  10534. private _firstBoundInternalTextureTracker;
  10535. private _lastBoundInternalTextureTracker;
  10536. private _workingCanvas;
  10537. private _workingContext;
  10538. private _rescalePostProcess;
  10539. private _dummyFramebuffer;
  10540. private _externalData;
  10541. private _bindedRenderFunction;
  10542. private _vaoRecordInProgress;
  10543. private _mustWipeVertexAttributes;
  10544. private _emptyTexture;
  10545. private _emptyCubeTexture;
  10546. private _emptyTexture3D;
  10547. /** @hidden */
  10548. _frameHandler: number;
  10549. private _nextFreeTextureSlots;
  10550. private _maxSimultaneousTextures;
  10551. private _activeRequests;
  10552. private _texturesSupported;
  10553. private _textureFormatInUse;
  10554. /**
  10555. * Gets the list of texture formats supported
  10556. */
  10557. readonly texturesSupported: Array<string>;
  10558. /**
  10559. * Gets the list of texture formats in use
  10560. */
  10561. readonly textureFormatInUse: Nullable<string>;
  10562. /**
  10563. * Gets the current viewport
  10564. */
  10565. readonly currentViewport: Nullable<Viewport>;
  10566. /**
  10567. * Gets the default empty texture
  10568. */
  10569. readonly emptyTexture: InternalTexture;
  10570. /**
  10571. * Gets the default empty 3D texture
  10572. */
  10573. readonly emptyTexture3D: InternalTexture;
  10574. /**
  10575. * Gets the default empty cube texture
  10576. */
  10577. readonly emptyCubeTexture: InternalTexture;
  10578. /**
  10579. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10580. */
  10581. readonly premultipliedAlpha: boolean;
  10582. /**
  10583. * Creates a new engine
  10584. * @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
  10585. * @param antialias defines enable antialiasing (default: false)
  10586. * @param options defines further options to be sent to the getContext() function
  10587. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10588. */
  10589. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10590. private _rebuildInternalTextures;
  10591. private _rebuildEffects;
  10592. /**
  10593. * Gets a boolean indicating if all created effects are ready
  10594. * @returns true if all effects are ready
  10595. */
  10596. areAllEffectsReady(): boolean;
  10597. private _rebuildBuffers;
  10598. private _initGLContext;
  10599. /**
  10600. * Gets version of the current webGL context
  10601. */
  10602. readonly webGLVersion: number;
  10603. /**
  10604. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10605. */
  10606. readonly isStencilEnable: boolean;
  10607. private _prepareWorkingCanvas;
  10608. /**
  10609. * Reset the texture cache to empty state
  10610. */
  10611. resetTextureCache(): void;
  10612. /**
  10613. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10614. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10615. * @returns true if engine is in deterministic lock step mode
  10616. */
  10617. isDeterministicLockStep(): boolean;
  10618. /**
  10619. * Gets the max steps when engine is running in deterministic lock step
  10620. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10621. * @returns the max steps
  10622. */
  10623. getLockstepMaxSteps(): number;
  10624. /**
  10625. * Gets an object containing information about the current webGL context
  10626. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10627. */
  10628. getGlInfo(): {
  10629. vendor: string;
  10630. renderer: string;
  10631. version: string;
  10632. };
  10633. /**
  10634. * Gets current aspect ratio
  10635. * @param camera defines the camera to use to get the aspect ratio
  10636. * @param useScreen defines if screen size must be used (or the current render target if any)
  10637. * @returns a number defining the aspect ratio
  10638. */
  10639. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10640. /**
  10641. * Gets current screen aspect ratio
  10642. * @returns a number defining the aspect ratio
  10643. */
  10644. getScreenAspectRatio(): number;
  10645. /**
  10646. * Gets the current render width
  10647. * @param useScreen defines if screen size must be used (or the current render target if any)
  10648. * @returns a number defining the current render width
  10649. */
  10650. getRenderWidth(useScreen?: boolean): number;
  10651. /**
  10652. * Gets the current render height
  10653. * @param useScreen defines if screen size must be used (or the current render target if any)
  10654. * @returns a number defining the current render height
  10655. */
  10656. getRenderHeight(useScreen?: boolean): number;
  10657. /**
  10658. * Gets the HTML canvas attached with the current webGL context
  10659. * @returns a HTML canvas
  10660. */
  10661. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10662. /**
  10663. * Gets the client rect of the HTML canvas attached with the current webGL context
  10664. * @returns a client rectanglee
  10665. */
  10666. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10667. /**
  10668. * Defines the hardware scaling level.
  10669. * By default the hardware scaling level is computed from the window device ratio.
  10670. * 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.
  10671. * @param level defines the level to use
  10672. */
  10673. setHardwareScalingLevel(level: number): void;
  10674. /**
  10675. * Gets the current hardware scaling level.
  10676. * By default the hardware scaling level is computed from the window device ratio.
  10677. * 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.
  10678. * @returns a number indicating the current hardware scaling level
  10679. */
  10680. getHardwareScalingLevel(): number;
  10681. /**
  10682. * Gets the list of loaded textures
  10683. * @returns an array containing all loaded textures
  10684. */
  10685. getLoadedTexturesCache(): InternalTexture[];
  10686. /**
  10687. * Gets the object containing all engine capabilities
  10688. * @returns the EngineCapabilities object
  10689. */
  10690. getCaps(): EngineCapabilities;
  10691. /**
  10692. * Gets the current depth function
  10693. * @returns a number defining the depth function
  10694. */
  10695. getDepthFunction(): Nullable<number>;
  10696. /**
  10697. * Sets the current depth function
  10698. * @param depthFunc defines the function to use
  10699. */
  10700. setDepthFunction(depthFunc: number): void;
  10701. /**
  10702. * Sets the current depth function to GREATER
  10703. */
  10704. setDepthFunctionToGreater(): void;
  10705. /**
  10706. * Sets the current depth function to GEQUAL
  10707. */
  10708. setDepthFunctionToGreaterOrEqual(): void;
  10709. /**
  10710. * Sets the current depth function to LESS
  10711. */
  10712. setDepthFunctionToLess(): void;
  10713. /**
  10714. * Sets the current depth function to LEQUAL
  10715. */
  10716. setDepthFunctionToLessOrEqual(): void;
  10717. /**
  10718. * Gets a boolean indicating if stencil buffer is enabled
  10719. * @returns the current stencil buffer state
  10720. */
  10721. getStencilBuffer(): boolean;
  10722. /**
  10723. * Enable or disable the stencil buffer
  10724. * @param enable defines if the stencil buffer must be enabled or disabled
  10725. */
  10726. setStencilBuffer(enable: boolean): void;
  10727. /**
  10728. * Gets the current stencil mask
  10729. * @returns a number defining the new stencil mask to use
  10730. */
  10731. getStencilMask(): number;
  10732. /**
  10733. * Sets the current stencil mask
  10734. * @param mask defines the new stencil mask to use
  10735. */
  10736. setStencilMask(mask: number): void;
  10737. /**
  10738. * Gets the current stencil function
  10739. * @returns a number defining the stencil function to use
  10740. */
  10741. getStencilFunction(): number;
  10742. /**
  10743. * Gets the current stencil reference value
  10744. * @returns a number defining the stencil reference value to use
  10745. */
  10746. getStencilFunctionReference(): number;
  10747. /**
  10748. * Gets the current stencil mask
  10749. * @returns a number defining the stencil mask to use
  10750. */
  10751. getStencilFunctionMask(): number;
  10752. /**
  10753. * Sets the current stencil function
  10754. * @param stencilFunc defines the new stencil function to use
  10755. */
  10756. setStencilFunction(stencilFunc: number): void;
  10757. /**
  10758. * Sets the current stencil reference
  10759. * @param reference defines the new stencil reference to use
  10760. */
  10761. setStencilFunctionReference(reference: number): void;
  10762. /**
  10763. * Sets the current stencil mask
  10764. * @param mask defines the new stencil mask to use
  10765. */
  10766. setStencilFunctionMask(mask: number): void;
  10767. /**
  10768. * Gets the current stencil operation when stencil fails
  10769. * @returns a number defining stencil operation to use when stencil fails
  10770. */
  10771. getStencilOperationFail(): number;
  10772. /**
  10773. * Gets the current stencil operation when depth fails
  10774. * @returns a number defining stencil operation to use when depth fails
  10775. */
  10776. getStencilOperationDepthFail(): number;
  10777. /**
  10778. * Gets the current stencil operation when stencil passes
  10779. * @returns a number defining stencil operation to use when stencil passes
  10780. */
  10781. getStencilOperationPass(): number;
  10782. /**
  10783. * Sets the stencil operation to use when stencil fails
  10784. * @param operation defines the stencil operation to use when stencil fails
  10785. */
  10786. setStencilOperationFail(operation: number): void;
  10787. /**
  10788. * Sets the stencil operation to use when depth fails
  10789. * @param operation defines the stencil operation to use when depth fails
  10790. */
  10791. setStencilOperationDepthFail(operation: number): void;
  10792. /**
  10793. * Sets the stencil operation to use when stencil passes
  10794. * @param operation defines the stencil operation to use when stencil passes
  10795. */
  10796. setStencilOperationPass(operation: number): void;
  10797. /**
  10798. * Sets a boolean indicating if the dithering state is enabled or disabled
  10799. * @param value defines the dithering state
  10800. */
  10801. setDitheringState(value: boolean): void;
  10802. /**
  10803. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10804. * @param value defines the rasterizer state
  10805. */
  10806. setRasterizerState(value: boolean): void;
  10807. /**
  10808. * stop executing a render loop function and remove it from the execution array
  10809. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10810. */
  10811. stopRenderLoop(renderFunction?: () => void): void;
  10812. /** @hidden */
  10813. _renderLoop(): void;
  10814. /**
  10815. * Register and execute a render loop. The engine can have more than one render function
  10816. * @param renderFunction defines the function to continuously execute
  10817. */
  10818. runRenderLoop(renderFunction: () => void): void;
  10819. /**
  10820. * Toggle full screen mode
  10821. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10822. */
  10823. switchFullscreen(requestPointerLock: boolean): void;
  10824. /**
  10825. * Clear the current render buffer or the current render target (if any is set up)
  10826. * @param color defines the color to use
  10827. * @param backBuffer defines if the back buffer must be cleared
  10828. * @param depth defines if the depth buffer must be cleared
  10829. * @param stencil defines if the stencil buffer must be cleared
  10830. */
  10831. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10832. /**
  10833. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10834. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10835. * @param y defines the y-coordinate of the corner of the clear rectangle
  10836. * @param width defines the width of the clear rectangle
  10837. * @param height defines the height of the clear rectangle
  10838. * @param clearColor defines the clear color
  10839. */
  10840. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10841. private _viewportCached;
  10842. /** @hidden */
  10843. _viewport(x: number, y: number, width: number, height: number): void;
  10844. /**
  10845. * Set the WebGL's viewport
  10846. * @param viewport defines the viewport element to be used
  10847. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10848. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10849. */
  10850. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10851. /**
  10852. * Directly set the WebGL Viewport
  10853. * @param x defines the x coordinate of the viewport (in screen space)
  10854. * @param y defines the y coordinate of the viewport (in screen space)
  10855. * @param width defines the width of the viewport (in screen space)
  10856. * @param height defines the height of the viewport (in screen space)
  10857. * @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
  10858. */
  10859. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10860. /**
  10861. * Begin a new frame
  10862. */
  10863. beginFrame(): void;
  10864. /**
  10865. * Enf the current frame
  10866. */
  10867. endFrame(): void;
  10868. /**
  10869. * Resize the view according to the canvas' size
  10870. */
  10871. resize(): void;
  10872. /**
  10873. * Force a specific size of the canvas
  10874. * @param width defines the new canvas' width
  10875. * @param height defines the new canvas' height
  10876. */
  10877. setSize(width: number, height: number): void;
  10878. /**
  10879. * Gets a boolean indicating if a webVR device was detected
  10880. * @returns true if a webVR device was detected
  10881. */
  10882. isVRDevicePresent(): boolean;
  10883. /**
  10884. * Gets the current webVR device
  10885. * @returns the current webVR device (or null)
  10886. */
  10887. getVRDevice(): any;
  10888. /**
  10889. * Initializes a webVR display and starts listening to display change events
  10890. * The onVRDisplayChangedObservable will be notified upon these changes
  10891. * @returns The onVRDisplayChangedObservable
  10892. */
  10893. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10894. /**
  10895. * Initializes a webVR display and starts listening to display change events
  10896. * The onVRDisplayChangedObservable will be notified upon these changes
  10897. * @returns A promise containing a VRDisplay and if vr is supported
  10898. */
  10899. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10900. /**
  10901. * Call this function to switch to webVR mode
  10902. * Will do nothing if webVR is not supported or if there is no webVR device
  10903. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10904. */
  10905. enableVR(): void;
  10906. /**
  10907. * Call this function to leave webVR mode
  10908. * Will do nothing if webVR is not supported or if there is no webVR device
  10909. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10910. */
  10911. disableVR(): void;
  10912. private _onVRFullScreenTriggered;
  10913. private _getVRDisplaysAsync;
  10914. /**
  10915. * Binds the frame buffer to the specified texture.
  10916. * @param texture The texture to render to or null for the default canvas
  10917. * @param faceIndex The face of the texture to render to in case of cube texture
  10918. * @param requiredWidth The width of the target to render to
  10919. * @param requiredHeight The height of the target to render to
  10920. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10921. * @param depthStencilTexture The depth stencil texture to use to render
  10922. * @param lodLevel defines le lod level to bind to the frame buffer
  10923. */
  10924. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10925. private bindUnboundFramebuffer;
  10926. /**
  10927. * Unbind the current render target texture from the webGL context
  10928. * @param texture defines the render target texture to unbind
  10929. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10930. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10931. */
  10932. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10933. /**
  10934. * Unbind a list of render target textures from the webGL context
  10935. * This is used only when drawBuffer extension or webGL2 are active
  10936. * @param textures defines the render target textures to unbind
  10937. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10938. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10939. */
  10940. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10941. /**
  10942. * Force the mipmap generation for the given render target texture
  10943. * @param texture defines the render target texture to use
  10944. */
  10945. generateMipMapsForCubemap(texture: InternalTexture): void;
  10946. /**
  10947. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10948. */
  10949. flushFramebuffer(): void;
  10950. /**
  10951. * Unbind the current render target and bind the default framebuffer
  10952. */
  10953. restoreDefaultFramebuffer(): void;
  10954. /**
  10955. * Create an uniform buffer
  10956. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10957. * @param elements defines the content of the uniform buffer
  10958. * @returns the webGL uniform buffer
  10959. */
  10960. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10961. /**
  10962. * Create a dynamic uniform buffer
  10963. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10964. * @param elements defines the content of the uniform buffer
  10965. * @returns the webGL uniform buffer
  10966. */
  10967. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10968. /**
  10969. * Update an existing uniform buffer
  10970. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10971. * @param uniformBuffer defines the target uniform buffer
  10972. * @param elements defines the content to update
  10973. * @param offset defines the offset in the uniform buffer where update should start
  10974. * @param count defines the size of the data to update
  10975. */
  10976. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10977. private _resetVertexBufferBinding;
  10978. /**
  10979. * Creates a vertex buffer
  10980. * @param data the data for the vertex buffer
  10981. * @returns the new WebGL static buffer
  10982. */
  10983. createVertexBuffer(data: DataArray): WebGLBuffer;
  10984. /**
  10985. * Creates a dynamic vertex buffer
  10986. * @param data the data for the dynamic vertex buffer
  10987. * @returns the new WebGL dynamic buffer
  10988. */
  10989. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10990. /**
  10991. * Update a dynamic index buffer
  10992. * @param indexBuffer defines the target index buffer
  10993. * @param indices defines the data to update
  10994. * @param offset defines the offset in the target index buffer where update should start
  10995. */
  10996. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10997. /**
  10998. * Updates a dynamic vertex buffer.
  10999. * @param vertexBuffer the vertex buffer to update
  11000. * @param data the data used to update the vertex buffer
  11001. * @param byteOffset the byte offset of the data
  11002. * @param byteLength the byte length of the data
  11003. */
  11004. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11005. private _resetIndexBufferBinding;
  11006. /**
  11007. * Creates a new index buffer
  11008. * @param indices defines the content of the index buffer
  11009. * @param updatable defines if the index buffer must be updatable
  11010. * @returns a new webGL buffer
  11011. */
  11012. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11013. /**
  11014. * Bind a webGL buffer to the webGL context
  11015. * @param buffer defines the buffer to bind
  11016. */
  11017. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11018. /**
  11019. * Bind an uniform buffer to the current webGL context
  11020. * @param buffer defines the buffer to bind
  11021. */
  11022. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11023. /**
  11024. * Bind a buffer to the current webGL context at a given location
  11025. * @param buffer defines the buffer to bind
  11026. * @param location defines the index where to bind the buffer
  11027. */
  11028. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11029. /**
  11030. * Bind a specific block at a given index in a specific shader program
  11031. * @param shaderProgram defines the shader program
  11032. * @param blockName defines the block name
  11033. * @param index defines the index where to bind the block
  11034. */
  11035. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11036. private bindIndexBuffer;
  11037. private bindBuffer;
  11038. /**
  11039. * update the bound buffer with the given data
  11040. * @param data defines the data to update
  11041. */
  11042. updateArrayBuffer(data: Float32Array): void;
  11043. private _vertexAttribPointer;
  11044. private _bindIndexBufferWithCache;
  11045. private _bindVertexBuffersAttributes;
  11046. /**
  11047. * Records a vertex array object
  11048. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11049. * @param vertexBuffers defines the list of vertex buffers to store
  11050. * @param indexBuffer defines the index buffer to store
  11051. * @param effect defines the effect to store
  11052. * @returns the new vertex array object
  11053. */
  11054. recordVertexArrayObject(vertexBuffers: {
  11055. [key: string]: VertexBuffer;
  11056. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11057. /**
  11058. * Bind a specific vertex array object
  11059. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11060. * @param vertexArrayObject defines the vertex array object to bind
  11061. * @param indexBuffer defines the index buffer to bind
  11062. */
  11063. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11064. /**
  11065. * Bind webGl buffers directly to the webGL context
  11066. * @param vertexBuffer defines the vertex buffer to bind
  11067. * @param indexBuffer defines the index buffer to bind
  11068. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11069. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11070. * @param effect defines the effect associated with the vertex buffer
  11071. */
  11072. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11073. private _unbindVertexArrayObject;
  11074. /**
  11075. * Bind a list of vertex buffers to the webGL context
  11076. * @param vertexBuffers defines the list of vertex buffers to bind
  11077. * @param indexBuffer defines the index buffer to bind
  11078. * @param effect defines the effect associated with the vertex buffers
  11079. */
  11080. bindBuffers(vertexBuffers: {
  11081. [key: string]: Nullable<VertexBuffer>;
  11082. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11083. /**
  11084. * Unbind all instance attributes
  11085. */
  11086. unbindInstanceAttributes(): void;
  11087. /**
  11088. * Release and free the memory of a vertex array object
  11089. * @param vao defines the vertex array object to delete
  11090. */
  11091. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11092. /** @hidden */
  11093. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11094. /**
  11095. * Creates a webGL buffer to use with instanciation
  11096. * @param capacity defines the size of the buffer
  11097. * @returns the webGL buffer
  11098. */
  11099. createInstancesBuffer(capacity: number): WebGLBuffer;
  11100. /**
  11101. * Delete a webGL buffer used with instanciation
  11102. * @param buffer defines the webGL buffer to delete
  11103. */
  11104. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11105. /**
  11106. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11107. * @param instancesBuffer defines the webGL buffer to update and bind
  11108. * @param data defines the data to store in the buffer
  11109. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11110. */
  11111. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11112. /**
  11113. * Apply all cached states (depth, culling, stencil and alpha)
  11114. */
  11115. applyStates(): void;
  11116. /**
  11117. * Send a draw order
  11118. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11119. * @param indexStart defines the starting index
  11120. * @param indexCount defines the number of index to draw
  11121. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11122. */
  11123. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11124. /**
  11125. * Draw a list of points
  11126. * @param verticesStart defines the index of first vertex to draw
  11127. * @param verticesCount defines the count of vertices to draw
  11128. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11129. */
  11130. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11131. /**
  11132. * Draw a list of unindexed primitives
  11133. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11134. * @param verticesStart defines the index of first vertex to draw
  11135. * @param verticesCount defines the count of vertices to draw
  11136. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11137. */
  11138. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11139. /**
  11140. * Draw a list of indexed primitives
  11141. * @param fillMode defines the primitive to use
  11142. * @param indexStart defines the starting index
  11143. * @param indexCount defines the number of index to draw
  11144. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11145. */
  11146. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11147. /**
  11148. * Draw a list of unindexed primitives
  11149. * @param fillMode defines the primitive to use
  11150. * @param verticesStart defines the index of first vertex to draw
  11151. * @param verticesCount defines the count of vertices to draw
  11152. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11153. */
  11154. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11155. private _drawMode;
  11156. /** @hidden */
  11157. _releaseEffect(effect: Effect): void;
  11158. /** @hidden */
  11159. _deleteProgram(program: WebGLProgram): void;
  11160. /**
  11161. * Create a new effect (used to store vertex/fragment shaders)
  11162. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11163. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11164. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11165. * @param samplers defines an array of string used to represent textures
  11166. * @param defines defines the string containing the defines to use to compile the shaders
  11167. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11168. * @param onCompiled defines a function to call when the effect creation is successful
  11169. * @param onError defines a function to call when the effect creation has failed
  11170. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11171. * @returns the new Effect
  11172. */
  11173. 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;
  11174. private _compileShader;
  11175. private _compileRawShader;
  11176. /**
  11177. * Directly creates a webGL program
  11178. * @param vertexCode defines the vertex shader code to use
  11179. * @param fragmentCode defines the fragment shader code to use
  11180. * @param context defines the webGL context to use (if not set, the current one will be used)
  11181. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11182. * @returns the new webGL program
  11183. */
  11184. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11185. /**
  11186. * Creates a webGL program
  11187. * @param vertexCode defines the vertex shader code to use
  11188. * @param fragmentCode defines the fragment shader code to use
  11189. * @param defines defines the string containing the defines to use to compile the shaders
  11190. * @param context defines the webGL context to use (if not set, the current one will be used)
  11191. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11192. * @returns the new webGL program
  11193. */
  11194. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11195. private _createShaderProgram;
  11196. private _finalizeProgram;
  11197. /** @hidden */
  11198. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11199. /** @hidden */
  11200. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11201. /**
  11202. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11203. * @param shaderProgram defines the webGL program to use
  11204. * @param uniformsNames defines the list of uniform names
  11205. * @returns an array of webGL uniform locations
  11206. */
  11207. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11208. /**
  11209. * Gets the lsit of active attributes for a given webGL program
  11210. * @param shaderProgram defines the webGL program to use
  11211. * @param attributesNames defines the list of attribute names to get
  11212. * @returns an array of indices indicating the offset of each attribute
  11213. */
  11214. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11215. /**
  11216. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11217. * @param effect defines the effect to activate
  11218. */
  11219. enableEffect(effect: Nullable<Effect>): void;
  11220. /**
  11221. * Set the value of an uniform to an array of int32
  11222. * @param uniform defines the webGL uniform location where to store the value
  11223. * @param array defines the array of int32 to store
  11224. */
  11225. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11226. /**
  11227. * Set the value of an uniform to an array of int32 (stored as vec2)
  11228. * @param uniform defines the webGL uniform location where to store the value
  11229. * @param array defines the array of int32 to store
  11230. */
  11231. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11232. /**
  11233. * Set the value of an uniform to an array of int32 (stored as vec3)
  11234. * @param uniform defines the webGL uniform location where to store the value
  11235. * @param array defines the array of int32 to store
  11236. */
  11237. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11238. /**
  11239. * Set the value of an uniform to an array of int32 (stored as vec4)
  11240. * @param uniform defines the webGL uniform location where to store the value
  11241. * @param array defines the array of int32 to store
  11242. */
  11243. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11244. /**
  11245. * Set the value of an uniform to an array of float32
  11246. * @param uniform defines the webGL uniform location where to store the value
  11247. * @param array defines the array of float32 to store
  11248. */
  11249. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11250. /**
  11251. * Set the value of an uniform to an array of float32 (stored as vec2)
  11252. * @param uniform defines the webGL uniform location where to store the value
  11253. * @param array defines the array of float32 to store
  11254. */
  11255. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11256. /**
  11257. * Set the value of an uniform to an array of float32 (stored as vec3)
  11258. * @param uniform defines the webGL uniform location where to store the value
  11259. * @param array defines the array of float32 to store
  11260. */
  11261. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11262. /**
  11263. * Set the value of an uniform to an array of float32 (stored as vec4)
  11264. * @param uniform defines the webGL uniform location where to store the value
  11265. * @param array defines the array of float32 to store
  11266. */
  11267. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11268. /**
  11269. * Set the value of an uniform to an array of number
  11270. * @param uniform defines the webGL uniform location where to store the value
  11271. * @param array defines the array of number to store
  11272. */
  11273. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11274. /**
  11275. * Set the value of an uniform to an array of number (stored as vec2)
  11276. * @param uniform defines the webGL uniform location where to store the value
  11277. * @param array defines the array of number to store
  11278. */
  11279. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11280. /**
  11281. * Set the value of an uniform to an array of number (stored as vec3)
  11282. * @param uniform defines the webGL uniform location where to store the value
  11283. * @param array defines the array of number to store
  11284. */
  11285. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11286. /**
  11287. * Set the value of an uniform to an array of number (stored as vec4)
  11288. * @param uniform defines the webGL uniform location where to store the value
  11289. * @param array defines the array of number to store
  11290. */
  11291. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11292. /**
  11293. * Set the value of an uniform to an array of float32 (stored as matrices)
  11294. * @param uniform defines the webGL uniform location where to store the value
  11295. * @param matrices defines the array of float32 to store
  11296. */
  11297. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11298. /**
  11299. * Set the value of an uniform to a matrix
  11300. * @param uniform defines the webGL uniform location where to store the value
  11301. * @param matrix defines the matrix to store
  11302. */
  11303. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11304. /**
  11305. * Set the value of an uniform to a matrix (3x3)
  11306. * @param uniform defines the webGL uniform location where to store the value
  11307. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11308. */
  11309. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11310. /**
  11311. * Set the value of an uniform to a matrix (2x2)
  11312. * @param uniform defines the webGL uniform location where to store the value
  11313. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11314. */
  11315. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11316. /**
  11317. * Set the value of an uniform to a number (int)
  11318. * @param uniform defines the webGL uniform location where to store the value
  11319. * @param value defines the int number to store
  11320. */
  11321. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11322. /**
  11323. * Set the value of an uniform to a number (float)
  11324. * @param uniform defines the webGL uniform location where to store the value
  11325. * @param value defines the float number to store
  11326. */
  11327. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11328. /**
  11329. * Set the value of an uniform to a vec2
  11330. * @param uniform defines the webGL uniform location where to store the value
  11331. * @param x defines the 1st component of the value
  11332. * @param y defines the 2nd component of the value
  11333. */
  11334. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11335. /**
  11336. * Set the value of an uniform to a vec3
  11337. * @param uniform defines the webGL uniform location where to store the value
  11338. * @param x defines the 1st component of the value
  11339. * @param y defines the 2nd component of the value
  11340. * @param z defines the 3rd component of the value
  11341. */
  11342. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11343. /**
  11344. * Set the value of an uniform to a boolean
  11345. * @param uniform defines the webGL uniform location where to store the value
  11346. * @param bool defines the boolean to store
  11347. */
  11348. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11349. /**
  11350. * Set the value of an uniform to a vec4
  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. * @param z defines the 3rd component of the value
  11355. * @param w defines the 4th component of the value
  11356. */
  11357. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11358. /**
  11359. * Set the value of an uniform to a Color3
  11360. * @param uniform defines the webGL uniform location where to store the value
  11361. * @param color3 defines the color to store
  11362. */
  11363. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11364. /**
  11365. * Set the value of an uniform to a Color3 and an alpha value
  11366. * @param uniform defines the webGL uniform location where to store the value
  11367. * @param color3 defines the color to store
  11368. * @param alpha defines the alpha component to store
  11369. */
  11370. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11371. /**
  11372. * Sets a Color4 on a uniform variable
  11373. * @param uniform defines the uniform location
  11374. * @param color4 defines the value to be set
  11375. */
  11376. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11377. /**
  11378. * Set various states to the webGL context
  11379. * @param culling defines backface culling state
  11380. * @param zOffset defines the value to apply to zOffset (0 by default)
  11381. * @param force defines if states must be applied even if cache is up to date
  11382. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11383. */
  11384. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11385. /**
  11386. * Set the z offset to apply to current rendering
  11387. * @param value defines the offset to apply
  11388. */
  11389. setZOffset(value: number): void;
  11390. /**
  11391. * Gets the current value of the zOffset
  11392. * @returns the current zOffset state
  11393. */
  11394. getZOffset(): number;
  11395. /**
  11396. * Enable or disable depth buffering
  11397. * @param enable defines the state to set
  11398. */
  11399. setDepthBuffer(enable: boolean): void;
  11400. /**
  11401. * Gets a boolean indicating if depth writing is enabled
  11402. * @returns the current depth writing state
  11403. */
  11404. getDepthWrite(): boolean;
  11405. /**
  11406. * Enable or disable depth writing
  11407. * @param enable defines the state to set
  11408. */
  11409. setDepthWrite(enable: boolean): void;
  11410. /**
  11411. * Enable or disable color writing
  11412. * @param enable defines the state to set
  11413. */
  11414. setColorWrite(enable: boolean): void;
  11415. /**
  11416. * Gets a boolean indicating if color writing is enabled
  11417. * @returns the current color writing state
  11418. */
  11419. getColorWrite(): boolean;
  11420. /**
  11421. * Sets alpha constants used by some alpha blending modes
  11422. * @param r defines the red component
  11423. * @param g defines the green component
  11424. * @param b defines the blue component
  11425. * @param a defines the alpha component
  11426. */
  11427. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11428. /**
  11429. * Sets the current alpha mode
  11430. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11431. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11432. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11433. */
  11434. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11435. /**
  11436. * Gets the current alpha mode
  11437. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11438. * @returns the current alpha mode
  11439. */
  11440. getAlphaMode(): number;
  11441. /**
  11442. * Clears the list of texture accessible through engine.
  11443. * This can help preventing texture load conflict due to name collision.
  11444. */
  11445. clearInternalTexturesCache(): void;
  11446. /**
  11447. * Force the entire cache to be cleared
  11448. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11449. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11450. */
  11451. wipeCaches(bruteForce?: boolean): void;
  11452. /**
  11453. * Set the compressed texture format to use, based on the formats you have, and the formats
  11454. * supported by the hardware / browser.
  11455. *
  11456. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11457. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11458. * to API arguments needed to compressed textures. This puts the burden on the container
  11459. * generator to house the arcane code for determining these for current & future formats.
  11460. *
  11461. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11462. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11463. *
  11464. * Note: The result of this call is not taken into account when a texture is base64.
  11465. *
  11466. * @param formatsAvailable defines the list of those format families you have created
  11467. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11468. *
  11469. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11470. * @returns The extension selected.
  11471. */
  11472. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11473. private _getSamplingParameters;
  11474. private _partialLoadImg;
  11475. private _cascadeLoadImgs;
  11476. /** @hidden */
  11477. _createTexture(): WebGLTexture;
  11478. /**
  11479. * Usually called from BABYLON.Texture.ts.
  11480. * Passed information to create a WebGLTexture
  11481. * @param urlArg defines a value which contains one of the following:
  11482. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11483. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11484. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11485. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11486. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11487. * @param scene needed for loading to the correct scene
  11488. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11489. * @param onLoad optional callback to be called upon successful completion
  11490. * @param onError optional callback to be called upon failure
  11491. * @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
  11492. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11493. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11494. * @param forcedExtension defines the extension to use to pick the right loader
  11495. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11496. */
  11497. 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;
  11498. private _rescaleTexture;
  11499. /**
  11500. * Update a raw texture
  11501. * @param texture defines the texture to update
  11502. * @param data defines the data to store in the texture
  11503. * @param format defines the format of the data
  11504. * @param invertY defines if data must be stored with Y axis inverted
  11505. * @param compression defines the compression used (null by default)
  11506. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11507. */
  11508. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11509. /**
  11510. * Creates a raw texture
  11511. * @param data defines the data to store in the texture
  11512. * @param width defines the width of the texture
  11513. * @param height defines the height of the texture
  11514. * @param format defines the format of the data
  11515. * @param generateMipMaps defines if the engine should generate the mip levels
  11516. * @param invertY defines if data must be stored with Y axis inverted
  11517. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11518. * @param compression defines the compression used (null by default)
  11519. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11520. * @returns the raw texture inside an InternalTexture
  11521. */
  11522. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11523. private _unpackFlipYCached;
  11524. /**
  11525. * In case you are sharing the context with other applications, it might
  11526. * be interested to not cache the unpack flip y state to ensure a consistent
  11527. * value would be set.
  11528. */
  11529. enableUnpackFlipYCached: boolean;
  11530. /** @hidden */
  11531. _unpackFlipY(value: boolean): void;
  11532. /** @hidden */
  11533. _getUnpackAlignement(): number;
  11534. /**
  11535. * Creates a dynamic texture
  11536. * @param width defines the width of the texture
  11537. * @param height defines the height of the texture
  11538. * @param generateMipMaps defines if the engine should generate the mip levels
  11539. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11540. * @returns the dynamic texture inside an InternalTexture
  11541. */
  11542. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11543. /**
  11544. * Update the sampling mode of a given texture
  11545. * @param samplingMode defines the required sampling mode
  11546. * @param texture defines the texture to update
  11547. */
  11548. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11549. /**
  11550. * Update the content of a dynamic texture
  11551. * @param texture defines the texture to update
  11552. * @param canvas defines the canvas containing the source
  11553. * @param invertY defines if data must be stored with Y axis inverted
  11554. * @param premulAlpha defines if alpha is stored as premultiplied
  11555. * @param format defines the format of the data
  11556. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11557. */
  11558. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11559. /**
  11560. * Update a video texture
  11561. * @param texture defines the texture to update
  11562. * @param video defines the video element to use
  11563. * @param invertY defines if data must be stored with Y axis inverted
  11564. */
  11565. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11566. /**
  11567. * Updates a depth texture Comparison Mode and Function.
  11568. * If the comparison Function is equal to 0, the mode will be set to none.
  11569. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11570. * @param texture The texture to set the comparison function for
  11571. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11572. */
  11573. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11574. private _setupDepthStencilTexture;
  11575. /**
  11576. * Creates a depth stencil texture.
  11577. * This is only available in WebGL 2 or with the depth texture extension available.
  11578. * @param size The size of face edge in the texture.
  11579. * @param options The options defining the texture.
  11580. * @returns The texture
  11581. */
  11582. createDepthStencilTexture(size: number | {
  11583. width: number;
  11584. height: number;
  11585. }, options: DepthTextureCreationOptions): InternalTexture;
  11586. /**
  11587. * Creates a depth stencil texture.
  11588. * This is only available in WebGL 2 or with the depth texture extension available.
  11589. * @param size The size of face edge in the texture.
  11590. * @param options The options defining the texture.
  11591. * @returns The texture
  11592. */
  11593. private _createDepthStencilTexture;
  11594. /**
  11595. * Creates a depth stencil cube texture.
  11596. * This is only available in WebGL 2.
  11597. * @param size The size of face edge in the cube texture.
  11598. * @param options The options defining the cube texture.
  11599. * @returns The cube texture
  11600. */
  11601. private _createDepthStencilCubeTexture;
  11602. /**
  11603. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11604. * @param renderTarget The render target to set the frame buffer for
  11605. */
  11606. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11607. /**
  11608. * Creates a new render target texture
  11609. * @param size defines the size of the texture
  11610. * @param options defines the options used to create the texture
  11611. * @returns a new render target texture stored in an InternalTexture
  11612. */
  11613. createRenderTargetTexture(size: number | {
  11614. width: number;
  11615. height: number;
  11616. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11617. /**
  11618. * Create a multi render target texture
  11619. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11620. * @param size defines the size of the texture
  11621. * @param options defines the creation options
  11622. * @returns the cube texture as an InternalTexture
  11623. */
  11624. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11625. private _setupFramebufferDepthAttachments;
  11626. /**
  11627. * Updates the sample count of a render target texture
  11628. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11629. * @param texture defines the texture to update
  11630. * @param samples defines the sample count to set
  11631. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11632. */
  11633. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11634. /**
  11635. * Update the sample count for a given multiple render target texture
  11636. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11637. * @param textures defines the textures to update
  11638. * @param samples defines the sample count to set
  11639. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11640. */
  11641. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11642. /** @hidden */
  11643. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11644. /** @hidden */
  11645. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11646. /** @hidden */
  11647. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11648. /** @hidden */
  11649. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11650. /**
  11651. * Creates a new render target cube texture
  11652. * @param size defines the size of the texture
  11653. * @param options defines the options used to create the texture
  11654. * @returns a new render target cube texture stored in an InternalTexture
  11655. */
  11656. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11657. /**
  11658. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11659. * @param rootUrl defines the url where the file to load is located
  11660. * @param scene defines the current scene
  11661. * @param lodScale defines scale to apply to the mip map selection
  11662. * @param lodOffset defines offset to apply to the mip map selection
  11663. * @param onLoad defines an optional callback raised when the texture is loaded
  11664. * @param onError defines an optional callback raised if there is an issue to load the texture
  11665. * @param format defines the format of the data
  11666. * @param forcedExtension defines the extension to use to pick the right loader
  11667. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11668. * @returns the cube texture as an InternalTexture
  11669. */
  11670. 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;
  11671. /**
  11672. * Creates a cube texture
  11673. * @param rootUrl defines the url where the files to load is located
  11674. * @param scene defines the current scene
  11675. * @param files defines the list of files to load (1 per face)
  11676. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11677. * @param onLoad defines an optional callback raised when the texture is loaded
  11678. * @param onError defines an optional callback raised if there is an issue to load the texture
  11679. * @param format defines the format of the data
  11680. * @param forcedExtension defines the extension to use to pick the right loader
  11681. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11682. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11683. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11684. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11685. * @returns the cube texture as an InternalTexture
  11686. */
  11687. 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;
  11688. /**
  11689. * @hidden
  11690. */
  11691. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11692. /**
  11693. * Update a raw cube texture
  11694. * @param texture defines the texture to udpdate
  11695. * @param data defines the data to store
  11696. * @param format defines the data format
  11697. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11698. * @param invertY defines if data must be stored with Y axis inverted
  11699. * @param compression defines the compression used (null by default)
  11700. * @param level defines which level of the texture to update
  11701. */
  11702. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11703. /**
  11704. * Creates a new raw cube texture
  11705. * @param data defines the array of data to use to create each face
  11706. * @param size defines the size of the textures
  11707. * @param format defines the format of the data
  11708. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11709. * @param generateMipMaps defines if the engine should generate the mip levels
  11710. * @param invertY defines if data must be stored with Y axis inverted
  11711. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11712. * @param compression defines the compression used (null by default)
  11713. * @returns the cube texture as an InternalTexture
  11714. */
  11715. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11716. /**
  11717. * Creates a new raw cube texture from a specified url
  11718. * @param url defines the url where the data is located
  11719. * @param scene defines the current scene
  11720. * @param size defines the size of the textures
  11721. * @param format defines the format of the data
  11722. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11723. * @param noMipmap defines if the engine should avoid generating the mip levels
  11724. * @param callback defines a callback used to extract texture data from loaded data
  11725. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11726. * @param onLoad defines a callback called when texture is loaded
  11727. * @param onError defines a callback called if there is an error
  11728. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11729. * @param invertY defines if data must be stored with Y axis inverted
  11730. * @returns the cube texture as an InternalTexture
  11731. */
  11732. 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;
  11733. /**
  11734. * Update a raw 3D texture
  11735. * @param texture defines the texture to update
  11736. * @param data defines the data to store
  11737. * @param format defines the data format
  11738. * @param invertY defines if data must be stored with Y axis inverted
  11739. * @param compression defines the used compression (can be null)
  11740. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11741. */
  11742. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11743. /**
  11744. * Creates a new raw 3D texture
  11745. * @param data defines the data used to create the texture
  11746. * @param width defines the width of the texture
  11747. * @param height defines the height of the texture
  11748. * @param depth defines the depth of the texture
  11749. * @param format defines the format of the texture
  11750. * @param generateMipMaps defines if the engine must generate mip levels
  11751. * @param invertY defines if data must be stored with Y axis inverted
  11752. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11753. * @param compression defines the compressed used (can be null)
  11754. * @param textureType defines the compressed used (can be null)
  11755. * @returns a new raw 3D texture (stored in an InternalTexture)
  11756. */
  11757. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11758. private _prepareWebGLTextureContinuation;
  11759. private _prepareWebGLTexture;
  11760. private _convertRGBtoRGBATextureData;
  11761. /** @hidden */
  11762. _releaseFramebufferObjects(texture: InternalTexture): void;
  11763. /** @hidden */
  11764. _releaseTexture(texture: InternalTexture): void;
  11765. private setProgram;
  11766. private _boundUniforms;
  11767. /**
  11768. * Binds an effect to the webGL context
  11769. * @param effect defines the effect to bind
  11770. */
  11771. bindSamplers(effect: Effect): void;
  11772. private _moveBoundTextureOnTop;
  11773. private _getCorrectTextureChannel;
  11774. private _linkTrackers;
  11775. private _removeDesignatedSlot;
  11776. private _activateCurrentTexture;
  11777. /** @hidden */
  11778. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11779. /** @hidden */
  11780. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11781. /**
  11782. * Sets a texture to the webGL context from a postprocess
  11783. * @param channel defines the channel to use
  11784. * @param postProcess defines the source postprocess
  11785. */
  11786. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11787. /**
  11788. * Binds the output of the passed in post process to the texture channel specified
  11789. * @param channel The channel the texture should be bound to
  11790. * @param postProcess The post process which's output should be bound
  11791. */
  11792. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11793. /**
  11794. * Unbind all textures from the webGL context
  11795. */
  11796. unbindAllTextures(): void;
  11797. /**
  11798. * Sets a texture to the according uniform.
  11799. * @param channel The texture channel
  11800. * @param uniform The uniform to set
  11801. * @param texture The texture to apply
  11802. */
  11803. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11804. /**
  11805. * Sets a depth stencil texture from a render target to the according uniform.
  11806. * @param channel The texture channel
  11807. * @param uniform The uniform to set
  11808. * @param texture The render target texture containing the depth stencil texture to apply
  11809. */
  11810. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11811. private _bindSamplerUniformToChannel;
  11812. private _getTextureWrapMode;
  11813. private _setTexture;
  11814. /**
  11815. * Sets an array of texture to the webGL context
  11816. * @param channel defines the channel where the texture array must be set
  11817. * @param uniform defines the associated uniform location
  11818. * @param textures defines the array of textures to bind
  11819. */
  11820. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11821. /** @hidden */
  11822. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11823. private _setTextureParameterFloat;
  11824. private _setTextureParameterInteger;
  11825. /**
  11826. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11827. * @param x defines the x coordinate of the rectangle where pixels must be read
  11828. * @param y defines the y coordinate of the rectangle where pixels must be read
  11829. * @param width defines the width of the rectangle where pixels must be read
  11830. * @param height defines the height of the rectangle where pixels must be read
  11831. * @returns a Uint8Array containing RGBA colors
  11832. */
  11833. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11834. /**
  11835. * Add an externaly attached data from its key.
  11836. * This method call will fail and return false, if such key already exists.
  11837. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11838. * @param key the unique key that identifies the data
  11839. * @param data the data object to associate to the key for this Engine instance
  11840. * @return true if no such key were already present and the data was added successfully, false otherwise
  11841. */
  11842. addExternalData<T>(key: string, data: T): boolean;
  11843. /**
  11844. * Get an externaly attached data from its key
  11845. * @param key the unique key that identifies the data
  11846. * @return the associated data, if present (can be null), or undefined if not present
  11847. */
  11848. getExternalData<T>(key: string): T;
  11849. /**
  11850. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11851. * @param key the unique key that identifies the data
  11852. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11853. * @return the associated data, can be null if the factory returned null.
  11854. */
  11855. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11856. /**
  11857. * Remove an externaly attached data from the Engine instance
  11858. * @param key the unique key that identifies the data
  11859. * @return true if the data was successfully removed, false if it doesn't exist
  11860. */
  11861. removeExternalData(key: string): boolean;
  11862. /**
  11863. * Unbind all vertex attributes from the webGL context
  11864. */
  11865. unbindAllAttributes(): void;
  11866. /**
  11867. * 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
  11868. */
  11869. releaseEffects(): void;
  11870. /**
  11871. * Dispose and release all associated resources
  11872. */
  11873. dispose(): void;
  11874. /**
  11875. * Display the loading screen
  11876. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11877. */
  11878. displayLoadingUI(): void;
  11879. /**
  11880. * Hide the loading screen
  11881. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11882. */
  11883. hideLoadingUI(): void;
  11884. /**
  11885. * Gets the current loading screen object
  11886. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11887. */
  11888. /**
  11889. * Sets the current loading screen object
  11890. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11891. */
  11892. loadingScreen: ILoadingScreen;
  11893. /**
  11894. * Sets the current loading screen text
  11895. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11896. */
  11897. loadingUIText: string;
  11898. /**
  11899. * Sets the current loading screen background color
  11900. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11901. */
  11902. loadingUIBackgroundColor: string;
  11903. /**
  11904. * Attach a new callback raised when context lost event is fired
  11905. * @param callback defines the callback to call
  11906. */
  11907. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11908. /**
  11909. * Attach a new callback raised when context restored event is fired
  11910. * @param callback defines the callback to call
  11911. */
  11912. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11913. /**
  11914. * Gets the source code of the vertex shader associated with a specific webGL program
  11915. * @param program defines the program to use
  11916. * @returns a string containing the source code of the vertex shader associated with the program
  11917. */
  11918. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11919. /**
  11920. * Gets the source code of the fragment shader associated with a specific webGL program
  11921. * @param program defines the program to use
  11922. * @returns a string containing the source code of the fragment shader associated with the program
  11923. */
  11924. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11925. /**
  11926. * Get the current error code of the webGL context
  11927. * @returns the error code
  11928. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11929. */
  11930. getError(): number;
  11931. /**
  11932. * Gets the current framerate
  11933. * @returns a number representing the framerate
  11934. */
  11935. getFps(): number;
  11936. /**
  11937. * Gets the time spent between current and previous frame
  11938. * @returns a number representing the delta time in ms
  11939. */
  11940. getDeltaTime(): number;
  11941. private _measureFps;
  11942. /** @hidden */
  11943. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11944. private _canRenderToFloatFramebuffer;
  11945. private _canRenderToHalfFloatFramebuffer;
  11946. private _canRenderToFramebuffer;
  11947. /** @hidden */
  11948. _getWebGLTextureType(type: number): number;
  11949. private _getInternalFormat;
  11950. /** @hidden */
  11951. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11952. /** @hidden */
  11953. _getRGBAMultiSampleBufferFormat(type: number): number;
  11954. /** @hidden */
  11955. _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;
  11956. /** @hidden */
  11957. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11958. private _partialLoadFile;
  11959. private _cascadeLoadFiles;
  11960. /**
  11961. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11962. * @returns true if the engine can be created
  11963. * @ignorenaming
  11964. */
  11965. static isSupported(): boolean;
  11966. }
  11967. }
  11968. declare module BABYLON {
  11969. /**
  11970. * Options to create the null engine
  11971. */
  11972. class NullEngineOptions {
  11973. /**
  11974. * Render width (Default: 512)
  11975. */
  11976. renderWidth: number;
  11977. /**
  11978. * Render height (Default: 256)
  11979. */
  11980. renderHeight: number;
  11981. /**
  11982. * Texture size (Default: 512)
  11983. */
  11984. textureSize: number;
  11985. /**
  11986. * If delta time between frames should be constant
  11987. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11988. */
  11989. deterministicLockstep: boolean;
  11990. /**
  11991. * Maximum about of steps between frames (Default: 4)
  11992. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11993. */
  11994. lockstepMaxSteps: number;
  11995. }
  11996. /**
  11997. * The null engine class provides support for headless version of babylon.js.
  11998. * This can be used in server side scenario or for testing purposes
  11999. */
  12000. class NullEngine extends Engine {
  12001. private _options;
  12002. /**
  12003. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12004. */
  12005. isDeterministicLockStep(): boolean;
  12006. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12007. getLockstepMaxSteps(): number;
  12008. /**
  12009. * Sets hardware scaling, used to save performance if needed
  12010. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12011. */
  12012. getHardwareScalingLevel(): number;
  12013. constructor(options?: NullEngineOptions);
  12014. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12015. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12016. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12017. getRenderWidth(useScreen?: boolean): number;
  12018. getRenderHeight(useScreen?: boolean): number;
  12019. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12020. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12021. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12022. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12023. bindSamplers(effect: Effect): void;
  12024. enableEffect(effect: Effect): void;
  12025. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12026. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12027. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12028. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12029. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12030. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12031. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12032. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12033. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12034. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12035. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12036. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12037. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12038. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12039. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12040. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12041. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12042. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12043. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12044. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12045. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12046. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12047. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12048. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12049. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12050. bindBuffers(vertexBuffers: {
  12051. [key: string]: VertexBuffer;
  12052. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12053. wipeCaches(bruteForce?: boolean): void;
  12054. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12055. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12056. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12057. /** @hidden */
  12058. _createTexture(): WebGLTexture;
  12059. /** @hidden */
  12060. _releaseTexture(texture: InternalTexture): void;
  12061. 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;
  12062. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12063. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12064. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12065. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12066. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12067. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12068. areAllEffectsReady(): boolean;
  12069. /**
  12070. * @hidden
  12071. * Get the current error code of the webGL context
  12072. * @returns the error code
  12073. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12074. */
  12075. getError(): number;
  12076. /** @hidden */
  12077. _getUnpackAlignement(): number;
  12078. /** @hidden */
  12079. _unpackFlipY(value: boolean): void;
  12080. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12081. /**
  12082. * Updates a dynamic vertex buffer.
  12083. * @param vertexBuffer the vertex buffer to update
  12084. * @param data the data used to update the vertex buffer
  12085. * @param byteOffset the byte offset of the data (optional)
  12086. * @param byteLength the byte length of the data (optional)
  12087. */
  12088. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12089. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12090. /** @hidden */
  12091. _bindTexture(channel: number, texture: InternalTexture): void;
  12092. /** @hidden */
  12093. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12094. releaseEffects(): void;
  12095. displayLoadingUI(): void;
  12096. hideLoadingUI(): void;
  12097. /** @hidden */
  12098. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12099. /** @hidden */
  12100. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12101. /** @hidden */
  12102. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12103. /** @hidden */
  12104. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12105. }
  12106. }
  12107. interface WebGLRenderingContext {
  12108. readonly RASTERIZER_DISCARD: number;
  12109. readonly DEPTH_COMPONENT24: number;
  12110. readonly TEXTURE_3D: number;
  12111. readonly TEXTURE_2D_ARRAY: number;
  12112. readonly TEXTURE_COMPARE_FUNC: number;
  12113. readonly TEXTURE_COMPARE_MODE: number;
  12114. readonly COMPARE_REF_TO_TEXTURE: number;
  12115. readonly TEXTURE_WRAP_R: number;
  12116. readonly HALF_FLOAT: number;
  12117. readonly RGB8: number;
  12118. readonly RED_INTEGER: number;
  12119. readonly RG_INTEGER: number;
  12120. readonly RGB_INTEGER: number;
  12121. readonly RGBA_INTEGER: number;
  12122. readonly R8_SNORM: number;
  12123. readonly RG8_SNORM: number;
  12124. readonly RGB8_SNORM: number;
  12125. readonly RGBA8_SNORM: number;
  12126. readonly R8I: number;
  12127. readonly RG8I: number;
  12128. readonly RGB8I: number;
  12129. readonly RGBA8I: number;
  12130. readonly R8UI: number;
  12131. readonly RG8UI: number;
  12132. readonly RGB8UI: number;
  12133. readonly RGBA8UI: number;
  12134. readonly R16I: number;
  12135. readonly RG16I: number;
  12136. readonly RGB16I: number;
  12137. readonly RGBA16I: number;
  12138. readonly R16UI: number;
  12139. readonly RG16UI: number;
  12140. readonly RGB16UI: number;
  12141. readonly RGBA16UI: number;
  12142. readonly R32I: number;
  12143. readonly RG32I: number;
  12144. readonly RGB32I: number;
  12145. readonly RGBA32I: number;
  12146. readonly R32UI: number;
  12147. readonly RG32UI: number;
  12148. readonly RGB32UI: number;
  12149. readonly RGBA32UI: number;
  12150. readonly RGB10_A2UI: number;
  12151. readonly R11F_G11F_B10F: number;
  12152. readonly RGB9_E5: number;
  12153. readonly RGB10_A2: number;
  12154. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12155. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12156. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12157. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12158. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12159. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12160. 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;
  12161. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12162. readonly TRANSFORM_FEEDBACK: number;
  12163. readonly INTERLEAVED_ATTRIBS: number;
  12164. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12165. createTransformFeedback(): WebGLTransformFeedback;
  12166. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12167. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12168. beginTransformFeedback(primitiveMode: number): void;
  12169. endTransformFeedback(): void;
  12170. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12171. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12172. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12173. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12174. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12175. }
  12176. interface ImageBitmap {
  12177. readonly width: number;
  12178. readonly height: number;
  12179. close(): void;
  12180. }
  12181. interface WebGLQuery extends WebGLObject {
  12182. }
  12183. declare var WebGLQuery: {
  12184. prototype: WebGLQuery;
  12185. new (): WebGLQuery;
  12186. };
  12187. interface WebGLSampler extends WebGLObject {
  12188. }
  12189. declare var WebGLSampler: {
  12190. prototype: WebGLSampler;
  12191. new (): WebGLSampler;
  12192. };
  12193. interface WebGLSync extends WebGLObject {
  12194. }
  12195. declare var WebGLSync: {
  12196. prototype: WebGLSync;
  12197. new (): WebGLSync;
  12198. };
  12199. interface WebGLTransformFeedback extends WebGLObject {
  12200. }
  12201. declare var WebGLTransformFeedback: {
  12202. prototype: WebGLTransformFeedback;
  12203. new (): WebGLTransformFeedback;
  12204. };
  12205. interface WebGLVertexArrayObject extends WebGLObject {
  12206. }
  12207. declare var WebGLVertexArrayObject: {
  12208. prototype: WebGLVertexArrayObject;
  12209. new (): WebGLVertexArrayObject;
  12210. };
  12211. declare module BABYLON {
  12212. /**
  12213. * Gather the list of clipboard event types as constants.
  12214. */
  12215. class ClipboardEventTypes {
  12216. /**
  12217. * The clipboard event is fired when a copy command is active (pressed).
  12218. */
  12219. static readonly COPY: number;
  12220. /**
  12221. * The clipboard event is fired when a cut command is active (pressed).
  12222. */
  12223. static readonly CUT: number;
  12224. /**
  12225. * The clipboard event is fired when a paste command is active (pressed).
  12226. */
  12227. static readonly PASTE: number;
  12228. }
  12229. /**
  12230. * This class is used to store clipboard related info for the onClipboardObservable event.
  12231. */
  12232. class ClipboardInfo {
  12233. /**
  12234. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12235. */
  12236. type: number;
  12237. /**
  12238. * Defines the related dom event
  12239. */
  12240. event: ClipboardEvent;
  12241. /**
  12242. *Creates an instance of ClipboardInfo.
  12243. * @param {number} type
  12244. * @param {ClipboardEvent} event
  12245. */
  12246. constructor(
  12247. /**
  12248. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12249. */
  12250. type: number,
  12251. /**
  12252. * Defines the related dom event
  12253. */
  12254. event: ClipboardEvent);
  12255. /**
  12256. * Get the clipboard event's type from the keycode.
  12257. * @param keyCode Defines the keyCode for the current keyboard event.
  12258. * @return {number}
  12259. */
  12260. static GetTypeFromCharacter(keyCode: number): number;
  12261. }
  12262. }
  12263. declare module BABYLON {
  12264. /**
  12265. * Gather the list of keyboard event types as constants.
  12266. */
  12267. class KeyboardEventTypes {
  12268. /**
  12269. * The keydown event is fired when a key becomes active (pressed).
  12270. */
  12271. static readonly KEYDOWN: number;
  12272. /**
  12273. * The keyup event is fired when a key has been released.
  12274. */
  12275. static readonly KEYUP: number;
  12276. }
  12277. /**
  12278. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12279. */
  12280. class KeyboardInfo {
  12281. /**
  12282. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12283. */
  12284. type: number;
  12285. /**
  12286. * Defines the related dom event
  12287. */
  12288. event: KeyboardEvent;
  12289. /**
  12290. * Instantiates a new keyboard info.
  12291. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12292. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12293. * @param event Defines the related dom event
  12294. */
  12295. constructor(
  12296. /**
  12297. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12298. */
  12299. type: number,
  12300. /**
  12301. * Defines the related dom event
  12302. */
  12303. event: KeyboardEvent);
  12304. }
  12305. /**
  12306. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12307. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12308. */
  12309. class KeyboardInfoPre extends KeyboardInfo {
  12310. /**
  12311. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12312. */
  12313. type: number;
  12314. /**
  12315. * Defines the related dom event
  12316. */
  12317. event: KeyboardEvent;
  12318. /**
  12319. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12320. */
  12321. skipOnPointerObservable: boolean;
  12322. /**
  12323. * Instantiates a new keyboard pre info.
  12324. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12325. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12326. * @param event Defines the related dom event
  12327. */
  12328. constructor(
  12329. /**
  12330. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12331. */
  12332. type: number,
  12333. /**
  12334. * Defines the related dom event
  12335. */
  12336. event: KeyboardEvent);
  12337. }
  12338. }
  12339. declare module BABYLON {
  12340. /**
  12341. * Gather the list of pointer event types as constants.
  12342. */
  12343. class PointerEventTypes {
  12344. /**
  12345. * 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.
  12346. */
  12347. static readonly POINTERDOWN: number;
  12348. /**
  12349. * The pointerup event is fired when a pointer is no longer active.
  12350. */
  12351. static readonly POINTERUP: number;
  12352. /**
  12353. * The pointermove event is fired when a pointer changes coordinates.
  12354. */
  12355. static readonly POINTERMOVE: number;
  12356. /**
  12357. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12358. */
  12359. static readonly POINTERWHEEL: number;
  12360. /**
  12361. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12362. */
  12363. static readonly POINTERPICK: number;
  12364. /**
  12365. * The pointertap event is fired when a the object has been touched and released without drag.
  12366. */
  12367. static readonly POINTERTAP: number;
  12368. /**
  12369. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12370. */
  12371. static readonly POINTERDOUBLETAP: number;
  12372. }
  12373. /**
  12374. * Base class of pointer info types.
  12375. */
  12376. class PointerInfoBase {
  12377. /**
  12378. * Defines the type of event (BABYLON.PointerEventTypes)
  12379. */
  12380. type: number;
  12381. /**
  12382. * Defines the related dom event
  12383. */
  12384. event: PointerEvent | MouseWheelEvent;
  12385. /**
  12386. * Instantiates the base class of pointers info.
  12387. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12388. * @param event Defines the related dom event
  12389. */
  12390. constructor(
  12391. /**
  12392. * Defines the type of event (BABYLON.PointerEventTypes)
  12393. */
  12394. type: number,
  12395. /**
  12396. * Defines the related dom event
  12397. */
  12398. event: PointerEvent | MouseWheelEvent);
  12399. }
  12400. /**
  12401. * This class is used to store pointer related info for the onPrePointerObservable event.
  12402. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12403. */
  12404. class PointerInfoPre extends PointerInfoBase {
  12405. /**
  12406. * Ray from a pointer if availible (eg. 6dof controller)
  12407. */
  12408. ray: Nullable<Ray>;
  12409. /**
  12410. * Defines the local position of the pointer on the canvas.
  12411. */
  12412. localPosition: Vector2;
  12413. /**
  12414. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12415. */
  12416. skipOnPointerObservable: boolean;
  12417. /**
  12418. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12419. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12420. * @param event Defines the related dom event
  12421. * @param localX Defines the local x coordinates of the pointer when the event occured
  12422. * @param localY Defines the local y coordinates of the pointer when the event occured
  12423. */
  12424. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12425. }
  12426. /**
  12427. * This type contains all the data related to a pointer event in Babylon.js.
  12428. * 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.
  12429. */
  12430. class PointerInfo extends PointerInfoBase {
  12431. /**
  12432. * Defines the picking info associated to the info (if any)\
  12433. */
  12434. pickInfo: Nullable<PickingInfo>;
  12435. /**
  12436. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12437. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12438. * @param event Defines the related dom event
  12439. * @param pickInfo Defines the picking info associated to the info (if any)\
  12440. */
  12441. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12442. /**
  12443. * Defines the picking info associated to the info (if any)\
  12444. */
  12445. pickInfo: Nullable<PickingInfo>);
  12446. }
  12447. }
  12448. declare module BABYLON {
  12449. /**
  12450. * Represents a gamepad control stick position
  12451. */
  12452. class StickValues {
  12453. /**
  12454. * The x component of the control stick
  12455. */
  12456. x: number;
  12457. /**
  12458. * The y component of the control stick
  12459. */
  12460. y: number;
  12461. /**
  12462. * Initializes the gamepad x and y control stick values
  12463. * @param x The x component of the gamepad control stick value
  12464. * @param y The y component of the gamepad control stick value
  12465. */
  12466. constructor(
  12467. /**
  12468. * The x component of the control stick
  12469. */
  12470. x: number,
  12471. /**
  12472. * The y component of the control stick
  12473. */
  12474. y: number);
  12475. }
  12476. /**
  12477. * An interface which manages callbacks for gamepad button changes
  12478. */
  12479. interface GamepadButtonChanges {
  12480. /**
  12481. * Called when a gamepad has been changed
  12482. */
  12483. changed: boolean;
  12484. /**
  12485. * Called when a gamepad press event has been triggered
  12486. */
  12487. pressChanged: boolean;
  12488. /**
  12489. * Called when a touch event has been triggered
  12490. */
  12491. touchChanged: boolean;
  12492. /**
  12493. * Called when a value has changed
  12494. */
  12495. valueChanged: boolean;
  12496. }
  12497. /**
  12498. * Represents a gamepad
  12499. */
  12500. class Gamepad {
  12501. /**
  12502. * The id of the gamepad
  12503. */
  12504. id: string;
  12505. /**
  12506. * The index of the gamepad
  12507. */
  12508. index: number;
  12509. /**
  12510. * The browser gamepad
  12511. */
  12512. browserGamepad: any;
  12513. /**
  12514. * Specifies what type of gamepad this represents
  12515. */
  12516. type: number;
  12517. private _leftStick;
  12518. private _rightStick;
  12519. /** @hidden */
  12520. _isConnected: boolean;
  12521. private _leftStickAxisX;
  12522. private _leftStickAxisY;
  12523. private _rightStickAxisX;
  12524. private _rightStickAxisY;
  12525. /**
  12526. * Triggered when the left control stick has been changed
  12527. */
  12528. private _onleftstickchanged;
  12529. /**
  12530. * Triggered when the right control stick has been changed
  12531. */
  12532. private _onrightstickchanged;
  12533. /**
  12534. * Represents a gamepad controller
  12535. */
  12536. static GAMEPAD: number;
  12537. /**
  12538. * Represents a generic controller
  12539. */
  12540. static GENERIC: number;
  12541. /**
  12542. * Represents an XBox controller
  12543. */
  12544. static XBOX: number;
  12545. /**
  12546. * Represents a pose-enabled controller
  12547. */
  12548. static POSE_ENABLED: number;
  12549. /**
  12550. * Specifies whether the left control stick should be Y-inverted
  12551. */
  12552. protected _invertLeftStickY: boolean;
  12553. /**
  12554. * Specifies if the gamepad has been connected
  12555. */
  12556. readonly isConnected: boolean;
  12557. /**
  12558. * Initializes the gamepad
  12559. * @param id The id of the gamepad
  12560. * @param index The index of the gamepad
  12561. * @param browserGamepad The browser gamepad
  12562. * @param leftStickX The x component of the left joystick
  12563. * @param leftStickY The y component of the left joystick
  12564. * @param rightStickX The x component of the right joystick
  12565. * @param rightStickY The y component of the right joystick
  12566. */
  12567. constructor(
  12568. /**
  12569. * The id of the gamepad
  12570. */
  12571. id: string,
  12572. /**
  12573. * The index of the gamepad
  12574. */
  12575. index: number,
  12576. /**
  12577. * The browser gamepad
  12578. */
  12579. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12580. /**
  12581. * Callback triggered when the left joystick has changed
  12582. * @param callback
  12583. */
  12584. onleftstickchanged(callback: (values: StickValues) => void): void;
  12585. /**
  12586. * Callback triggered when the right joystick has changed
  12587. * @param callback
  12588. */
  12589. onrightstickchanged(callback: (values: StickValues) => void): void;
  12590. /**
  12591. * Gets the left joystick
  12592. */
  12593. /**
  12594. * Sets the left joystick values
  12595. */
  12596. leftStick: StickValues;
  12597. /**
  12598. * Gets the right joystick
  12599. */
  12600. /**
  12601. * Sets the right joystick value
  12602. */
  12603. rightStick: StickValues;
  12604. /**
  12605. * Updates the gamepad joystick positions
  12606. */
  12607. update(): void;
  12608. /**
  12609. * Disposes the gamepad
  12610. */
  12611. dispose(): void;
  12612. }
  12613. /**
  12614. * Represents a generic gamepad
  12615. */
  12616. class GenericPad extends Gamepad {
  12617. private _buttons;
  12618. private _onbuttondown;
  12619. private _onbuttonup;
  12620. /**
  12621. * Observable triggered when a button has been pressed
  12622. */
  12623. onButtonDownObservable: Observable<number>;
  12624. /**
  12625. * Observable triggered when a button has been released
  12626. */
  12627. onButtonUpObservable: Observable<number>;
  12628. /**
  12629. * Callback triggered when a button has been pressed
  12630. * @param callback Called when a button has been pressed
  12631. */
  12632. onbuttondown(callback: (buttonPressed: number) => void): void;
  12633. /**
  12634. * Callback triggered when a button has been released
  12635. * @param callback Called when a button has been released
  12636. */
  12637. onbuttonup(callback: (buttonReleased: number) => void): void;
  12638. /**
  12639. * Initializes the generic gamepad
  12640. * @param id The id of the generic gamepad
  12641. * @param index The index of the generic gamepad
  12642. * @param browserGamepad The browser gamepad
  12643. */
  12644. constructor(id: string, index: number, browserGamepad: any);
  12645. private _setButtonValue;
  12646. /**
  12647. * Updates the generic gamepad
  12648. */
  12649. update(): void;
  12650. /**
  12651. * Disposes the generic gamepad
  12652. */
  12653. dispose(): void;
  12654. }
  12655. }
  12656. declare module BABYLON {
  12657. /**
  12658. * Manager for handling gamepads
  12659. */
  12660. class GamepadManager {
  12661. private _scene?;
  12662. private _babylonGamepads;
  12663. private _oneGamepadConnected;
  12664. /** @hidden */
  12665. _isMonitoring: boolean;
  12666. private _gamepadEventSupported;
  12667. private _gamepadSupport;
  12668. /**
  12669. * observable to be triggered when the gamepad controller has been connected
  12670. */
  12671. onGamepadConnectedObservable: Observable<Gamepad>;
  12672. /**
  12673. * observable to be triggered when the gamepad controller has been disconnected
  12674. */
  12675. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12676. private _onGamepadConnectedEvent;
  12677. private _onGamepadDisconnectedEvent;
  12678. /**
  12679. * Initializes the gamepad manager
  12680. * @param _scene BabylonJS scene
  12681. */
  12682. constructor(_scene?: Scene | undefined);
  12683. /**
  12684. * The gamepads in the game pad manager
  12685. */
  12686. readonly gamepads: Gamepad[];
  12687. /**
  12688. * Get the gamepad controllers based on type
  12689. * @param type The type of gamepad controller
  12690. * @returns Nullable gamepad
  12691. */
  12692. getGamepadByType(type?: number): Nullable<Gamepad>;
  12693. /**
  12694. * Disposes the gamepad manager
  12695. */
  12696. dispose(): void;
  12697. private _addNewGamepad;
  12698. private _startMonitoringGamepads;
  12699. private _stopMonitoringGamepads;
  12700. /** @hidden */
  12701. _checkGamepadsStatus(): void;
  12702. private _updateGamepadObjects;
  12703. }
  12704. }
  12705. declare module BABYLON {
  12706. interface Scene {
  12707. /** @hidden */
  12708. _gamepadManager: Nullable<GamepadManager>;
  12709. /**
  12710. * Gets the gamepad manager associated with the scene
  12711. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12712. */
  12713. gamepadManager: GamepadManager;
  12714. }
  12715. /**
  12716. * Interface representing a free camera inputs manager
  12717. */
  12718. interface FreeCameraInputsManager {
  12719. /**
  12720. * Adds gamepad input support to the FreeCameraInputsManager.
  12721. * @returns the FreeCameraInputsManager
  12722. */
  12723. addGamepad(): FreeCameraInputsManager;
  12724. }
  12725. /**
  12726. * Interface representing an arc rotate camera inputs manager
  12727. */
  12728. interface ArcRotateCameraInputsManager {
  12729. /**
  12730. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12731. * @returns the camera inputs manager
  12732. */
  12733. addGamepad(): ArcRotateCameraInputsManager;
  12734. }
  12735. /**
  12736. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12737. */
  12738. class GamepadSystemSceneComponent implements ISceneComponent {
  12739. /**
  12740. * The component name helpfull to identify the component in the list of scene components.
  12741. */
  12742. readonly name: string;
  12743. /**
  12744. * The scene the component belongs to.
  12745. */
  12746. scene: Scene;
  12747. /**
  12748. * Creates a new instance of the component for the given scene
  12749. * @param scene Defines the scene to register the component in
  12750. */
  12751. constructor(scene: Scene);
  12752. /**
  12753. * Registers the component in a given scene
  12754. */
  12755. register(): void;
  12756. /**
  12757. * Rebuilds the elements related to this component in case of
  12758. * context lost for instance.
  12759. */
  12760. rebuild(): void;
  12761. /**
  12762. * Disposes the component and the associated ressources
  12763. */
  12764. dispose(): void;
  12765. private _beforeCameraUpdate;
  12766. }
  12767. }
  12768. declare module BABYLON {
  12769. /**
  12770. * Defines supported buttons for XBox360 compatible gamepads
  12771. */
  12772. enum Xbox360Button {
  12773. /** A */
  12774. A = 0,
  12775. /** B */
  12776. B = 1,
  12777. /** X */
  12778. X = 2,
  12779. /** Y */
  12780. Y = 3,
  12781. /** Start */
  12782. Start = 4,
  12783. /** Back */
  12784. Back = 5,
  12785. /** Left button */
  12786. LB = 6,
  12787. /** Right button */
  12788. RB = 7,
  12789. /** Left stick */
  12790. LeftStick = 8,
  12791. /** Right stick */
  12792. RightStick = 9
  12793. }
  12794. /** Defines values for XBox360 DPad */
  12795. enum Xbox360Dpad {
  12796. /** Up */
  12797. Up = 0,
  12798. /** Down */
  12799. Down = 1,
  12800. /** Left */
  12801. Left = 2,
  12802. /** Right */
  12803. Right = 3
  12804. }
  12805. /**
  12806. * Defines a XBox360 gamepad
  12807. */
  12808. class Xbox360Pad extends Gamepad {
  12809. private _leftTrigger;
  12810. private _rightTrigger;
  12811. private _onlefttriggerchanged;
  12812. private _onrighttriggerchanged;
  12813. private _onbuttondown;
  12814. private _onbuttonup;
  12815. private _ondpaddown;
  12816. private _ondpadup;
  12817. /** Observable raised when a button is pressed */
  12818. onButtonDownObservable: Observable<Xbox360Button>;
  12819. /** Observable raised when a button is released */
  12820. onButtonUpObservable: Observable<Xbox360Button>;
  12821. /** Observable raised when a pad is pressed */
  12822. onPadDownObservable: Observable<Xbox360Dpad>;
  12823. /** Observable raised when a pad is released */
  12824. onPadUpObservable: Observable<Xbox360Dpad>;
  12825. private _buttonA;
  12826. private _buttonB;
  12827. private _buttonX;
  12828. private _buttonY;
  12829. private _buttonBack;
  12830. private _buttonStart;
  12831. private _buttonLB;
  12832. private _buttonRB;
  12833. private _buttonLeftStick;
  12834. private _buttonRightStick;
  12835. private _dPadUp;
  12836. private _dPadDown;
  12837. private _dPadLeft;
  12838. private _dPadRight;
  12839. private _isXboxOnePad;
  12840. /**
  12841. * Creates a new XBox360 gamepad object
  12842. * @param id defines the id of this gamepad
  12843. * @param index defines its index
  12844. * @param gamepad defines the internal HTML gamepad object
  12845. * @param xboxOne defines if it is a XBox One gamepad
  12846. */
  12847. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12848. /**
  12849. * Defines the callback to call when left trigger is pressed
  12850. * @param callback defines the callback to use
  12851. */
  12852. onlefttriggerchanged(callback: (value: number) => void): void;
  12853. /**
  12854. * Defines the callback to call when right trigger is pressed
  12855. * @param callback defines the callback to use
  12856. */
  12857. onrighttriggerchanged(callback: (value: number) => void): void;
  12858. /**
  12859. * Gets the left trigger value
  12860. */
  12861. /**
  12862. * Sets the left trigger value
  12863. */
  12864. leftTrigger: number;
  12865. /**
  12866. * Gets the right trigger value
  12867. */
  12868. /**
  12869. * Sets the right trigger value
  12870. */
  12871. rightTrigger: number;
  12872. /**
  12873. * Defines the callback to call when a button is pressed
  12874. * @param callback defines the callback to use
  12875. */
  12876. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12877. /**
  12878. * Defines the callback to call when a button is released
  12879. * @param callback defines the callback to use
  12880. */
  12881. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12882. /**
  12883. * Defines the callback to call when a pad is pressed
  12884. * @param callback defines the callback to use
  12885. */
  12886. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12887. /**
  12888. * Defines the callback to call when a pad is released
  12889. * @param callback defines the callback to use
  12890. */
  12891. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12892. private _setButtonValue;
  12893. private _setDPadValue;
  12894. /**
  12895. * Gets the value of the `A` button
  12896. */
  12897. /**
  12898. * Sets the value of the `A` button
  12899. */
  12900. buttonA: number;
  12901. /**
  12902. * Gets the value of the `B` button
  12903. */
  12904. /**
  12905. * Sets the value of the `B` button
  12906. */
  12907. buttonB: number;
  12908. /**
  12909. * Gets the value of the `X` button
  12910. */
  12911. /**
  12912. * Sets the value of the `X` button
  12913. */
  12914. buttonX: number;
  12915. /**
  12916. * Gets the value of the `Y` button
  12917. */
  12918. /**
  12919. * Sets the value of the `Y` button
  12920. */
  12921. buttonY: number;
  12922. /**
  12923. * Gets the value of the `Start` button
  12924. */
  12925. /**
  12926. * Sets the value of the `Start` button
  12927. */
  12928. buttonStart: number;
  12929. /**
  12930. * Gets the value of the `Back` button
  12931. */
  12932. /**
  12933. * Sets the value of the `Back` button
  12934. */
  12935. buttonBack: number;
  12936. /**
  12937. * Gets the value of the `Left` button
  12938. */
  12939. /**
  12940. * Sets the value of the `Left` button
  12941. */
  12942. buttonLB: number;
  12943. /**
  12944. * Gets the value of the `Right` button
  12945. */
  12946. /**
  12947. * Sets the value of the `Right` button
  12948. */
  12949. buttonRB: number;
  12950. /**
  12951. * Gets the value of the Left joystick
  12952. */
  12953. /**
  12954. * Sets the value of the Left joystick
  12955. */
  12956. buttonLeftStick: number;
  12957. /**
  12958. * Gets the value of the Right joystick
  12959. */
  12960. /**
  12961. * Sets the value of the Right joystick
  12962. */
  12963. buttonRightStick: number;
  12964. /**
  12965. * Gets the value of D-pad up
  12966. */
  12967. /**
  12968. * Sets the value of D-pad up
  12969. */
  12970. dPadUp: number;
  12971. /**
  12972. * Gets the value of D-pad down
  12973. */
  12974. /**
  12975. * Sets the value of D-pad down
  12976. */
  12977. dPadDown: number;
  12978. /**
  12979. * Gets the value of D-pad left
  12980. */
  12981. /**
  12982. * Sets the value of D-pad left
  12983. */
  12984. dPadLeft: number;
  12985. /**
  12986. * Gets the value of D-pad right
  12987. */
  12988. /**
  12989. * Sets the value of D-pad right
  12990. */
  12991. dPadRight: number;
  12992. /**
  12993. * Force the gamepad to synchronize with device values
  12994. */
  12995. update(): void;
  12996. /**
  12997. * Disposes the gamepad
  12998. */
  12999. dispose(): void;
  13000. }
  13001. }
  13002. declare module BABYLON {
  13003. /**
  13004. * Single axis drag gizmo
  13005. */
  13006. class AxisDragGizmo extends Gizmo {
  13007. /**
  13008. * Drag behavior responsible for the gizmos dragging interactions
  13009. */
  13010. dragBehavior: PointerDragBehavior;
  13011. private _pointerObserver;
  13012. /**
  13013. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13014. */
  13015. snapDistance: number;
  13016. /**
  13017. * Event that fires each time the gizmo snaps to a new location.
  13018. * * snapDistance is the the change in distance
  13019. */
  13020. onSnapObservable: Observable<{
  13021. snapDistance: number;
  13022. }>;
  13023. /**
  13024. * Creates an AxisDragGizmo
  13025. * @param gizmoLayer The utility layer the gizmo will be added to
  13026. * @param dragAxis The axis which the gizmo will be able to drag on
  13027. * @param color The color of the gizmo
  13028. */
  13029. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13030. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13031. /**
  13032. * Disposes of the gizmo
  13033. */
  13034. dispose(): void;
  13035. }
  13036. }
  13037. declare module BABYLON {
  13038. /**
  13039. * Single axis scale gizmo
  13040. */
  13041. class AxisScaleGizmo extends Gizmo {
  13042. private _coloredMaterial;
  13043. /**
  13044. * Drag behavior responsible for the gizmos dragging interactions
  13045. */
  13046. dragBehavior: PointerDragBehavior;
  13047. private _pointerObserver;
  13048. /**
  13049. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13050. */
  13051. snapDistance: number;
  13052. /**
  13053. * Event that fires each time the gizmo snaps to a new location.
  13054. * * snapDistance is the the change in distance
  13055. */
  13056. onSnapObservable: Observable<{
  13057. snapDistance: number;
  13058. }>;
  13059. /**
  13060. * If the scaling operation should be done on all axis (default: false)
  13061. */
  13062. uniformScaling: boolean;
  13063. /**
  13064. * Creates an AxisScaleGizmo
  13065. * @param gizmoLayer The utility layer the gizmo will be added to
  13066. * @param dragAxis The axis which the gizmo will be able to scale on
  13067. * @param color The color of the gizmo
  13068. */
  13069. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13070. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13071. /**
  13072. * Disposes of the gizmo
  13073. */
  13074. dispose(): void;
  13075. /**
  13076. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13077. * @param mesh The mesh to replace the default mesh of the gizmo
  13078. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13079. */
  13080. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13081. }
  13082. }
  13083. declare module BABYLON {
  13084. /**
  13085. * Bounding box gizmo
  13086. */
  13087. class BoundingBoxGizmo extends Gizmo {
  13088. private _lineBoundingBox;
  13089. private _rotateSpheresParent;
  13090. private _scaleBoxesParent;
  13091. private _boundingDimensions;
  13092. private _renderObserver;
  13093. private _pointerObserver;
  13094. private _scaleDragSpeed;
  13095. private _tmpQuaternion;
  13096. private _tmpVector;
  13097. private _tmpRotationMatrix;
  13098. /**
  13099. * 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)
  13100. */
  13101. ignoreChildren: boolean;
  13102. /**
  13103. * 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)
  13104. */
  13105. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13106. /**
  13107. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13108. */
  13109. rotationSphereSize: number;
  13110. /**
  13111. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13112. */
  13113. scaleBoxSize: number;
  13114. /**
  13115. * 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)
  13116. */
  13117. fixedDragMeshScreenSize: boolean;
  13118. /**
  13119. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13120. */
  13121. fixedDragMeshScreenSizeDistanceFactor: number;
  13122. /**
  13123. * Fired when a rotation sphere or scale box is dragged
  13124. */
  13125. onDragStartObservable: Observable<{}>;
  13126. /**
  13127. * Fired when a scale box is dragged
  13128. */
  13129. onScaleBoxDragObservable: Observable<{}>;
  13130. /**
  13131. * Fired when a scale box drag is ended
  13132. */
  13133. onScaleBoxDragEndObservable: Observable<{}>;
  13134. /**
  13135. * Fired when a rotation sphere is dragged
  13136. */
  13137. onRotationSphereDragObservable: Observable<{}>;
  13138. /**
  13139. * Fired when a rotation sphere drag is ended
  13140. */
  13141. onRotationSphereDragEndObservable: Observable<{}>;
  13142. /**
  13143. * 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)
  13144. */
  13145. scalePivot: Nullable<Vector3>;
  13146. private _anchorMesh;
  13147. private _existingMeshScale;
  13148. private static _PivotCached;
  13149. private static _OldPivotPoint;
  13150. private static _PivotTranslation;
  13151. private static _PivotTmpVector;
  13152. /** @hidden */
  13153. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13154. /** @hidden */
  13155. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13156. /**
  13157. * Creates an BoundingBoxGizmo
  13158. * @param gizmoLayer The utility layer the gizmo will be added to
  13159. * @param color The color of the gizmo
  13160. */
  13161. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13162. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13163. private _selectNode;
  13164. /**
  13165. * Updates the bounding box information for the Gizmo
  13166. */
  13167. updateBoundingBox(): void;
  13168. /**
  13169. * Enables rotation on the specified axis and disables rotation on the others
  13170. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13171. */
  13172. setEnabledRotationAxis(axis: string): void;
  13173. /**
  13174. * Disposes of the gizmo
  13175. */
  13176. dispose(): void;
  13177. /**
  13178. * 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)
  13179. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13180. * @returns the bounding box mesh with the passed in mesh as a child
  13181. */
  13182. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13183. /**
  13184. * CustomMeshes are not supported by this gizmo
  13185. * @param mesh The mesh to replace the default mesh of the gizmo
  13186. */
  13187. setCustomMesh(mesh: Mesh): void;
  13188. }
  13189. }
  13190. declare module BABYLON {
  13191. /**
  13192. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13193. */
  13194. class Gizmo implements IDisposable {
  13195. /** The utility layer the gizmo will be added to */
  13196. gizmoLayer: UtilityLayerRenderer;
  13197. /**
  13198. * The root mesh of the gizmo
  13199. */
  13200. protected _rootMesh: Mesh;
  13201. private _attachedMesh;
  13202. /**
  13203. * Ratio for the scale of the gizmo (Default: 1)
  13204. */
  13205. scaleRatio: number;
  13206. private _tmpMatrix;
  13207. /**
  13208. * If a custom mesh has been set (Default: false)
  13209. */
  13210. protected _customMeshSet: boolean;
  13211. /**
  13212. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13213. * * When set, interactions will be enabled
  13214. */
  13215. attachedMesh: Nullable<AbstractMesh>;
  13216. /**
  13217. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13218. * @param mesh The mesh to replace the default mesh of the gizmo
  13219. */
  13220. setCustomMesh(mesh: Mesh): void;
  13221. /**
  13222. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13223. */
  13224. updateGizmoRotationToMatchAttachedMesh: boolean;
  13225. /**
  13226. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13227. */
  13228. updateGizmoPositionToMatchAttachedMesh: boolean;
  13229. /**
  13230. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13231. */
  13232. protected _updateScale: boolean;
  13233. protected _interactionsEnabled: boolean;
  13234. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13235. private _beforeRenderObserver;
  13236. /**
  13237. * Creates a gizmo
  13238. * @param gizmoLayer The utility layer the gizmo will be added to
  13239. */
  13240. constructor(
  13241. /** The utility layer the gizmo will be added to */
  13242. gizmoLayer?: UtilityLayerRenderer);
  13243. private _tempVector;
  13244. /**
  13245. * @hidden
  13246. * Updates the gizmo to match the attached mesh's position/rotation
  13247. */
  13248. protected _update(): void;
  13249. /**
  13250. * Disposes of the gizmo
  13251. */
  13252. dispose(): void;
  13253. }
  13254. }
  13255. declare module BABYLON {
  13256. /**
  13257. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13258. */
  13259. class GizmoManager implements IDisposable {
  13260. private scene;
  13261. /**
  13262. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13263. */
  13264. gizmos: {
  13265. positionGizmo: Nullable<PositionGizmo>;
  13266. rotationGizmo: Nullable<RotationGizmo>;
  13267. scaleGizmo: Nullable<ScaleGizmo>;
  13268. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13269. };
  13270. private _gizmosEnabled;
  13271. private _pointerObserver;
  13272. private _attachedMesh;
  13273. private _boundingBoxColor;
  13274. private _defaultUtilityLayer;
  13275. private _defaultKeepDepthUtilityLayer;
  13276. /**
  13277. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13278. */
  13279. boundingBoxDragBehavior: SixDofDragBehavior;
  13280. /**
  13281. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13282. */
  13283. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13284. /**
  13285. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13286. */
  13287. usePointerToAttachGizmos: boolean;
  13288. /**
  13289. * Instatiates a gizmo manager
  13290. * @param scene the scene to overlay the gizmos on top of
  13291. */
  13292. constructor(scene: Scene);
  13293. /**
  13294. * Attaches a set of gizmos to the specified mesh
  13295. * @param mesh The mesh the gizmo's should be attached to
  13296. */
  13297. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13298. /**
  13299. * If the position gizmo is enabled
  13300. */
  13301. positionGizmoEnabled: boolean;
  13302. /**
  13303. * If the rotation gizmo is enabled
  13304. */
  13305. rotationGizmoEnabled: boolean;
  13306. /**
  13307. * If the scale gizmo is enabled
  13308. */
  13309. scaleGizmoEnabled: boolean;
  13310. /**
  13311. * If the boundingBox gizmo is enabled
  13312. */
  13313. boundingBoxGizmoEnabled: boolean;
  13314. /**
  13315. * Disposes of the gizmo manager
  13316. */
  13317. dispose(): void;
  13318. }
  13319. }
  13320. declare module BABYLON {
  13321. /**
  13322. * Single plane rotation gizmo
  13323. */
  13324. class PlaneRotationGizmo extends Gizmo {
  13325. /**
  13326. * Drag behavior responsible for the gizmos dragging interactions
  13327. */
  13328. dragBehavior: PointerDragBehavior;
  13329. private _pointerObserver;
  13330. /**
  13331. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13332. */
  13333. snapDistance: number;
  13334. /**
  13335. * Event that fires each time the gizmo snaps to a new location.
  13336. * * snapDistance is the the change in distance
  13337. */
  13338. onSnapObservable: Observable<{
  13339. snapDistance: number;
  13340. }>;
  13341. /**
  13342. * Creates a PlaneRotationGizmo
  13343. * @param gizmoLayer The utility layer the gizmo will be added to
  13344. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13345. * @param color The color of the gizmo
  13346. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13347. */
  13348. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13349. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13350. /**
  13351. * Disposes of the gizmo
  13352. */
  13353. dispose(): void;
  13354. }
  13355. }
  13356. declare module BABYLON {
  13357. /**
  13358. * Gizmo that enables dragging a mesh along 3 axis
  13359. */
  13360. class PositionGizmo extends Gizmo {
  13361. /**
  13362. * Internal gizmo used for interactions on the x axis
  13363. */
  13364. xGizmo: AxisDragGizmo;
  13365. /**
  13366. * Internal gizmo used for interactions on the y axis
  13367. */
  13368. yGizmo: AxisDragGizmo;
  13369. /**
  13370. * Internal gizmo used for interactions on the z axis
  13371. */
  13372. zGizmo: AxisDragGizmo;
  13373. /** Fires an event when any of it's sub gizmos are dragged */
  13374. onDragStartObservable: Observable<{}>;
  13375. /** Fires an event when any of it's sub gizmos are released from dragging */
  13376. onDragEndObservable: Observable<{}>;
  13377. attachedMesh: Nullable<AbstractMesh>;
  13378. /**
  13379. * Creates a PositionGizmo
  13380. * @param gizmoLayer The utility layer the gizmo will be added to
  13381. */
  13382. constructor(gizmoLayer?: UtilityLayerRenderer);
  13383. updateGizmoRotationToMatchAttachedMesh: boolean;
  13384. /**
  13385. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13386. */
  13387. snapDistance: number;
  13388. /**
  13389. * Ratio for the scale of the gizmo (Default: 1)
  13390. */
  13391. scaleRatio: number;
  13392. /**
  13393. * Disposes of the gizmo
  13394. */
  13395. dispose(): void;
  13396. /**
  13397. * CustomMeshes are not supported by this gizmo
  13398. * @param mesh The mesh to replace the default mesh of the gizmo
  13399. */
  13400. setCustomMesh(mesh: Mesh): void;
  13401. }
  13402. }
  13403. declare module BABYLON {
  13404. /**
  13405. * Gizmo that enables rotating a mesh along 3 axis
  13406. */
  13407. class RotationGizmo extends Gizmo {
  13408. /**
  13409. * Internal gizmo used for interactions on the x axis
  13410. */
  13411. xGizmo: PlaneRotationGizmo;
  13412. /**
  13413. * Internal gizmo used for interactions on the y axis
  13414. */
  13415. yGizmo: PlaneRotationGizmo;
  13416. /**
  13417. * Internal gizmo used for interactions on the z axis
  13418. */
  13419. zGizmo: PlaneRotationGizmo;
  13420. /** Fires an event when any of it's sub gizmos are dragged */
  13421. onDragStartObservable: Observable<{}>;
  13422. /** Fires an event when any of it's sub gizmos are released from dragging */
  13423. onDragEndObservable: Observable<{}>;
  13424. attachedMesh: Nullable<AbstractMesh>;
  13425. /**
  13426. * Creates a RotationGizmo
  13427. * @param gizmoLayer The utility layer the gizmo will be added to
  13428. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13429. */
  13430. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13431. updateGizmoRotationToMatchAttachedMesh: boolean;
  13432. /**
  13433. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13434. */
  13435. snapDistance: number;
  13436. /**
  13437. * Ratio for the scale of the gizmo (Default: 1)
  13438. */
  13439. scaleRatio: number;
  13440. /**
  13441. * Disposes of the gizmo
  13442. */
  13443. dispose(): void;
  13444. /**
  13445. * CustomMeshes are not supported by this gizmo
  13446. * @param mesh The mesh to replace the default mesh of the gizmo
  13447. */
  13448. setCustomMesh(mesh: Mesh): void;
  13449. }
  13450. }
  13451. declare module BABYLON {
  13452. /**
  13453. * Gizmo that enables scaling a mesh along 3 axis
  13454. */
  13455. class ScaleGizmo extends Gizmo {
  13456. /**
  13457. * Internal gizmo used for interactions on the x axis
  13458. */
  13459. xGizmo: AxisScaleGizmo;
  13460. /**
  13461. * Internal gizmo used for interactions on the y axis
  13462. */
  13463. yGizmo: AxisScaleGizmo;
  13464. /**
  13465. * Internal gizmo used for interactions on the z axis
  13466. */
  13467. zGizmo: AxisScaleGizmo;
  13468. /**
  13469. * Internal gizmo used to scale all axis equally
  13470. */
  13471. uniformScaleGizmo: AxisScaleGizmo;
  13472. /** Fires an event when any of it's sub gizmos are dragged */
  13473. onDragStartObservable: Observable<{}>;
  13474. /** Fires an event when any of it's sub gizmos are released from dragging */
  13475. onDragEndObservable: Observable<{}>;
  13476. attachedMesh: Nullable<AbstractMesh>;
  13477. /**
  13478. * Creates a ScaleGizmo
  13479. * @param gizmoLayer The utility layer the gizmo will be added to
  13480. */
  13481. constructor(gizmoLayer?: UtilityLayerRenderer);
  13482. updateGizmoRotationToMatchAttachedMesh: boolean;
  13483. /**
  13484. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13485. */
  13486. snapDistance: number;
  13487. /**
  13488. * Ratio for the scale of the gizmo (Default: 1)
  13489. */
  13490. scaleRatio: number;
  13491. /**
  13492. * Disposes of the gizmo
  13493. */
  13494. dispose(): void;
  13495. }
  13496. }
  13497. declare module BABYLON {
  13498. /**
  13499. * Represents the different options available during the creation of
  13500. * a Environment helper.
  13501. *
  13502. * This can control the default ground, skybox and image processing setup of your scene.
  13503. */
  13504. interface IEnvironmentHelperOptions {
  13505. /**
  13506. * Specifies wether or not to create a ground.
  13507. * True by default.
  13508. */
  13509. createGround: boolean;
  13510. /**
  13511. * Specifies the ground size.
  13512. * 15 by default.
  13513. */
  13514. groundSize: number;
  13515. /**
  13516. * The texture used on the ground for the main color.
  13517. * Comes from the BabylonJS CDN by default.
  13518. *
  13519. * Remarks: Can be either a texture or a url.
  13520. */
  13521. groundTexture: string | BaseTexture;
  13522. /**
  13523. * The color mixed in the ground texture by default.
  13524. * BabylonJS clearColor by default.
  13525. */
  13526. groundColor: Color3;
  13527. /**
  13528. * Specifies the ground opacity.
  13529. * 1 by default.
  13530. */
  13531. groundOpacity: number;
  13532. /**
  13533. * Enables the ground to receive shadows.
  13534. * True by default.
  13535. */
  13536. enableGroundShadow: boolean;
  13537. /**
  13538. * Helps preventing the shadow to be fully black on the ground.
  13539. * 0.5 by default.
  13540. */
  13541. groundShadowLevel: number;
  13542. /**
  13543. * Creates a mirror texture attach to the ground.
  13544. * false by default.
  13545. */
  13546. enableGroundMirror: boolean;
  13547. /**
  13548. * Specifies the ground mirror size ratio.
  13549. * 0.3 by default as the default kernel is 64.
  13550. */
  13551. groundMirrorSizeRatio: number;
  13552. /**
  13553. * Specifies the ground mirror blur kernel size.
  13554. * 64 by default.
  13555. */
  13556. groundMirrorBlurKernel: number;
  13557. /**
  13558. * Specifies the ground mirror visibility amount.
  13559. * 1 by default
  13560. */
  13561. groundMirrorAmount: number;
  13562. /**
  13563. * Specifies the ground mirror reflectance weight.
  13564. * This uses the standard weight of the background material to setup the fresnel effect
  13565. * of the mirror.
  13566. * 1 by default.
  13567. */
  13568. groundMirrorFresnelWeight: number;
  13569. /**
  13570. * Specifies the ground mirror Falloff distance.
  13571. * This can helps reducing the size of the reflection.
  13572. * 0 by Default.
  13573. */
  13574. groundMirrorFallOffDistance: number;
  13575. /**
  13576. * Specifies the ground mirror texture type.
  13577. * Unsigned Int by Default.
  13578. */
  13579. groundMirrorTextureType: number;
  13580. /**
  13581. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13582. * the shown objects.
  13583. */
  13584. groundYBias: number;
  13585. /**
  13586. * Specifies wether or not to create a skybox.
  13587. * True by default.
  13588. */
  13589. createSkybox: boolean;
  13590. /**
  13591. * Specifies the skybox size.
  13592. * 20 by default.
  13593. */
  13594. skyboxSize: number;
  13595. /**
  13596. * The texture used on the skybox for the main color.
  13597. * Comes from the BabylonJS CDN by default.
  13598. *
  13599. * Remarks: Can be either a texture or a url.
  13600. */
  13601. skyboxTexture: string | BaseTexture;
  13602. /**
  13603. * The color mixed in the skybox texture by default.
  13604. * BabylonJS clearColor by default.
  13605. */
  13606. skyboxColor: Color3;
  13607. /**
  13608. * The background rotation around the Y axis of the scene.
  13609. * This helps aligning the key lights of your scene with the background.
  13610. * 0 by default.
  13611. */
  13612. backgroundYRotation: number;
  13613. /**
  13614. * Compute automatically the size of the elements to best fit with the scene.
  13615. */
  13616. sizeAuto: boolean;
  13617. /**
  13618. * Default position of the rootMesh if autoSize is not true.
  13619. */
  13620. rootPosition: Vector3;
  13621. /**
  13622. * Sets up the image processing in the scene.
  13623. * true by default.
  13624. */
  13625. setupImageProcessing: boolean;
  13626. /**
  13627. * The texture used as your environment texture in the scene.
  13628. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13629. *
  13630. * Remarks: Can be either a texture or a url.
  13631. */
  13632. environmentTexture: string | BaseTexture;
  13633. /**
  13634. * The value of the exposure to apply to the scene.
  13635. * 0.6 by default if setupImageProcessing is true.
  13636. */
  13637. cameraExposure: number;
  13638. /**
  13639. * The value of the contrast to apply to the scene.
  13640. * 1.6 by default if setupImageProcessing is true.
  13641. */
  13642. cameraContrast: number;
  13643. /**
  13644. * Specifies wether or not tonemapping should be enabled in the scene.
  13645. * true by default if setupImageProcessing is true.
  13646. */
  13647. toneMappingEnabled: boolean;
  13648. }
  13649. /**
  13650. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13651. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13652. * It also helps with the default setup of your imageProcessing configuration.
  13653. */
  13654. class EnvironmentHelper {
  13655. /**
  13656. * Default ground texture URL.
  13657. */
  13658. private static _groundTextureCDNUrl;
  13659. /**
  13660. * Default skybox texture URL.
  13661. */
  13662. private static _skyboxTextureCDNUrl;
  13663. /**
  13664. * Default environment texture URL.
  13665. */
  13666. private static _environmentTextureCDNUrl;
  13667. /**
  13668. * Creates the default options for the helper.
  13669. */
  13670. private static _getDefaultOptions;
  13671. private _rootMesh;
  13672. /**
  13673. * Gets the root mesh created by the helper.
  13674. */
  13675. readonly rootMesh: Mesh;
  13676. private _skybox;
  13677. /**
  13678. * Gets the skybox created by the helper.
  13679. */
  13680. readonly skybox: Nullable<Mesh>;
  13681. private _skyboxTexture;
  13682. /**
  13683. * Gets the skybox texture created by the helper.
  13684. */
  13685. readonly skyboxTexture: Nullable<BaseTexture>;
  13686. private _skyboxMaterial;
  13687. /**
  13688. * Gets the skybox material created by the helper.
  13689. */
  13690. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13691. private _ground;
  13692. /**
  13693. * Gets the ground mesh created by the helper.
  13694. */
  13695. readonly ground: Nullable<Mesh>;
  13696. private _groundTexture;
  13697. /**
  13698. * Gets the ground texture created by the helper.
  13699. */
  13700. readonly groundTexture: Nullable<BaseTexture>;
  13701. private _groundMirror;
  13702. /**
  13703. * Gets the ground mirror created by the helper.
  13704. */
  13705. readonly groundMirror: Nullable<MirrorTexture>;
  13706. /**
  13707. * Gets the ground mirror render list to helps pushing the meshes
  13708. * you wish in the ground reflection.
  13709. */
  13710. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13711. private _groundMaterial;
  13712. /**
  13713. * Gets the ground material created by the helper.
  13714. */
  13715. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13716. /**
  13717. * Stores the creation options.
  13718. */
  13719. private readonly _scene;
  13720. private _options;
  13721. /**
  13722. * This observable will be notified with any error during the creation of the environment,
  13723. * mainly texture creation errors.
  13724. */
  13725. onErrorObservable: Observable<{
  13726. message?: string;
  13727. exception?: any;
  13728. }>;
  13729. /**
  13730. * constructor
  13731. * @param options
  13732. * @param scene The scene to add the material to
  13733. */
  13734. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13735. /**
  13736. * Updates the background according to the new options
  13737. * @param options
  13738. */
  13739. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13740. /**
  13741. * Sets the primary color of all the available elements.
  13742. * @param color the main color to affect to the ground and the background
  13743. */
  13744. setMainColor(color: Color3): void;
  13745. /**
  13746. * Setup the image processing according to the specified options.
  13747. */
  13748. private _setupImageProcessing;
  13749. /**
  13750. * Setup the environment texture according to the specified options.
  13751. */
  13752. private _setupEnvironmentTexture;
  13753. /**
  13754. * Setup the background according to the specified options.
  13755. */
  13756. private _setupBackground;
  13757. /**
  13758. * Get the scene sizes according to the setup.
  13759. */
  13760. private _getSceneSize;
  13761. /**
  13762. * Setup the ground according to the specified options.
  13763. */
  13764. private _setupGround;
  13765. /**
  13766. * Setup the ground material according to the specified options.
  13767. */
  13768. private _setupGroundMaterial;
  13769. /**
  13770. * Setup the ground diffuse texture according to the specified options.
  13771. */
  13772. private _setupGroundDiffuseTexture;
  13773. /**
  13774. * Setup the ground mirror texture according to the specified options.
  13775. */
  13776. private _setupGroundMirrorTexture;
  13777. /**
  13778. * Setup the ground to receive the mirror texture.
  13779. */
  13780. private _setupMirrorInGroundMaterial;
  13781. /**
  13782. * Setup the skybox according to the specified options.
  13783. */
  13784. private _setupSkybox;
  13785. /**
  13786. * Setup the skybox material according to the specified options.
  13787. */
  13788. private _setupSkyboxMaterial;
  13789. /**
  13790. * Setup the skybox reflection texture according to the specified options.
  13791. */
  13792. private _setupSkyboxReflectionTexture;
  13793. private _errorHandler;
  13794. /**
  13795. * Dispose all the elements created by the Helper.
  13796. */
  13797. dispose(): void;
  13798. }
  13799. }
  13800. declare module BABYLON {
  13801. /**
  13802. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13803. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13804. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13805. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13806. */
  13807. class PhotoDome extends TransformNode {
  13808. private _useDirectMapping;
  13809. /**
  13810. * The texture being displayed on the sphere
  13811. */
  13812. protected _photoTexture: Texture;
  13813. /**
  13814. * Gets or sets the texture being displayed on the sphere
  13815. */
  13816. photoTexture: Texture;
  13817. /**
  13818. * Observable raised when an error occured while loading the 360 image
  13819. */
  13820. onLoadErrorObservable: Observable<string>;
  13821. /**
  13822. * The skybox material
  13823. */
  13824. protected _material: BackgroundMaterial;
  13825. /**
  13826. * The surface used for the skybox
  13827. */
  13828. protected _mesh: Mesh;
  13829. /**
  13830. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13831. * Also see the options.resolution property.
  13832. */
  13833. fovMultiplier: number;
  13834. /**
  13835. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13836. * @param name Element's name, child elements will append suffixes for their own names.
  13837. * @param urlsOfPhoto defines the url of the photo to display
  13838. * @param options defines an object containing optional or exposed sub element properties
  13839. * @param onError defines a callback called when an error occured while loading the texture
  13840. */
  13841. constructor(name: string, urlOfPhoto: string, options: {
  13842. resolution?: number;
  13843. size?: number;
  13844. useDirectMapping?: boolean;
  13845. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13846. /**
  13847. * Releases resources associated with this node.
  13848. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13849. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13850. */
  13851. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13852. }
  13853. }
  13854. declare module BABYLON {
  13855. interface Scene {
  13856. /**
  13857. * Creates a default light for the scene.
  13858. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13859. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13860. */
  13861. createDefaultLight(replace?: boolean): void;
  13862. /**
  13863. * Creates a default camera for the scene.
  13864. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13865. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13866. * @param replace has default false, when true replaces the active camera in the scene
  13867. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13868. */
  13869. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13870. /**
  13871. * Creates a default camera and a default light.
  13872. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13873. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13874. * @param replace has the default false, when true replaces the active camera/light in the scene
  13875. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13876. */
  13877. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13878. /**
  13879. * Creates a new sky box
  13880. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13881. * @param environmentTexture defines the texture to use as environment texture
  13882. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13883. * @param scale defines the overall scale of the skybox
  13884. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13885. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13886. * @returns a new mesh holding the sky box
  13887. */
  13888. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13889. /**
  13890. * Creates a new environment
  13891. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13892. * @param options defines the options you can use to configure the environment
  13893. * @returns the new EnvironmentHelper
  13894. */
  13895. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13896. /**
  13897. * Creates a new VREXperienceHelper
  13898. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13899. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13900. * @returns a new VREXperienceHelper
  13901. */
  13902. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13903. /**
  13904. * Creates a new XREXperienceHelper
  13905. * @see http://doc.babylonjs.com/how_to/webxr
  13906. * @returns a promise for a new XREXperienceHelper
  13907. */
  13908. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  13909. }
  13910. }
  13911. declare module BABYLON {
  13912. /**
  13913. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13914. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13915. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13916. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13917. */
  13918. class VideoDome extends TransformNode {
  13919. private _useDirectMapping;
  13920. /**
  13921. * The video texture being displayed on the sphere
  13922. */
  13923. protected _videoTexture: VideoTexture;
  13924. /**
  13925. * Gets the video texture being displayed on the sphere
  13926. */
  13927. readonly videoTexture: VideoTexture;
  13928. /**
  13929. * The skybox material
  13930. */
  13931. protected _material: BackgroundMaterial;
  13932. /**
  13933. * The surface used for the skybox
  13934. */
  13935. protected _mesh: Mesh;
  13936. /**
  13937. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13938. * Also see the options.resolution property.
  13939. */
  13940. fovMultiplier: number;
  13941. /**
  13942. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13943. * @param name Element's name, child elements will append suffixes for their own names.
  13944. * @param urlsOrVideo defines the url(s) or the video element to use
  13945. * @param options An object containing optional or exposed sub element properties
  13946. */
  13947. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13948. resolution?: number;
  13949. clickToPlay?: boolean;
  13950. autoPlay?: boolean;
  13951. loop?: boolean;
  13952. size?: number;
  13953. poster?: string;
  13954. useDirectMapping?: boolean;
  13955. }, scene: Scene);
  13956. /**
  13957. * Releases resources associated with this node.
  13958. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13959. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13960. */
  13961. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13962. }
  13963. }
  13964. declare module BABYLON {
  13965. /**
  13966. * This class can be used to get instrumentation data from a Babylon engine
  13967. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13968. */
  13969. class EngineInstrumentation implements IDisposable {
  13970. /**
  13971. * Define the instrumented engine.
  13972. */
  13973. engine: Engine;
  13974. private _captureGPUFrameTime;
  13975. private _gpuFrameTimeToken;
  13976. private _gpuFrameTime;
  13977. private _captureShaderCompilationTime;
  13978. private _shaderCompilationTime;
  13979. private _onBeginFrameObserver;
  13980. private _onEndFrameObserver;
  13981. private _onBeforeShaderCompilationObserver;
  13982. private _onAfterShaderCompilationObserver;
  13983. /**
  13984. * Gets the perf counter used for GPU frame time
  13985. */
  13986. readonly gpuFrameTimeCounter: PerfCounter;
  13987. /**
  13988. * Gets the GPU frame time capture status
  13989. */
  13990. /**
  13991. * Enable or disable the GPU frame time capture
  13992. */
  13993. captureGPUFrameTime: boolean;
  13994. /**
  13995. * Gets the perf counter used for shader compilation time
  13996. */
  13997. readonly shaderCompilationTimeCounter: PerfCounter;
  13998. /**
  13999. * Gets the shader compilation time capture status
  14000. */
  14001. /**
  14002. * Enable or disable the shader compilation time capture
  14003. */
  14004. captureShaderCompilationTime: boolean;
  14005. /**
  14006. * Instantiates a new engine instrumentation.
  14007. * This class can be used to get instrumentation data from a Babylon engine
  14008. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14009. * @param engine Defines the engine to instrument
  14010. */
  14011. constructor(
  14012. /**
  14013. * Define the instrumented engine.
  14014. */
  14015. engine: Engine);
  14016. /**
  14017. * Dispose and release associated resources.
  14018. */
  14019. dispose(): void;
  14020. }
  14021. }
  14022. declare module BABYLON {
  14023. /**
  14024. * This class can be used to get instrumentation data from a Babylon engine
  14025. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14026. */
  14027. class SceneInstrumentation implements IDisposable {
  14028. /**
  14029. * Defines the scene to instrument
  14030. */
  14031. scene: Scene;
  14032. private _captureActiveMeshesEvaluationTime;
  14033. private _activeMeshesEvaluationTime;
  14034. private _captureRenderTargetsRenderTime;
  14035. private _renderTargetsRenderTime;
  14036. private _captureFrameTime;
  14037. private _frameTime;
  14038. private _captureRenderTime;
  14039. private _renderTime;
  14040. private _captureInterFrameTime;
  14041. private _interFrameTime;
  14042. private _captureParticlesRenderTime;
  14043. private _particlesRenderTime;
  14044. private _captureSpritesRenderTime;
  14045. private _spritesRenderTime;
  14046. private _capturePhysicsTime;
  14047. private _physicsTime;
  14048. private _captureAnimationsTime;
  14049. private _animationsTime;
  14050. private _captureCameraRenderTime;
  14051. private _cameraRenderTime;
  14052. private _onBeforeActiveMeshesEvaluationObserver;
  14053. private _onAfterActiveMeshesEvaluationObserver;
  14054. private _onBeforeRenderTargetsRenderObserver;
  14055. private _onAfterRenderTargetsRenderObserver;
  14056. private _onAfterRenderObserver;
  14057. private _onBeforeDrawPhaseObserver;
  14058. private _onAfterDrawPhaseObserver;
  14059. private _onBeforeAnimationsObserver;
  14060. private _onBeforeParticlesRenderingObserver;
  14061. private _onAfterParticlesRenderingObserver;
  14062. private _onBeforeSpritesRenderingObserver;
  14063. private _onAfterSpritesRenderingObserver;
  14064. private _onBeforePhysicsObserver;
  14065. private _onAfterPhysicsObserver;
  14066. private _onAfterAnimationsObserver;
  14067. private _onBeforeCameraRenderObserver;
  14068. private _onAfterCameraRenderObserver;
  14069. /**
  14070. * Gets the perf counter used for active meshes evaluation time
  14071. */
  14072. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14073. /**
  14074. * Gets the active meshes evaluation time capture status
  14075. */
  14076. /**
  14077. * Enable or disable the active meshes evaluation time capture
  14078. */
  14079. captureActiveMeshesEvaluationTime: boolean;
  14080. /**
  14081. * Gets the perf counter used for render targets render time
  14082. */
  14083. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14084. /**
  14085. * Gets the render targets render time capture status
  14086. */
  14087. /**
  14088. * Enable or disable the render targets render time capture
  14089. */
  14090. captureRenderTargetsRenderTime: boolean;
  14091. /**
  14092. * Gets the perf counter used for particles render time
  14093. */
  14094. readonly particlesRenderTimeCounter: PerfCounter;
  14095. /**
  14096. * Gets the particles render time capture status
  14097. */
  14098. /**
  14099. * Enable or disable the particles render time capture
  14100. */
  14101. captureParticlesRenderTime: boolean;
  14102. /**
  14103. * Gets the perf counter used for sprites render time
  14104. */
  14105. readonly spritesRenderTimeCounter: PerfCounter;
  14106. /**
  14107. * Gets the sprites render time capture status
  14108. */
  14109. /**
  14110. * Enable or disable the sprites render time capture
  14111. */
  14112. captureSpritesRenderTime: boolean;
  14113. /**
  14114. * Gets the perf counter used for physics time
  14115. */
  14116. readonly physicsTimeCounter: PerfCounter;
  14117. /**
  14118. * Gets the physics time capture status
  14119. */
  14120. /**
  14121. * Enable or disable the physics time capture
  14122. */
  14123. capturePhysicsTime: boolean;
  14124. /**
  14125. * Gets the perf counter used for animations time
  14126. */
  14127. readonly animationsTimeCounter: PerfCounter;
  14128. /**
  14129. * Gets the animations time capture status
  14130. */
  14131. /**
  14132. * Enable or disable the animations time capture
  14133. */
  14134. captureAnimationsTime: boolean;
  14135. /**
  14136. * Gets the perf counter used for frame time capture
  14137. */
  14138. readonly frameTimeCounter: PerfCounter;
  14139. /**
  14140. * Gets the frame time capture status
  14141. */
  14142. /**
  14143. * Enable or disable the frame time capture
  14144. */
  14145. captureFrameTime: boolean;
  14146. /**
  14147. * Gets the perf counter used for inter-frames time capture
  14148. */
  14149. readonly interFrameTimeCounter: PerfCounter;
  14150. /**
  14151. * Gets the inter-frames time capture status
  14152. */
  14153. /**
  14154. * Enable or disable the inter-frames time capture
  14155. */
  14156. captureInterFrameTime: boolean;
  14157. /**
  14158. * Gets the perf counter used for render time capture
  14159. */
  14160. readonly renderTimeCounter: PerfCounter;
  14161. /**
  14162. * Gets the render time capture status
  14163. */
  14164. /**
  14165. * Enable or disable the render time capture
  14166. */
  14167. captureRenderTime: boolean;
  14168. /**
  14169. * Gets the perf counter used for camera render time capture
  14170. */
  14171. readonly cameraRenderTimeCounter: PerfCounter;
  14172. /**
  14173. * Gets the camera render time capture status
  14174. */
  14175. /**
  14176. * Enable or disable the camera render time capture
  14177. */
  14178. captureCameraRenderTime: boolean;
  14179. /**
  14180. * Gets the perf counter used for draw calls
  14181. */
  14182. readonly drawCallsCounter: PerfCounter;
  14183. /**
  14184. * Gets the perf counter used for texture collisions
  14185. */
  14186. readonly textureCollisionsCounter: PerfCounter;
  14187. /**
  14188. * Instantiates a new scene instrumentation.
  14189. * This class can be used to get instrumentation data from a Babylon engine
  14190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14191. * @param scene Defines the scene to instrument
  14192. */
  14193. constructor(
  14194. /**
  14195. * Defines the scene to instrument
  14196. */
  14197. scene: Scene);
  14198. /**
  14199. * Dispose and release associated resources.
  14200. */
  14201. dispose(): void;
  14202. }
  14203. }
  14204. declare module BABYLON {
  14205. /**
  14206. * @hidden
  14207. **/
  14208. class _TimeToken {
  14209. _startTimeQuery: Nullable<WebGLQuery>;
  14210. _endTimeQuery: Nullable<WebGLQuery>;
  14211. _timeElapsedQuery: Nullable<WebGLQuery>;
  14212. _timeElapsedQueryEnded: boolean;
  14213. }
  14214. }
  14215. declare module BABYLON {
  14216. /**
  14217. * Effect layer options. This helps customizing the behaviour
  14218. * of the effect layer.
  14219. */
  14220. interface IEffectLayerOptions {
  14221. /**
  14222. * Multiplication factor apply to the canvas size to compute the render target size
  14223. * used to generated the objects (the smaller the faster).
  14224. */
  14225. mainTextureRatio: number;
  14226. /**
  14227. * Enforces a fixed size texture to ensure effect stability across devices.
  14228. */
  14229. mainTextureFixedSize?: number;
  14230. /**
  14231. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14232. */
  14233. alphaBlendingMode: number;
  14234. /**
  14235. * The camera attached to the layer.
  14236. */
  14237. camera: Nullable<Camera>;
  14238. /**
  14239. * The rendering group to draw the layer in.
  14240. */
  14241. renderingGroupId: number;
  14242. }
  14243. /**
  14244. * The effect layer Helps adding post process effect blended with the main pass.
  14245. *
  14246. * This can be for instance use to generate glow or higlight effects on the scene.
  14247. *
  14248. * The effect layer class can not be used directly and is intented to inherited from to be
  14249. * customized per effects.
  14250. */
  14251. abstract class EffectLayer {
  14252. private _vertexBuffers;
  14253. private _indexBuffer;
  14254. private _cachedDefines;
  14255. private _effectLayerMapGenerationEffect;
  14256. private _effectLayerOptions;
  14257. private _mergeEffect;
  14258. protected _scene: Scene;
  14259. protected _engine: Engine;
  14260. protected _maxSize: number;
  14261. protected _mainTextureDesiredSize: ISize;
  14262. protected _mainTexture: RenderTargetTexture;
  14263. protected _shouldRender: boolean;
  14264. protected _postProcesses: PostProcess[];
  14265. protected _textures: BaseTexture[];
  14266. protected _emissiveTextureAndColor: {
  14267. texture: Nullable<BaseTexture>;
  14268. color: Color4;
  14269. };
  14270. /**
  14271. * The name of the layer
  14272. */
  14273. name: string;
  14274. /**
  14275. * The clear color of the texture used to generate the glow map.
  14276. */
  14277. neutralColor: Color4;
  14278. /**
  14279. * Specifies wether the highlight layer is enabled or not.
  14280. */
  14281. isEnabled: boolean;
  14282. /**
  14283. * Gets the camera attached to the layer.
  14284. */
  14285. readonly camera: Nullable<Camera>;
  14286. /**
  14287. * Gets the rendering group id the layer should render in.
  14288. */
  14289. readonly renderingGroupId: number;
  14290. /**
  14291. * An event triggered when the effect layer has been disposed.
  14292. */
  14293. onDisposeObservable: Observable<EffectLayer>;
  14294. /**
  14295. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14296. */
  14297. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14298. /**
  14299. * An event triggered when the generated texture is being merged in the scene.
  14300. */
  14301. onBeforeComposeObservable: Observable<EffectLayer>;
  14302. /**
  14303. * An event triggered when the generated texture has been merged in the scene.
  14304. */
  14305. onAfterComposeObservable: Observable<EffectLayer>;
  14306. /**
  14307. * An event triggered when the efffect layer changes its size.
  14308. */
  14309. onSizeChangedObservable: Observable<EffectLayer>;
  14310. /**
  14311. * Instantiates a new effect Layer and references it in the scene.
  14312. * @param name The name of the layer
  14313. * @param scene The scene to use the layer in
  14314. */
  14315. constructor(
  14316. /** The Friendly of the effect in the scene */
  14317. name: string, scene: Scene);
  14318. /**
  14319. * Get the effect name of the layer.
  14320. * @return The effect name
  14321. */
  14322. abstract getEffectName(): string;
  14323. /**
  14324. * Checks for the readiness of the element composing the layer.
  14325. * @param subMesh the mesh to check for
  14326. * @param useInstances specify wether or not to use instances to render the mesh
  14327. * @return true if ready otherwise, false
  14328. */
  14329. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14330. /**
  14331. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14332. * @returns true if the effect requires stencil during the main canvas render pass.
  14333. */
  14334. abstract needStencil(): boolean;
  14335. /**
  14336. * Create the merge effect. This is the shader use to blit the information back
  14337. * to the main canvas at the end of the scene rendering.
  14338. * @returns The effect containing the shader used to merge the effect on the main canvas
  14339. */
  14340. protected abstract _createMergeEffect(): Effect;
  14341. /**
  14342. * Creates the render target textures and post processes used in the effect layer.
  14343. */
  14344. protected abstract _createTextureAndPostProcesses(): void;
  14345. /**
  14346. * Implementation specific of rendering the generating effect on the main canvas.
  14347. * @param effect The effect used to render through
  14348. */
  14349. protected abstract _internalRender(effect: Effect): void;
  14350. /**
  14351. * Sets the required values for both the emissive texture and and the main color.
  14352. */
  14353. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14354. /**
  14355. * Free any resources and references associated to a mesh.
  14356. * Internal use
  14357. * @param mesh The mesh to free.
  14358. */
  14359. abstract _disposeMesh(mesh: Mesh): void;
  14360. /**
  14361. * Serializes this layer (Glow or Highlight for example)
  14362. * @returns a serialized layer object
  14363. */
  14364. abstract serialize?(): any;
  14365. /**
  14366. * Initializes the effect layer with the required options.
  14367. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14368. */
  14369. protected _init(options: Partial<IEffectLayerOptions>): void;
  14370. /**
  14371. * Generates the index buffer of the full screen quad blending to the main canvas.
  14372. */
  14373. private _generateIndexBuffer;
  14374. /**
  14375. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14376. */
  14377. private _genrateVertexBuffer;
  14378. /**
  14379. * Sets the main texture desired size which is the closest power of two
  14380. * of the engine canvas size.
  14381. */
  14382. private _setMainTextureSize;
  14383. /**
  14384. * Creates the main texture for the effect layer.
  14385. */
  14386. protected _createMainTexture(): void;
  14387. /**
  14388. * Checks for the readiness of the element composing the layer.
  14389. * @param subMesh the mesh to check for
  14390. * @param useInstances specify wether or not to use instances to render the mesh
  14391. * @param emissiveTexture the associated emissive texture used to generate the glow
  14392. * @return true if ready otherwise, false
  14393. */
  14394. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14395. /**
  14396. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14397. */
  14398. render(): void;
  14399. /**
  14400. * Determine if a given mesh will be used in the current effect.
  14401. * @param mesh mesh to test
  14402. * @returns true if the mesh will be used
  14403. */
  14404. hasMesh(mesh: AbstractMesh): boolean;
  14405. /**
  14406. * Returns true if the layer contains information to display, otherwise false.
  14407. * @returns true if the glow layer should be rendered
  14408. */
  14409. shouldRender(): boolean;
  14410. /**
  14411. * Returns true if the mesh should render, otherwise false.
  14412. * @param mesh The mesh to render
  14413. * @returns true if it should render otherwise false
  14414. */
  14415. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14416. /**
  14417. * Returns true if the mesh should render, otherwise false.
  14418. * @param mesh The mesh to render
  14419. * @returns true if it should render otherwise false
  14420. */
  14421. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14422. /**
  14423. * Renders the submesh passed in parameter to the generation map.
  14424. */
  14425. protected _renderSubMesh(subMesh: SubMesh): void;
  14426. /**
  14427. * Rebuild the required buffers.
  14428. * @hidden Internal use only.
  14429. */
  14430. _rebuild(): void;
  14431. /**
  14432. * Dispose only the render target textures and post process.
  14433. */
  14434. private _disposeTextureAndPostProcesses;
  14435. /**
  14436. * Dispose the highlight layer and free resources.
  14437. */
  14438. dispose(): void;
  14439. /**
  14440. * Gets the class name of the effect layer
  14441. * @returns the string with the class name of the effect layer
  14442. */
  14443. getClassName(): string;
  14444. /**
  14445. * Creates an effect layer from parsed effect layer data
  14446. * @param parsedEffectLayer defines effect layer data
  14447. * @param scene defines the current scene
  14448. * @param rootUrl defines the root URL containing the effect layer information
  14449. * @returns a parsed effect Layer
  14450. */
  14451. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14452. }
  14453. }
  14454. declare module BABYLON {
  14455. interface AbstractScene {
  14456. /**
  14457. * The list of effect layers (highlights/glow) added to the scene
  14458. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14459. * @see http://doc.babylonjs.com/how_to/glow_layer
  14460. */
  14461. effectLayers: Array<EffectLayer>;
  14462. /**
  14463. * Removes the given effect layer from this scene.
  14464. * @param toRemove defines the effect layer to remove
  14465. * @returns the index of the removed effect layer
  14466. */
  14467. removeEffectLayer(toRemove: EffectLayer): number;
  14468. /**
  14469. * Adds the given effect layer to this scene
  14470. * @param newEffectLayer defines the effect layer to add
  14471. */
  14472. addEffectLayer(newEffectLayer: EffectLayer): void;
  14473. }
  14474. /**
  14475. * Defines the layer scene component responsible to manage any effect layers
  14476. * in a given scene.
  14477. */
  14478. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14479. /**
  14480. * The component name helpfull to identify the component in the list of scene components.
  14481. */
  14482. readonly name: string;
  14483. /**
  14484. * The scene the component belongs to.
  14485. */
  14486. scene: Scene;
  14487. private _engine;
  14488. private _renderEffects;
  14489. private _needStencil;
  14490. private _previousStencilState;
  14491. /**
  14492. * Creates a new instance of the component for the given scene
  14493. * @param scene Defines the scene to register the component in
  14494. */
  14495. constructor(scene: Scene);
  14496. /**
  14497. * Registers the component in a given scene
  14498. */
  14499. register(): void;
  14500. /**
  14501. * Rebuilds the elements related to this component in case of
  14502. * context lost for instance.
  14503. */
  14504. rebuild(): void;
  14505. /**
  14506. * Serializes the component data to the specified json object
  14507. * @param serializationObject The object to serialize to
  14508. */
  14509. serialize(serializationObject: any): void;
  14510. /**
  14511. * Adds all the element from the container to the scene
  14512. * @param container the container holding the elements
  14513. */
  14514. addFromContainer(container: AbstractScene): void;
  14515. /**
  14516. * Removes all the elements in the container from the scene
  14517. * @param container contains the elements to remove
  14518. */
  14519. removeFromContainer(container: AbstractScene): void;
  14520. /**
  14521. * Disposes the component and the associated ressources.
  14522. */
  14523. dispose(): void;
  14524. private _isReadyForMesh;
  14525. private _renderMainTexture;
  14526. private _setStencil;
  14527. private _setStencilBack;
  14528. private _draw;
  14529. private _drawCamera;
  14530. private _drawRenderingGroup;
  14531. }
  14532. }
  14533. declare module BABYLON {
  14534. interface AbstractScene {
  14535. /**
  14536. * Return a the first highlight layer of the scene with a given name.
  14537. * @param name The name of the highlight layer to look for.
  14538. * @return The highlight layer if found otherwise null.
  14539. */
  14540. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14541. }
  14542. /**
  14543. * Glow layer options. This helps customizing the behaviour
  14544. * of the glow layer.
  14545. */
  14546. interface IGlowLayerOptions {
  14547. /**
  14548. * Multiplication factor apply to the canvas size to compute the render target size
  14549. * used to generated the glowing objects (the smaller the faster).
  14550. */
  14551. mainTextureRatio: number;
  14552. /**
  14553. * Enforces a fixed size texture to ensure resize independant blur.
  14554. */
  14555. mainTextureFixedSize?: number;
  14556. /**
  14557. * How big is the kernel of the blur texture.
  14558. */
  14559. blurKernelSize: number;
  14560. /**
  14561. * The camera attached to the layer.
  14562. */
  14563. camera: Nullable<Camera>;
  14564. /**
  14565. * Enable MSAA by chosing the number of samples.
  14566. */
  14567. mainTextureSamples?: number;
  14568. /**
  14569. * The rendering group to draw the layer in.
  14570. */
  14571. renderingGroupId: number;
  14572. }
  14573. /**
  14574. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14575. *
  14576. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14577. * glowy meshes to your scene.
  14578. *
  14579. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14580. */
  14581. class GlowLayer extends EffectLayer {
  14582. /**
  14583. * Effect Name of the layer.
  14584. */
  14585. static readonly EffectName: string;
  14586. /**
  14587. * The default blur kernel size used for the glow.
  14588. */
  14589. static DefaultBlurKernelSize: number;
  14590. /**
  14591. * The default texture size ratio used for the glow.
  14592. */
  14593. static DefaultTextureRatio: number;
  14594. /**
  14595. * Sets the kernel size of the blur.
  14596. */
  14597. /**
  14598. * Gets the kernel size of the blur.
  14599. */
  14600. blurKernelSize: number;
  14601. /**
  14602. * Sets the glow intensity.
  14603. */
  14604. /**
  14605. * Gets the glow intensity.
  14606. */
  14607. intensity: number;
  14608. private _options;
  14609. private _intensity;
  14610. private _horizontalBlurPostprocess1;
  14611. private _verticalBlurPostprocess1;
  14612. private _horizontalBlurPostprocess2;
  14613. private _verticalBlurPostprocess2;
  14614. private _blurTexture1;
  14615. private _blurTexture2;
  14616. private _postProcesses1;
  14617. private _postProcesses2;
  14618. private _includedOnlyMeshes;
  14619. private _excludedMeshes;
  14620. /**
  14621. * Callback used to let the user override the color selection on a per mesh basis
  14622. */
  14623. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14624. /**
  14625. * Callback used to let the user override the texture selection on a per mesh basis
  14626. */
  14627. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14628. /**
  14629. * Instantiates a new glow Layer and references it to the scene.
  14630. * @param name The name of the layer
  14631. * @param scene The scene to use the layer in
  14632. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14633. */
  14634. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14635. /**
  14636. * Get the effect name of the layer.
  14637. * @return The effect name
  14638. */
  14639. getEffectName(): string;
  14640. /**
  14641. * Create the merge effect. This is the shader use to blit the information back
  14642. * to the main canvas at the end of the scene rendering.
  14643. */
  14644. protected _createMergeEffect(): Effect;
  14645. /**
  14646. * Creates the render target textures and post processes used in the glow layer.
  14647. */
  14648. protected _createTextureAndPostProcesses(): void;
  14649. /**
  14650. * Checks for the readiness of the element composing the layer.
  14651. * @param subMesh the mesh to check for
  14652. * @param useInstances specify wether or not to use instances to render the mesh
  14653. * @param emissiveTexture the associated emissive texture used to generate the glow
  14654. * @return true if ready otherwise, false
  14655. */
  14656. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14657. /**
  14658. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14659. */
  14660. needStencil(): boolean;
  14661. /**
  14662. * Implementation specific of rendering the generating effect on the main canvas.
  14663. * @param effect The effect used to render through
  14664. */
  14665. protected _internalRender(effect: Effect): void;
  14666. /**
  14667. * Sets the required values for both the emissive texture and and the main color.
  14668. */
  14669. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14670. /**
  14671. * Returns true if the mesh should render, otherwise false.
  14672. * @param mesh The mesh to render
  14673. * @returns true if it should render otherwise false
  14674. */
  14675. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14676. /**
  14677. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14678. * @param mesh The mesh to exclude from the glow layer
  14679. */
  14680. addExcludedMesh(mesh: Mesh): void;
  14681. /**
  14682. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14683. * @param mesh The mesh to remove
  14684. */
  14685. removeExcludedMesh(mesh: Mesh): void;
  14686. /**
  14687. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14688. * @param mesh The mesh to include in the glow layer
  14689. */
  14690. addIncludedOnlyMesh(mesh: Mesh): void;
  14691. /**
  14692. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14693. * @param mesh The mesh to remove
  14694. */
  14695. removeIncludedOnlyMesh(mesh: Mesh): void;
  14696. /**
  14697. * Determine if a given mesh will be used in the glow layer
  14698. * @param mesh The mesh to test
  14699. * @returns true if the mesh will be highlighted by the current glow layer
  14700. */
  14701. hasMesh(mesh: AbstractMesh): boolean;
  14702. /**
  14703. * Free any resources and references associated to a mesh.
  14704. * Internal use
  14705. * @param mesh The mesh to free.
  14706. * @hidden
  14707. */
  14708. _disposeMesh(mesh: Mesh): void;
  14709. /**
  14710. * Gets the class name of the effect layer
  14711. * @returns the string with the class name of the effect layer
  14712. */
  14713. getClassName(): string;
  14714. /**
  14715. * Serializes this glow layer
  14716. * @returns a serialized glow layer object
  14717. */
  14718. serialize(): any;
  14719. /**
  14720. * Creates a Glow Layer from parsed glow layer data
  14721. * @param parsedGlowLayer defines glow layer data
  14722. * @param scene defines the current scene
  14723. * @param rootUrl defines the root URL containing the glow layer information
  14724. * @returns a parsed Glow Layer
  14725. */
  14726. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14727. }
  14728. }
  14729. declare module BABYLON {
  14730. interface AbstractScene {
  14731. /**
  14732. * Return a the first highlight layer of the scene with a given name.
  14733. * @param name The name of the highlight layer to look for.
  14734. * @return The highlight layer if found otherwise null.
  14735. */
  14736. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14737. }
  14738. /**
  14739. * Highlight layer options. This helps customizing the behaviour
  14740. * of the highlight layer.
  14741. */
  14742. interface IHighlightLayerOptions {
  14743. /**
  14744. * Multiplication factor apply to the canvas size to compute the render target size
  14745. * used to generated the glowing objects (the smaller the faster).
  14746. */
  14747. mainTextureRatio: number;
  14748. /**
  14749. * Enforces a fixed size texture to ensure resize independant blur.
  14750. */
  14751. mainTextureFixedSize?: number;
  14752. /**
  14753. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14754. * of the picture to blur (the smaller the faster).
  14755. */
  14756. blurTextureSizeRatio: number;
  14757. /**
  14758. * How big in texel of the blur texture is the vertical blur.
  14759. */
  14760. blurVerticalSize: number;
  14761. /**
  14762. * How big in texel of the blur texture is the horizontal blur.
  14763. */
  14764. blurHorizontalSize: number;
  14765. /**
  14766. * Alpha blending mode used to apply the blur. Default is combine.
  14767. */
  14768. alphaBlendingMode: number;
  14769. /**
  14770. * The camera attached to the layer.
  14771. */
  14772. camera: Nullable<Camera>;
  14773. /**
  14774. * Should we display highlight as a solid stroke?
  14775. */
  14776. isStroke?: boolean;
  14777. /**
  14778. * The rendering group to draw the layer in.
  14779. */
  14780. renderingGroupId: number;
  14781. }
  14782. /**
  14783. * The highlight layer Helps adding a glow effect around a mesh.
  14784. *
  14785. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14786. * glowy meshes to your scene.
  14787. *
  14788. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14789. */
  14790. class HighlightLayer extends EffectLayer {
  14791. name: string;
  14792. /**
  14793. * Effect Name of the highlight layer.
  14794. */
  14795. static readonly EffectName: string;
  14796. /**
  14797. * The neutral color used during the preparation of the glow effect.
  14798. * This is black by default as the blend operation is a blend operation.
  14799. */
  14800. static NeutralColor: Color4;
  14801. /**
  14802. * Stencil value used for glowing meshes.
  14803. */
  14804. static GlowingMeshStencilReference: number;
  14805. /**
  14806. * Stencil value used for the other meshes in the scene.
  14807. */
  14808. static NormalMeshStencilReference: number;
  14809. /**
  14810. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14811. */
  14812. innerGlow: boolean;
  14813. /**
  14814. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14815. */
  14816. outerGlow: boolean;
  14817. /**
  14818. * Specifies the horizontal size of the blur.
  14819. */
  14820. /**
  14821. * Gets the horizontal size of the blur.
  14822. */
  14823. blurHorizontalSize: number;
  14824. /**
  14825. * Specifies the vertical size of the blur.
  14826. */
  14827. /**
  14828. * Gets the vertical size of the blur.
  14829. */
  14830. blurVerticalSize: number;
  14831. /**
  14832. * An event triggered when the highlight layer is being blurred.
  14833. */
  14834. onBeforeBlurObservable: Observable<HighlightLayer>;
  14835. /**
  14836. * An event triggered when the highlight layer has been blurred.
  14837. */
  14838. onAfterBlurObservable: Observable<HighlightLayer>;
  14839. private _instanceGlowingMeshStencilReference;
  14840. private _options;
  14841. private _downSamplePostprocess;
  14842. private _horizontalBlurPostprocess;
  14843. private _verticalBlurPostprocess;
  14844. private _blurTexture;
  14845. private _meshes;
  14846. private _excludedMeshes;
  14847. /**
  14848. * Instantiates a new highlight Layer and references it to the scene..
  14849. * @param name The name of the layer
  14850. * @param scene The scene to use the layer in
  14851. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14852. */
  14853. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14854. /**
  14855. * Get the effect name of the layer.
  14856. * @return The effect name
  14857. */
  14858. getEffectName(): string;
  14859. /**
  14860. * Create the merge effect. This is the shader use to blit the information back
  14861. * to the main canvas at the end of the scene rendering.
  14862. */
  14863. protected _createMergeEffect(): Effect;
  14864. /**
  14865. * Creates the render target textures and post processes used in the highlight layer.
  14866. */
  14867. protected _createTextureAndPostProcesses(): void;
  14868. /**
  14869. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14870. */
  14871. needStencil(): boolean;
  14872. /**
  14873. * Checks for the readiness of the element composing the layer.
  14874. * @param subMesh the mesh to check for
  14875. * @param useInstances specify wether or not to use instances to render the mesh
  14876. * @param emissiveTexture the associated emissive texture used to generate the glow
  14877. * @return true if ready otherwise, false
  14878. */
  14879. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14880. /**
  14881. * Implementation specific of rendering the generating effect on the main canvas.
  14882. * @param effect The effect used to render through
  14883. */
  14884. protected _internalRender(effect: Effect): void;
  14885. /**
  14886. * Returns true if the layer contains information to display, otherwise false.
  14887. */
  14888. shouldRender(): boolean;
  14889. /**
  14890. * Returns true if the mesh should render, otherwise false.
  14891. * @param mesh The mesh to render
  14892. * @returns true if it should render otherwise false
  14893. */
  14894. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14895. /**
  14896. * Sets the required values for both the emissive texture and and the main color.
  14897. */
  14898. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14899. /**
  14900. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14901. * @param mesh The mesh to exclude from the highlight layer
  14902. */
  14903. addExcludedMesh(mesh: Mesh): void;
  14904. /**
  14905. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14906. * @param mesh The mesh to highlight
  14907. */
  14908. removeExcludedMesh(mesh: Mesh): void;
  14909. /**
  14910. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14911. * @param mesh mesh to test
  14912. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14913. */
  14914. hasMesh(mesh: AbstractMesh): boolean;
  14915. /**
  14916. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14917. * @param mesh The mesh to highlight
  14918. * @param color The color of the highlight
  14919. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14920. */
  14921. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14922. /**
  14923. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14924. * @param mesh The mesh to highlight
  14925. */
  14926. removeMesh(mesh: Mesh): void;
  14927. /**
  14928. * Force the stencil to the normal expected value for none glowing parts
  14929. */
  14930. private _defaultStencilReference;
  14931. /**
  14932. * Free any resources and references associated to a mesh.
  14933. * Internal use
  14934. * @param mesh The mesh to free.
  14935. * @hidden
  14936. */
  14937. _disposeMesh(mesh: Mesh): void;
  14938. /**
  14939. * Dispose the highlight layer and free resources.
  14940. */
  14941. dispose(): void;
  14942. /**
  14943. * Gets the class name of the effect layer
  14944. * @returns the string with the class name of the effect layer
  14945. */
  14946. getClassName(): string;
  14947. /**
  14948. * Serializes this Highlight layer
  14949. * @returns a serialized Highlight layer object
  14950. */
  14951. serialize(): any;
  14952. /**
  14953. * Creates a Highlight layer from parsed Highlight layer data
  14954. * @param parsedHightlightLayer defines the Highlight layer data
  14955. * @param scene defines the current scene
  14956. * @param rootUrl defines the root URL containing the Highlight layer information
  14957. * @returns a parsed Highlight layer
  14958. */
  14959. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14960. }
  14961. }
  14962. declare module BABYLON {
  14963. /**
  14964. * This represents a full screen 2d layer.
  14965. * This can be usefull to display a picture in the background of your scene for instance.
  14966. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14967. */
  14968. class Layer {
  14969. /**
  14970. * Define the name of the layer.
  14971. */
  14972. name: string;
  14973. /**
  14974. * Define the texture the layer should display.
  14975. */
  14976. texture: Nullable<Texture>;
  14977. /**
  14978. * Is the layer in background or foreground.
  14979. */
  14980. isBackground: boolean;
  14981. /**
  14982. * Define the color of the layer (instead of texture).
  14983. */
  14984. color: Color4;
  14985. /**
  14986. * Define the scale of the layer in order to zoom in out of the texture.
  14987. */
  14988. scale: Vector2;
  14989. /**
  14990. * Define an offset for the layer in order to shift the texture.
  14991. */
  14992. offset: Vector2;
  14993. /**
  14994. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14995. */
  14996. alphaBlendingMode: number;
  14997. /**
  14998. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14999. * Alpha test will not mix with the background color in case of transparency.
  15000. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15001. */
  15002. alphaTest: boolean;
  15003. /**
  15004. * Define a mask to restrict the layer to only some of the scene cameras.
  15005. */
  15006. layerMask: number;
  15007. private _scene;
  15008. private _vertexBuffers;
  15009. private _indexBuffer;
  15010. private _effect;
  15011. private _alphaTestEffect;
  15012. /**
  15013. * An event triggered when the layer is disposed.
  15014. */
  15015. onDisposeObservable: Observable<Layer>;
  15016. private _onDisposeObserver;
  15017. /**
  15018. * Back compatibility with callback before the onDisposeObservable existed.
  15019. * The set callback will be triggered when the layer has been disposed.
  15020. */
  15021. onDispose: () => void;
  15022. /**
  15023. * An event triggered before rendering the scene
  15024. */
  15025. onBeforeRenderObservable: Observable<Layer>;
  15026. private _onBeforeRenderObserver;
  15027. /**
  15028. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15029. * The set callback will be triggered just before rendering the layer.
  15030. */
  15031. onBeforeRender: () => void;
  15032. /**
  15033. * An event triggered after rendering the scene
  15034. */
  15035. onAfterRenderObservable: Observable<Layer>;
  15036. private _onAfterRenderObserver;
  15037. /**
  15038. * Back compatibility with callback before the onAfterRenderObservable existed.
  15039. * The set callback will be triggered just after rendering the layer.
  15040. */
  15041. onAfterRender: () => void;
  15042. /**
  15043. * Instantiates a new layer.
  15044. * This represents a full screen 2d layer.
  15045. * This can be usefull to display a picture in the background of your scene for instance.
  15046. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15047. * @param name Define the name of the layer in the scene
  15048. * @param imgUrl Define the url of the texture to display in the layer
  15049. * @param scene Define the scene the layer belongs to
  15050. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15051. * @param color Defines a color for the layer
  15052. */
  15053. constructor(
  15054. /**
  15055. * Define the name of the layer.
  15056. */
  15057. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15058. private _createIndexBuffer;
  15059. /** @hidden */
  15060. _rebuild(): void;
  15061. /**
  15062. * Renders the layer in the scene.
  15063. */
  15064. render(): void;
  15065. /**
  15066. * Disposes and releases the associated ressources.
  15067. */
  15068. dispose(): void;
  15069. }
  15070. }
  15071. declare module BABYLON {
  15072. interface AbstractScene {
  15073. /**
  15074. * The list of layers (background and foreground) of the scene
  15075. */
  15076. layers: Array<Layer>;
  15077. }
  15078. /**
  15079. * Defines the layer scene component responsible to manage any layers
  15080. * in a given scene.
  15081. */
  15082. class LayerSceneComponent implements ISceneComponent {
  15083. /**
  15084. * The component name helpfull to identify the component in the list of scene components.
  15085. */
  15086. readonly name: string;
  15087. /**
  15088. * The scene the component belongs to.
  15089. */
  15090. scene: Scene;
  15091. private _engine;
  15092. /**
  15093. * Creates a new instance of the component for the given scene
  15094. * @param scene Defines the scene to register the component in
  15095. */
  15096. constructor(scene: Scene);
  15097. /**
  15098. * Registers the component in a given scene
  15099. */
  15100. register(): void;
  15101. /**
  15102. * Rebuilds the elements related to this component in case of
  15103. * context lost for instance.
  15104. */
  15105. rebuild(): void;
  15106. /**
  15107. * Disposes the component and the associated ressources.
  15108. */
  15109. dispose(): void;
  15110. private _draw;
  15111. private _drawBackground;
  15112. private _drawForeground;
  15113. }
  15114. }
  15115. declare module BABYLON {
  15116. /**
  15117. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15118. * It controls one of the indiviual texture used in the effect.
  15119. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15120. */
  15121. class LensFlare {
  15122. /**
  15123. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15124. */
  15125. size: number;
  15126. /**
  15127. * 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.
  15128. */
  15129. position: number;
  15130. /**
  15131. * Define the lens color.
  15132. */
  15133. color: Color3;
  15134. /**
  15135. * Define the lens texture.
  15136. */
  15137. texture: Nullable<Texture>;
  15138. /**
  15139. * Define the alpha mode to render this particular lens.
  15140. */
  15141. alphaMode: number;
  15142. private _system;
  15143. /**
  15144. * Creates a new Lens Flare.
  15145. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15146. * It controls one of the indiviual texture used in the effect.
  15147. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15148. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15149. * @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.
  15150. * @param color Define the lens color
  15151. * @param imgUrl Define the lens texture url
  15152. * @param system Define the `lensFlareSystem` this flare is part of
  15153. * @returns The newly created Lens Flare
  15154. */
  15155. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15156. /**
  15157. * Instantiates a new Lens Flare.
  15158. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15159. * It controls one of the indiviual texture used in the effect.
  15160. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15161. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15162. * @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.
  15163. * @param color Define the lens color
  15164. * @param imgUrl Define the lens texture url
  15165. * @param system Define the `lensFlareSystem` this flare is part of
  15166. */
  15167. constructor(
  15168. /**
  15169. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15170. */
  15171. size: number,
  15172. /**
  15173. * 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.
  15174. */
  15175. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15176. /**
  15177. * Dispose and release the lens flare with its associated resources.
  15178. */
  15179. dispose(): void;
  15180. }
  15181. }
  15182. declare module BABYLON {
  15183. /**
  15184. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15185. * It is usually composed of several `BABYLON.lensFlare`.
  15186. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15187. */
  15188. class LensFlareSystem {
  15189. /**
  15190. * Define the name of the lens flare system
  15191. */
  15192. name: string;
  15193. /**
  15194. * List of lens flares used in this system.
  15195. */
  15196. lensFlares: LensFlare[];
  15197. /**
  15198. * Define a limit from the border the lens flare can be visible.
  15199. */
  15200. borderLimit: number;
  15201. /**
  15202. * Define a viewport border we do not want to see the lens flare in.
  15203. */
  15204. viewportBorder: number;
  15205. /**
  15206. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15207. */
  15208. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15209. /**
  15210. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15211. */
  15212. layerMask: number;
  15213. /**
  15214. * Define the id of the lens flare system in the scene.
  15215. * (equal to name by default)
  15216. */
  15217. id: string;
  15218. private _scene;
  15219. private _emitter;
  15220. private _vertexBuffers;
  15221. private _indexBuffer;
  15222. private _effect;
  15223. private _positionX;
  15224. private _positionY;
  15225. private _isEnabled;
  15226. /**
  15227. * Instantiates a lens flare system.
  15228. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15229. * It is usually composed of several `BABYLON.lensFlare`.
  15230. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15231. * @param name Define the name of the lens flare system in the scene
  15232. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15233. * @param scene Define the scene the lens flare system belongs to
  15234. */
  15235. constructor(
  15236. /**
  15237. * Define the name of the lens flare system
  15238. */
  15239. name: string, emitter: any, scene: Scene);
  15240. /**
  15241. * Define if the lens flare system is enabled.
  15242. */
  15243. isEnabled: boolean;
  15244. /**
  15245. * Get the scene the effects belongs to.
  15246. * @returns the scene holding the lens flare system
  15247. */
  15248. getScene(): Scene;
  15249. /**
  15250. * Get the emitter of the lens flare system.
  15251. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15252. * @returns the emitter of the lens flare system
  15253. */
  15254. getEmitter(): any;
  15255. /**
  15256. * Set the emitter of the lens flare system.
  15257. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15258. * @param newEmitter Define the new emitter of the system
  15259. */
  15260. setEmitter(newEmitter: any): void;
  15261. /**
  15262. * Get the lens flare system emitter position.
  15263. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15264. * @returns the position
  15265. */
  15266. getEmitterPosition(): Vector3;
  15267. /**
  15268. * @hidden
  15269. */
  15270. computeEffectivePosition(globalViewport: Viewport): boolean;
  15271. /** @hidden */
  15272. _isVisible(): boolean;
  15273. /**
  15274. * @hidden
  15275. */
  15276. render(): boolean;
  15277. /**
  15278. * Dispose and release the lens flare with its associated resources.
  15279. */
  15280. dispose(): void;
  15281. /**
  15282. * Parse a lens flare system from a JSON repressentation
  15283. * @param parsedLensFlareSystem Define the JSON to parse
  15284. * @param scene Define the scene the parsed system should be instantiated in
  15285. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15286. * @returns the parsed system
  15287. */
  15288. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15289. /**
  15290. * Serialize the current Lens Flare System into a JSON representation.
  15291. * @returns the serialized JSON
  15292. */
  15293. serialize(): any;
  15294. }
  15295. }
  15296. declare module BABYLON {
  15297. interface AbstractScene {
  15298. /**
  15299. * The list of lens flare system added to the scene
  15300. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15301. */
  15302. lensFlareSystems: Array<LensFlareSystem>;
  15303. /**
  15304. * Removes the given lens flare system from this scene.
  15305. * @param toRemove The lens flare system to remove
  15306. * @returns The index of the removed lens flare system
  15307. */
  15308. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15309. /**
  15310. * Adds the given lens flare system to this scene
  15311. * @param newLensFlareSystem The lens flare system to add
  15312. */
  15313. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15314. /**
  15315. * Gets a lens flare system using its name
  15316. * @param name defines the name to look for
  15317. * @returns the lens flare system or null if not found
  15318. */
  15319. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15320. /**
  15321. * Gets a lens flare system using its id
  15322. * @param id defines the id to look for
  15323. * @returns the lens flare system or null if not found
  15324. */
  15325. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15326. }
  15327. /**
  15328. * Defines the lens flare scene component responsible to manage any lens flares
  15329. * in a given scene.
  15330. */
  15331. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15332. /**
  15333. * The component name helpfull to identify the component in the list of scene components.
  15334. */
  15335. readonly name: string;
  15336. /**
  15337. * The scene the component belongs to.
  15338. */
  15339. scene: Scene;
  15340. /**
  15341. * Creates a new instance of the component for the given scene
  15342. * @param scene Defines the scene to register the component in
  15343. */
  15344. constructor(scene: Scene);
  15345. /**
  15346. * Registers the component in a given scene
  15347. */
  15348. register(): void;
  15349. /**
  15350. * Rebuilds the elements related to this component in case of
  15351. * context lost for instance.
  15352. */
  15353. rebuild(): void;
  15354. /**
  15355. * Adds all the element from the container to the scene
  15356. * @param container the container holding the elements
  15357. */
  15358. addFromContainer(container: AbstractScene): void;
  15359. /**
  15360. * Removes all the elements in the container from the scene
  15361. * @param container contains the elements to remove
  15362. */
  15363. removeFromContainer(container: AbstractScene): void;
  15364. /**
  15365. * Serializes the component data to the specified json object
  15366. * @param serializationObject The object to serialize to
  15367. */
  15368. serialize(serializationObject: any): void;
  15369. /**
  15370. * Disposes the component and the associated ressources.
  15371. */
  15372. dispose(): void;
  15373. private _draw;
  15374. }
  15375. }
  15376. declare module BABYLON {
  15377. /**
  15378. * A directional light is defined by a direction (what a surprise!).
  15379. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15380. * 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.
  15381. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15382. */
  15383. class DirectionalLight extends ShadowLight {
  15384. private _shadowFrustumSize;
  15385. /**
  15386. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15387. */
  15388. /**
  15389. * Specifies a fix frustum size for the shadow generation.
  15390. */
  15391. shadowFrustumSize: number;
  15392. private _shadowOrthoScale;
  15393. /**
  15394. * Gets the shadow projection scale against the optimal computed one.
  15395. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15396. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15397. */
  15398. /**
  15399. * Sets the shadow projection scale against the optimal computed one.
  15400. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15401. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15402. */
  15403. shadowOrthoScale: number;
  15404. /**
  15405. * Automatically compute the projection matrix to best fit (including all the casters)
  15406. * on each frame.
  15407. */
  15408. autoUpdateExtends: boolean;
  15409. private _orthoLeft;
  15410. private _orthoRight;
  15411. private _orthoTop;
  15412. private _orthoBottom;
  15413. /**
  15414. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15415. * The directional light is emitted from everywhere in the given direction.
  15416. * It can cast shadows.
  15417. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15418. * @param name The friendly name of the light
  15419. * @param direction The direction of the light
  15420. * @param scene The scene the light belongs to
  15421. */
  15422. constructor(name: string, direction: Vector3, scene: Scene);
  15423. /**
  15424. * Returns the string "DirectionalLight".
  15425. * @return The class name
  15426. */
  15427. getClassName(): string;
  15428. /**
  15429. * Returns the integer 1.
  15430. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15431. */
  15432. getTypeID(): number;
  15433. /**
  15434. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15435. * Returns the DirectionalLight Shadow projection matrix.
  15436. */
  15437. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15438. /**
  15439. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15440. * Returns the DirectionalLight Shadow projection matrix.
  15441. */
  15442. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15443. /**
  15444. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15445. * Returns the DirectionalLight Shadow projection matrix.
  15446. */
  15447. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15448. protected _buildUniformLayout(): void;
  15449. /**
  15450. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15451. * @param effect The effect to update
  15452. * @param lightIndex The index of the light in the effect to update
  15453. * @returns The directional light
  15454. */
  15455. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15456. /**
  15457. * Gets the minZ used for shadow according to both the scene and the light.
  15458. *
  15459. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15460. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15461. * @param activeCamera The camera we are returning the min for
  15462. * @returns the depth min z
  15463. */
  15464. getDepthMinZ(activeCamera: Camera): number;
  15465. /**
  15466. * Gets the maxZ used for shadow according to both the scene and the light.
  15467. *
  15468. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15469. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15470. * @param activeCamera The camera we are returning the max for
  15471. * @returns the depth max z
  15472. */
  15473. getDepthMaxZ(activeCamera: Camera): number;
  15474. /**
  15475. * Prepares the list of defines specific to the light type.
  15476. * @param defines the list of defines
  15477. * @param lightIndex defines the index of the light for the effect
  15478. */
  15479. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15480. }
  15481. }
  15482. declare module BABYLON {
  15483. /**
  15484. * The HemisphericLight simulates the ambient environment light,
  15485. * so the passed direction is the light reflection direction, not the incoming direction.
  15486. */
  15487. class HemisphericLight extends Light {
  15488. /**
  15489. * The groundColor is the light in the opposite direction to the one specified during creation.
  15490. * 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.
  15491. */
  15492. groundColor: Color3;
  15493. /**
  15494. * The light reflection direction, not the incoming direction.
  15495. */
  15496. direction: Vector3;
  15497. /**
  15498. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15499. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15500. * The HemisphericLight can't cast shadows.
  15501. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15502. * @param name The friendly name of the light
  15503. * @param direction The direction of the light reflection
  15504. * @param scene The scene the light belongs to
  15505. */
  15506. constructor(name: string, direction: Vector3, scene: Scene);
  15507. protected _buildUniformLayout(): void;
  15508. /**
  15509. * Returns the string "HemisphericLight".
  15510. * @return The class name
  15511. */
  15512. getClassName(): string;
  15513. /**
  15514. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15515. * Returns the updated direction.
  15516. * @param target The target the direction should point to
  15517. * @return The computed direction
  15518. */
  15519. setDirectionToTarget(target: Vector3): Vector3;
  15520. /**
  15521. * Returns the shadow generator associated to the light.
  15522. * @returns Always null for hemispheric lights because it does not support shadows.
  15523. */
  15524. getShadowGenerator(): Nullable<IShadowGenerator>;
  15525. /**
  15526. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15527. * @param effect The effect to update
  15528. * @param lightIndex The index of the light in the effect to update
  15529. * @returns The hemispheric light
  15530. */
  15531. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15532. /**
  15533. * Computes the world matrix of the node
  15534. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15535. * @param useWasUpdatedFlag defines a reserved property
  15536. * @returns the world matrix
  15537. */
  15538. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15539. /**
  15540. * Returns the integer 3.
  15541. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15542. */
  15543. getTypeID(): number;
  15544. /**
  15545. * Prepares the list of defines specific to the light type.
  15546. * @param defines the list of defines
  15547. * @param lightIndex defines the index of the light for the effect
  15548. */
  15549. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15550. }
  15551. }
  15552. declare module BABYLON {
  15553. /**
  15554. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15555. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15556. * 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.
  15557. */
  15558. abstract class Light extends Node {
  15559. /**
  15560. * Falloff Default: light is falling off following the material specification:
  15561. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15562. */
  15563. static readonly FALLOFF_DEFAULT: number;
  15564. /**
  15565. * Falloff Physical: light is falling off following the inverse squared distance law.
  15566. */
  15567. static readonly FALLOFF_PHYSICAL: number;
  15568. /**
  15569. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15570. * to enhance interoperability with other engines.
  15571. */
  15572. static readonly FALLOFF_GLTF: number;
  15573. /**
  15574. * Falloff Standard: light is falling off like in the standard material
  15575. * to enhance interoperability with other materials.
  15576. */
  15577. static readonly FALLOFF_STANDARD: number;
  15578. /**
  15579. * If every light affecting the material is in this lightmapMode,
  15580. * material.lightmapTexture adds or multiplies
  15581. * (depends on material.useLightmapAsShadowmap)
  15582. * after every other light calculations.
  15583. */
  15584. static readonly LIGHTMAP_DEFAULT: number;
  15585. /**
  15586. * material.lightmapTexture as only diffuse lighting from this light
  15587. * adds only specular lighting from this light
  15588. * adds dynamic shadows
  15589. */
  15590. static readonly LIGHTMAP_SPECULAR: number;
  15591. /**
  15592. * material.lightmapTexture as only lighting
  15593. * no light calculation from this light
  15594. * only adds dynamic shadows from this light
  15595. */
  15596. static readonly LIGHTMAP_SHADOWSONLY: number;
  15597. /**
  15598. * Each light type uses the default quantity according to its type:
  15599. * point/spot lights use luminous intensity
  15600. * directional lights use illuminance
  15601. */
  15602. static readonly INTENSITYMODE_AUTOMATIC: number;
  15603. /**
  15604. * lumen (lm)
  15605. */
  15606. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15607. /**
  15608. * candela (lm/sr)
  15609. */
  15610. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15611. /**
  15612. * lux (lm/m^2)
  15613. */
  15614. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15615. /**
  15616. * nit (cd/m^2)
  15617. */
  15618. static readonly INTENSITYMODE_LUMINANCE: number;
  15619. /**
  15620. * Light type const id of the point light.
  15621. */
  15622. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15623. /**
  15624. * Light type const id of the directional light.
  15625. */
  15626. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15627. /**
  15628. * Light type const id of the spot light.
  15629. */
  15630. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15631. /**
  15632. * Light type const id of the hemispheric light.
  15633. */
  15634. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15635. /**
  15636. * Diffuse gives the basic color to an object.
  15637. */
  15638. diffuse: Color3;
  15639. /**
  15640. * Specular produces a highlight color on an object.
  15641. * Note: This is note affecting PBR materials.
  15642. */
  15643. specular: Color3;
  15644. /**
  15645. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15646. * falling off base on range or angle.
  15647. * This can be set to any values in Light.FALLOFF_x.
  15648. *
  15649. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15650. * other types of materials.
  15651. */
  15652. falloffType: number;
  15653. /**
  15654. * Strength of the light.
  15655. * Note: By default it is define in the framework own unit.
  15656. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15657. */
  15658. intensity: number;
  15659. private _range;
  15660. protected _inverseSquaredRange: number;
  15661. /**
  15662. * Defines how far from the source the light is impacting in scene units.
  15663. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15664. */
  15665. /**
  15666. * Defines how far from the source the light is impacting in scene units.
  15667. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15668. */
  15669. range: number;
  15670. /**
  15671. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15672. * of light.
  15673. */
  15674. private _photometricScale;
  15675. private _intensityMode;
  15676. /**
  15677. * Gets the photometric scale used to interpret the intensity.
  15678. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15679. */
  15680. /**
  15681. * Sets the photometric scale used to interpret the intensity.
  15682. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15683. */
  15684. intensityMode: number;
  15685. private _radius;
  15686. /**
  15687. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15688. */
  15689. /**
  15690. * sets the light radius used by PBR Materials to simulate soft area lights.
  15691. */
  15692. radius: number;
  15693. private _renderPriority;
  15694. /**
  15695. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15696. * exceeding the number allowed of the materials.
  15697. */
  15698. renderPriority: number;
  15699. private _shadowEnabled;
  15700. /**
  15701. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15702. * the current shadow generator.
  15703. */
  15704. /**
  15705. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15706. * the current shadow generator.
  15707. */
  15708. shadowEnabled: boolean;
  15709. private _includedOnlyMeshes;
  15710. /**
  15711. * Gets the only meshes impacted by this light.
  15712. */
  15713. /**
  15714. * Sets the only meshes impacted by this light.
  15715. */
  15716. includedOnlyMeshes: AbstractMesh[];
  15717. private _excludedMeshes;
  15718. /**
  15719. * Gets the meshes not impacted by this light.
  15720. */
  15721. /**
  15722. * Sets the meshes not impacted by this light.
  15723. */
  15724. excludedMeshes: AbstractMesh[];
  15725. private _excludeWithLayerMask;
  15726. /**
  15727. * Gets the layer id use to find what meshes are not impacted by the light.
  15728. * Inactive if 0
  15729. */
  15730. /**
  15731. * Sets the layer id use to find what meshes are not impacted by the light.
  15732. * Inactive if 0
  15733. */
  15734. excludeWithLayerMask: number;
  15735. private _includeOnlyWithLayerMask;
  15736. /**
  15737. * Gets the layer id use to find what meshes are impacted by the light.
  15738. * Inactive if 0
  15739. */
  15740. /**
  15741. * Sets the layer id use to find what meshes are impacted by the light.
  15742. * Inactive if 0
  15743. */
  15744. includeOnlyWithLayerMask: number;
  15745. private _lightmapMode;
  15746. /**
  15747. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15748. */
  15749. /**
  15750. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15751. */
  15752. lightmapMode: number;
  15753. /**
  15754. * Shadow generator associted to the light.
  15755. * @hidden Internal use only.
  15756. */
  15757. _shadowGenerator: Nullable<IShadowGenerator>;
  15758. /**
  15759. * @hidden Internal use only.
  15760. */
  15761. _excludedMeshesIds: string[];
  15762. /**
  15763. * @hidden Internal use only.
  15764. */
  15765. _includedOnlyMeshesIds: string[];
  15766. /**
  15767. * The current light unifom buffer.
  15768. * @hidden Internal use only.
  15769. */
  15770. _uniformBuffer: UniformBuffer;
  15771. /**
  15772. * Creates a Light object in the scene.
  15773. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15774. * @param name The firendly name of the light
  15775. * @param scene The scene the light belongs too
  15776. */
  15777. constructor(name: string, scene: Scene);
  15778. protected abstract _buildUniformLayout(): void;
  15779. /**
  15780. * Sets the passed Effect "effect" with the Light information.
  15781. * @param effect The effect to update
  15782. * @param lightIndex The index of the light in the effect to update
  15783. * @returns The light
  15784. */
  15785. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15786. /**
  15787. * Returns the string "Light".
  15788. * @returns the class name
  15789. */
  15790. getClassName(): string;
  15791. /**
  15792. * Converts the light information to a readable string for debug purpose.
  15793. * @param fullDetails Supports for multiple levels of logging within scene loading
  15794. * @returns the human readable light info
  15795. */
  15796. toString(fullDetails?: boolean): string;
  15797. /** @hidden */
  15798. protected _syncParentEnabledState(): void;
  15799. /**
  15800. * Set the enabled state of this node.
  15801. * @param value - the new enabled state
  15802. */
  15803. setEnabled(value: boolean): void;
  15804. /**
  15805. * Returns the Light associated shadow generator if any.
  15806. * @return the associated shadow generator.
  15807. */
  15808. getShadowGenerator(): Nullable<IShadowGenerator>;
  15809. /**
  15810. * Returns a Vector3, the absolute light position in the World.
  15811. * @returns the world space position of the light
  15812. */
  15813. getAbsolutePosition(): Vector3;
  15814. /**
  15815. * Specifies if the light will affect the passed mesh.
  15816. * @param mesh The mesh to test against the light
  15817. * @return true the mesh is affected otherwise, false.
  15818. */
  15819. canAffectMesh(mesh: AbstractMesh): boolean;
  15820. /**
  15821. * Sort function to order lights for rendering.
  15822. * @param a First Light object to compare to second.
  15823. * @param b Second Light object to compare first.
  15824. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15825. */
  15826. static CompareLightsPriority(a: Light, b: Light): number;
  15827. /**
  15828. * Releases resources associated with this node.
  15829. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15830. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15831. */
  15832. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15833. /**
  15834. * Returns the light type ID (integer).
  15835. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15836. */
  15837. getTypeID(): number;
  15838. /**
  15839. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15840. * @returns the scaled intensity in intensity mode unit
  15841. */
  15842. getScaledIntensity(): number;
  15843. /**
  15844. * Returns a new Light object, named "name", from the current one.
  15845. * @param name The name of the cloned light
  15846. * @returns the new created light
  15847. */
  15848. clone(name: string): Nullable<Light>;
  15849. /**
  15850. * Serializes the current light into a Serialization object.
  15851. * @returns the serialized object.
  15852. */
  15853. serialize(): any;
  15854. /**
  15855. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15856. * This new light is named "name" and added to the passed scene.
  15857. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15858. * @param name The friendly name of the light
  15859. * @param scene The scene the new light will belong to
  15860. * @returns the constructor function
  15861. */
  15862. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15863. /**
  15864. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15865. * @param parsedLight The JSON representation of the light
  15866. * @param scene The scene to create the parsed light in
  15867. * @returns the created light after parsing
  15868. */
  15869. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15870. private _hookArrayForExcluded;
  15871. private _hookArrayForIncludedOnly;
  15872. private _resyncMeshes;
  15873. /**
  15874. * Forces the meshes to update their light related information in their rendering used effects
  15875. * @hidden Internal Use Only
  15876. */
  15877. _markMeshesAsLightDirty(): void;
  15878. /**
  15879. * Recomputes the cached photometric scale if needed.
  15880. */
  15881. private _computePhotometricScale;
  15882. /**
  15883. * Returns the Photometric Scale according to the light type and intensity mode.
  15884. */
  15885. private _getPhotometricScale;
  15886. /**
  15887. * Reorder the light in the scene according to their defined priority.
  15888. * @hidden Internal Use Only
  15889. */
  15890. _reorderLightsInScene(): void;
  15891. /**
  15892. * Prepares the list of defines specific to the light type.
  15893. * @param defines the list of defines
  15894. * @param lightIndex defines the index of the light for the effect
  15895. */
  15896. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15897. }
  15898. }
  15899. declare module BABYLON {
  15900. /**
  15901. * A point light is a light defined by an unique point in world space.
  15902. * The light is emitted in every direction from this point.
  15903. * A good example of a point light is a standard light bulb.
  15904. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15905. */
  15906. class PointLight extends ShadowLight {
  15907. private _shadowAngle;
  15908. /**
  15909. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15910. * This specifies what angle the shadow will use to be created.
  15911. *
  15912. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15913. */
  15914. /**
  15915. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15916. * This specifies what angle the shadow will use to be created.
  15917. *
  15918. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15919. */
  15920. shadowAngle: number;
  15921. /**
  15922. * Gets the direction if it has been set.
  15923. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15924. */
  15925. /**
  15926. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15927. */
  15928. direction: Vector3;
  15929. /**
  15930. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15931. * A PointLight emits the light in every direction.
  15932. * It can cast shadows.
  15933. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15934. * ```javascript
  15935. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15936. * ```
  15937. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15938. * @param name The light friendly name
  15939. * @param position The position of the point light in the scene
  15940. * @param scene The scene the lights belongs to
  15941. */
  15942. constructor(name: string, position: Vector3, scene: Scene);
  15943. /**
  15944. * Returns the string "PointLight"
  15945. * @returns the class name
  15946. */
  15947. getClassName(): string;
  15948. /**
  15949. * Returns the integer 0.
  15950. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15951. */
  15952. getTypeID(): number;
  15953. /**
  15954. * Specifies wether or not the shadowmap should be a cube texture.
  15955. * @returns true if the shadowmap needs to be a cube texture.
  15956. */
  15957. needCube(): boolean;
  15958. /**
  15959. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15960. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15961. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15962. */
  15963. getShadowDirection(faceIndex?: number): Vector3;
  15964. /**
  15965. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15966. * - fov = PI / 2
  15967. * - aspect ratio : 1.0
  15968. * - z-near and far equal to the active camera minZ and maxZ.
  15969. * Returns the PointLight.
  15970. */
  15971. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15972. protected _buildUniformLayout(): void;
  15973. /**
  15974. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15975. * @param effect The effect to update
  15976. * @param lightIndex The index of the light in the effect to update
  15977. * @returns The point light
  15978. */
  15979. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15980. /**
  15981. * Prepares the list of defines specific to the light type.
  15982. * @param defines the list of defines
  15983. * @param lightIndex defines the index of the light for the effect
  15984. */
  15985. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15986. }
  15987. }
  15988. declare module BABYLON {
  15989. /**
  15990. * Interface describing all the common properties and methods a shadow light needs to implement.
  15991. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15992. * as well as binding the different shadow properties to the effects.
  15993. */
  15994. interface IShadowLight extends Light {
  15995. /**
  15996. * The light id in the scene (used in scene.findLighById for instance)
  15997. */
  15998. id: string;
  15999. /**
  16000. * The position the shdow will be casted from.
  16001. */
  16002. position: Vector3;
  16003. /**
  16004. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16005. */
  16006. direction: Vector3;
  16007. /**
  16008. * The transformed position. Position of the light in world space taking parenting in account.
  16009. */
  16010. transformedPosition: Vector3;
  16011. /**
  16012. * The transformed direction. Direction of the light in world space taking parenting in account.
  16013. */
  16014. transformedDirection: Vector3;
  16015. /**
  16016. * The friendly name of the light in the scene.
  16017. */
  16018. name: string;
  16019. /**
  16020. * Defines the shadow projection clipping minimum z value.
  16021. */
  16022. shadowMinZ: number;
  16023. /**
  16024. * Defines the shadow projection clipping maximum z value.
  16025. */
  16026. shadowMaxZ: number;
  16027. /**
  16028. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16029. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16030. */
  16031. computeTransformedInformation(): boolean;
  16032. /**
  16033. * Gets the scene the light belongs to.
  16034. * @returns The scene
  16035. */
  16036. getScene(): Scene;
  16037. /**
  16038. * Callback defining a custom Projection Matrix Builder.
  16039. * This can be used to override the default projection matrix computation.
  16040. */
  16041. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16042. /**
  16043. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16044. * @param matrix The materix to updated with the projection information
  16045. * @param viewMatrix The transform matrix of the light
  16046. * @param renderList The list of mesh to render in the map
  16047. * @returns The current light
  16048. */
  16049. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16050. /**
  16051. * Gets the current depth scale used in ESM.
  16052. * @returns The scale
  16053. */
  16054. getDepthScale(): number;
  16055. /**
  16056. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16057. * @returns true if a cube texture needs to be use
  16058. */
  16059. needCube(): boolean;
  16060. /**
  16061. * Detects if the projection matrix requires to be recomputed this frame.
  16062. * @returns true if it requires to be recomputed otherwise, false.
  16063. */
  16064. needProjectionMatrixCompute(): boolean;
  16065. /**
  16066. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16067. */
  16068. forceProjectionMatrixCompute(): void;
  16069. /**
  16070. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16071. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16072. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16073. */
  16074. getShadowDirection(faceIndex?: number): Vector3;
  16075. /**
  16076. * Gets the minZ used for shadow according to both the scene and the light.
  16077. * @param activeCamera The camera we are returning the min for
  16078. * @returns the depth min z
  16079. */
  16080. getDepthMinZ(activeCamera: Camera): number;
  16081. /**
  16082. * Gets the maxZ used for shadow according to both the scene and the light.
  16083. * @param activeCamera The camera we are returning the max for
  16084. * @returns the depth max z
  16085. */
  16086. getDepthMaxZ(activeCamera: Camera): number;
  16087. }
  16088. /**
  16089. * Base implementation IShadowLight
  16090. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16091. */
  16092. abstract class ShadowLight extends Light implements IShadowLight {
  16093. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16094. protected _position: Vector3;
  16095. protected _setPosition(value: Vector3): void;
  16096. /**
  16097. * Sets the position the shadow will be casted from. Also use as the light position for both
  16098. * point and spot lights.
  16099. */
  16100. /**
  16101. * Sets the position the shadow will be casted from. Also use as the light position for both
  16102. * point and spot lights.
  16103. */
  16104. position: Vector3;
  16105. protected _direction: Vector3;
  16106. protected _setDirection(value: Vector3): void;
  16107. /**
  16108. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16109. * Also use as the light direction on spot and directional lights.
  16110. */
  16111. /**
  16112. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16113. * Also use as the light direction on spot and directional lights.
  16114. */
  16115. direction: Vector3;
  16116. private _shadowMinZ;
  16117. /**
  16118. * Gets the shadow projection clipping minimum z value.
  16119. */
  16120. /**
  16121. * Sets the shadow projection clipping minimum z value.
  16122. */
  16123. shadowMinZ: number;
  16124. private _shadowMaxZ;
  16125. /**
  16126. * Sets the shadow projection clipping maximum z value.
  16127. */
  16128. /**
  16129. * Gets the shadow projection clipping maximum z value.
  16130. */
  16131. shadowMaxZ: number;
  16132. /**
  16133. * Callback defining a custom Projection Matrix Builder.
  16134. * This can be used to override the default projection matrix computation.
  16135. */
  16136. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16137. /**
  16138. * The transformed position. Position of the light in world space taking parenting in account.
  16139. */
  16140. transformedPosition: Vector3;
  16141. /**
  16142. * The transformed direction. Direction of the light in world space taking parenting in account.
  16143. */
  16144. transformedDirection: Vector3;
  16145. private _needProjectionMatrixCompute;
  16146. /**
  16147. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16148. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16149. */
  16150. computeTransformedInformation(): boolean;
  16151. /**
  16152. * Return the depth scale used for the shadow map.
  16153. * @returns the depth scale.
  16154. */
  16155. getDepthScale(): number;
  16156. /**
  16157. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16158. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16159. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16160. */
  16161. getShadowDirection(faceIndex?: number): Vector3;
  16162. /**
  16163. * Returns the ShadowLight absolute position in the World.
  16164. * @returns the position vector in world space
  16165. */
  16166. getAbsolutePosition(): Vector3;
  16167. /**
  16168. * Sets the ShadowLight direction toward the passed target.
  16169. * @param target The point tot target in local space
  16170. * @returns the updated ShadowLight direction
  16171. */
  16172. setDirectionToTarget(target: Vector3): Vector3;
  16173. /**
  16174. * Returns the light rotation in euler definition.
  16175. * @returns the x y z rotation in local space.
  16176. */
  16177. getRotation(): Vector3;
  16178. /**
  16179. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16180. * @returns true if a cube texture needs to be use
  16181. */
  16182. needCube(): boolean;
  16183. /**
  16184. * Detects if the projection matrix requires to be recomputed this frame.
  16185. * @returns true if it requires to be recomputed otherwise, false.
  16186. */
  16187. needProjectionMatrixCompute(): boolean;
  16188. /**
  16189. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16190. */
  16191. forceProjectionMatrixCompute(): void;
  16192. /** @hidden */
  16193. _initCache(): void;
  16194. /** @hidden */
  16195. _isSynchronized(): boolean;
  16196. /**
  16197. * Computes the world matrix of the node
  16198. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16199. * @returns the world matrix
  16200. */
  16201. computeWorldMatrix(force?: boolean): Matrix;
  16202. /**
  16203. * Gets the minZ used for shadow according to both the scene and the light.
  16204. * @param activeCamera The camera we are returning the min for
  16205. * @returns the depth min z
  16206. */
  16207. getDepthMinZ(activeCamera: Camera): number;
  16208. /**
  16209. * Gets the maxZ used for shadow according to both the scene and the light.
  16210. * @param activeCamera The camera we are returning the max for
  16211. * @returns the depth max z
  16212. */
  16213. getDepthMaxZ(activeCamera: Camera): number;
  16214. /**
  16215. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16216. * @param matrix The materix to updated with the projection information
  16217. * @param viewMatrix The transform matrix of the light
  16218. * @param renderList The list of mesh to render in the map
  16219. * @returns The current light
  16220. */
  16221. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16222. }
  16223. }
  16224. declare module BABYLON {
  16225. /**
  16226. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16227. * These values define a cone of light starting from the position, emitting toward the direction.
  16228. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16229. * and the exponent defines the speed of the decay of the light with distance (reach).
  16230. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16231. */
  16232. class SpotLight extends ShadowLight {
  16233. private _angle;
  16234. private _innerAngle;
  16235. private _cosHalfAngle;
  16236. private _lightAngleScale;
  16237. private _lightAngleOffset;
  16238. /**
  16239. * Gets the cone angle of the spot light in Radians.
  16240. */
  16241. /**
  16242. * Sets the cone angle of the spot light in Radians.
  16243. */
  16244. angle: number;
  16245. /**
  16246. * Only used in gltf falloff mode, this defines the angle where
  16247. * the directional falloff will start before cutting at angle which could be seen
  16248. * as outer angle.
  16249. */
  16250. /**
  16251. * Only used in gltf falloff mode, this defines the angle where
  16252. * the directional falloff will start before cutting at angle which could be seen
  16253. * as outer angle.
  16254. */
  16255. innerAngle: number;
  16256. private _shadowAngleScale;
  16257. /**
  16258. * Allows scaling the angle of the light for shadow generation only.
  16259. */
  16260. /**
  16261. * Allows scaling the angle of the light for shadow generation only.
  16262. */
  16263. shadowAngleScale: number;
  16264. /**
  16265. * The light decay speed with the distance from the emission spot.
  16266. */
  16267. exponent: number;
  16268. private _projectionTextureMatrix;
  16269. /**
  16270. * Allows reading the projecton texture
  16271. */
  16272. readonly projectionTextureMatrix: Matrix;
  16273. protected _projectionTextureLightNear: number;
  16274. /**
  16275. * Gets the near clip of the Spotlight for texture projection.
  16276. */
  16277. /**
  16278. * Sets the near clip of the Spotlight for texture projection.
  16279. */
  16280. projectionTextureLightNear: number;
  16281. protected _projectionTextureLightFar: number;
  16282. /**
  16283. * Gets the far clip of the Spotlight for texture projection.
  16284. */
  16285. /**
  16286. * Sets the far clip of the Spotlight for texture projection.
  16287. */
  16288. projectionTextureLightFar: number;
  16289. protected _projectionTextureUpDirection: Vector3;
  16290. /**
  16291. * Gets the Up vector of the Spotlight for texture projection.
  16292. */
  16293. /**
  16294. * Sets the Up vector of the Spotlight for texture projection.
  16295. */
  16296. projectionTextureUpDirection: Vector3;
  16297. private _projectionTexture;
  16298. /**
  16299. * Gets the projection texture of the light.
  16300. */
  16301. /**
  16302. * Sets the projection texture of the light.
  16303. */
  16304. projectionTexture: Nullable<BaseTexture>;
  16305. private _projectionTextureViewLightDirty;
  16306. private _projectionTextureProjectionLightDirty;
  16307. private _projectionTextureDirty;
  16308. private _projectionTextureViewTargetVector;
  16309. private _projectionTextureViewLightMatrix;
  16310. private _projectionTextureProjectionLightMatrix;
  16311. private _projectionTextureScalingMatrix;
  16312. /**
  16313. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16314. * It can cast shadows.
  16315. * Documentation : http://doc.babylonjs.com/tutorials/lights
  16316. * @param name The light friendly name
  16317. * @param position The position of the spot light in the scene
  16318. * @param direction The direction of the light in the scene
  16319. * @param angle The cone angle of the light in Radians
  16320. * @param exponent The light decay speed with the distance from the emission spot
  16321. * @param scene The scene the lights belongs to
  16322. */
  16323. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16324. /**
  16325. * Returns the string "SpotLight".
  16326. * @returns the class name
  16327. */
  16328. getClassName(): string;
  16329. /**
  16330. * Returns the integer 2.
  16331. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16332. */
  16333. getTypeID(): number;
  16334. /**
  16335. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16336. */
  16337. protected _setDirection(value: Vector3): void;
  16338. /**
  16339. * Overrides the position setter to recompute the projection texture view light Matrix.
  16340. */
  16341. protected _setPosition(value: Vector3): void;
  16342. /**
  16343. * 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.
  16344. * Returns the SpotLight.
  16345. */
  16346. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16347. protected _computeProjectionTextureViewLightMatrix(): void;
  16348. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16349. /**
  16350. * Main function for light texture projection matrix computing.
  16351. */
  16352. protected _computeProjectionTextureMatrix(): void;
  16353. protected _buildUniformLayout(): void;
  16354. private _computeAngleValues;
  16355. /**
  16356. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16357. * @param effect The effect to update
  16358. * @param lightIndex The index of the light in the effect to update
  16359. * @returns The spot light
  16360. */
  16361. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16362. /**
  16363. * Disposes the light and the associated resources.
  16364. */
  16365. dispose(): void;
  16366. /**
  16367. * Prepares the list of defines specific to the light type.
  16368. * @param defines the list of defines
  16369. * @param lightIndex defines the index of the light for the effect
  16370. */
  16371. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16372. }
  16373. }
  16374. declare module BABYLON {
  16375. /**
  16376. * Interface used to present a loading screen while loading a scene
  16377. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16378. */
  16379. interface ILoadingScreen {
  16380. /**
  16381. * Function called to display the loading screen
  16382. */
  16383. displayLoadingUI: () => void;
  16384. /**
  16385. * Function called to hide the loading screen
  16386. */
  16387. hideLoadingUI: () => void;
  16388. /**
  16389. * Gets or sets the color to use for the background
  16390. */
  16391. loadingUIBackgroundColor: string;
  16392. /**
  16393. * Gets or sets the text to display while loading
  16394. */
  16395. loadingUIText: string;
  16396. }
  16397. /**
  16398. * Class used for the default loading screen
  16399. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16400. */
  16401. class DefaultLoadingScreen implements ILoadingScreen {
  16402. private _renderingCanvas;
  16403. private _loadingText;
  16404. private _loadingDivBackgroundColor;
  16405. private _loadingDiv;
  16406. private _loadingTextDiv;
  16407. /**
  16408. * Creates a new default loading screen
  16409. * @param _renderingCanvas defines the canvas used to render the scene
  16410. * @param _loadingText defines the default text to display
  16411. * @param _loadingDivBackgroundColor defines the default background color
  16412. */
  16413. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16414. /**
  16415. * Function called to display the loading screen
  16416. */
  16417. displayLoadingUI(): void;
  16418. /**
  16419. * Function called to hide the loading screen
  16420. */
  16421. hideLoadingUI(): void;
  16422. /**
  16423. * Gets or sets the text to display while loading
  16424. */
  16425. loadingUIText: string;
  16426. /**
  16427. * Gets or sets the color to use for the background
  16428. */
  16429. loadingUIBackgroundColor: string;
  16430. private _resizeLoadingUI;
  16431. }
  16432. }
  16433. declare module BABYLON {
  16434. /**
  16435. * Class used to represent data loading progression
  16436. */
  16437. class SceneLoaderProgressEvent {
  16438. /** defines if data length to load can be evaluated */
  16439. readonly lengthComputable: boolean;
  16440. /** defines the loaded data length */
  16441. readonly loaded: number;
  16442. /** defines the data length to load */
  16443. readonly total: number;
  16444. /**
  16445. * Create a new progress event
  16446. * @param lengthComputable defines if data length to load can be evaluated
  16447. * @param loaded defines the loaded data length
  16448. * @param total defines the data length to load
  16449. */
  16450. constructor(
  16451. /** defines if data length to load can be evaluated */
  16452. lengthComputable: boolean,
  16453. /** defines the loaded data length */
  16454. loaded: number,
  16455. /** defines the data length to load */
  16456. total: number);
  16457. /**
  16458. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16459. * @param event defines the source event
  16460. * @returns a new SceneLoaderProgressEvent
  16461. */
  16462. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16463. }
  16464. /**
  16465. * Interface used by SceneLoader plugins to define supported file extensions
  16466. */
  16467. interface ISceneLoaderPluginExtensions {
  16468. /**
  16469. * Defines the list of supported extensions
  16470. */
  16471. [extension: string]: {
  16472. isBinary: boolean;
  16473. };
  16474. }
  16475. /**
  16476. * Interface used by SceneLoader plugin factory
  16477. */
  16478. interface ISceneLoaderPluginFactory {
  16479. /**
  16480. * Defines the name of the factory
  16481. */
  16482. name: string;
  16483. /**
  16484. * Function called to create a new plugin
  16485. * @return the new plugin
  16486. */
  16487. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16488. /**
  16489. * Boolean indicating if the plugin can direct load specific data
  16490. */
  16491. canDirectLoad?: (data: string) => boolean;
  16492. }
  16493. /**
  16494. * Interface used to define a SceneLoader plugin
  16495. */
  16496. interface ISceneLoaderPlugin {
  16497. /**
  16498. * The friendly name of this plugin.
  16499. */
  16500. name: string;
  16501. /**
  16502. * The file extensions supported by this plugin.
  16503. */
  16504. extensions: string | ISceneLoaderPluginExtensions;
  16505. /**
  16506. * Import meshes into a scene.
  16507. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16508. * @param scene The scene to import into
  16509. * @param data The data to import
  16510. * @param rootUrl The root url for scene and resources
  16511. * @param meshes The meshes array to import into
  16512. * @param particleSystems The particle systems array to import into
  16513. * @param skeletons The skeletons array to import into
  16514. * @param onError The callback when import fails
  16515. * @returns True if successful or false otherwise
  16516. */
  16517. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16518. /**
  16519. * Load into a scene.
  16520. * @param scene The scene to load into
  16521. * @param data The data to import
  16522. * @param rootUrl The root url for scene and resources
  16523. * @param onError The callback when import fails
  16524. * @returns true if successful or false otherwise
  16525. */
  16526. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16527. /**
  16528. * The callback that returns true if the data can be directly loaded.
  16529. */
  16530. canDirectLoad?: (data: string) => boolean;
  16531. /**
  16532. * The callback that allows custom handling of the root url based on the response url.
  16533. */
  16534. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16535. /**
  16536. * Load into an asset container.
  16537. * @param scene The scene to load into
  16538. * @param data The data to import
  16539. * @param rootUrl The root url for scene and resources
  16540. * @param onError The callback when import fails
  16541. * @returns The loaded asset container
  16542. */
  16543. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16544. }
  16545. /**
  16546. * Interface used to define an async SceneLoader plugin
  16547. */
  16548. interface ISceneLoaderPluginAsync {
  16549. /**
  16550. * The friendly name of this plugin.
  16551. */
  16552. name: string;
  16553. /**
  16554. * The file extensions supported by this plugin.
  16555. */
  16556. extensions: string | ISceneLoaderPluginExtensions;
  16557. /**
  16558. * Import meshes into a scene.
  16559. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16560. * @param scene The scene to import into
  16561. * @param data The data to import
  16562. * @param rootUrl The root url for scene and resources
  16563. * @param onProgress The callback when the load progresses
  16564. * @param fileName Defines the name of the file to load
  16565. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16566. */
  16567. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16568. meshes: AbstractMesh[];
  16569. particleSystems: IParticleSystem[];
  16570. skeletons: Skeleton[];
  16571. animationGroups: AnimationGroup[];
  16572. }>;
  16573. /**
  16574. * Load into a scene.
  16575. * @param scene The scene to load into
  16576. * @param data The data to import
  16577. * @param rootUrl The root url for scene and resources
  16578. * @param onProgress The callback when the load progresses
  16579. * @param fileName Defines the name of the file to load
  16580. * @returns Nothing
  16581. */
  16582. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16583. /**
  16584. * The callback that returns true if the data can be directly loaded.
  16585. */
  16586. canDirectLoad?: (data: string) => boolean;
  16587. /**
  16588. * The callback that allows custom handling of the root url based on the response url.
  16589. */
  16590. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16591. /**
  16592. * Load into an asset container.
  16593. * @param scene The scene to load into
  16594. * @param data The data to import
  16595. * @param rootUrl The root url for scene and resources
  16596. * @param onProgress The callback when the load progresses
  16597. * @param fileName Defines the name of the file to load
  16598. * @returns The loaded asset container
  16599. */
  16600. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16601. }
  16602. /**
  16603. * Class used to load scene from various file formats using registered plugins
  16604. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16605. */
  16606. class SceneLoader {
  16607. private static _ForceFullSceneLoadingForIncremental;
  16608. private static _ShowLoadingScreen;
  16609. private static _CleanBoneMatrixWeights;
  16610. /**
  16611. * No logging while loading
  16612. */
  16613. static readonly NO_LOGGING: number;
  16614. /**
  16615. * Minimal logging while loading
  16616. */
  16617. static readonly MINIMAL_LOGGING: number;
  16618. /**
  16619. * Summary logging while loading
  16620. */
  16621. static readonly SUMMARY_LOGGING: number;
  16622. /**
  16623. * Detailled logging while loading
  16624. */
  16625. static readonly DETAILED_LOGGING: number;
  16626. private static _loggingLevel;
  16627. /**
  16628. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16629. */
  16630. static ForceFullSceneLoadingForIncremental: boolean;
  16631. /**
  16632. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16633. */
  16634. static ShowLoadingScreen: boolean;
  16635. /**
  16636. * Defines the current logging level (while loading the scene)
  16637. * @ignorenaming
  16638. */
  16639. static loggingLevel: number;
  16640. /**
  16641. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16642. */
  16643. static CleanBoneMatrixWeights: boolean;
  16644. /**
  16645. * Event raised when a plugin is used to load a scene
  16646. */
  16647. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16648. private static _registeredPlugins;
  16649. private static _getDefaultPlugin;
  16650. private static _getPluginForExtension;
  16651. private static _getPluginForDirectLoad;
  16652. private static _getPluginForFilename;
  16653. private static _getDirectLoad;
  16654. private static _loadData;
  16655. private static _getFileInfo;
  16656. /**
  16657. * Gets a plugin that can load the given extension
  16658. * @param extension defines the extension to load
  16659. * @returns a plugin or null if none works
  16660. */
  16661. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16662. /**
  16663. * Gets a boolean indicating that the given extension can be loaded
  16664. * @param extension defines the extension to load
  16665. * @returns true if the extension is supported
  16666. */
  16667. static IsPluginForExtensionAvailable(extension: string): boolean;
  16668. /**
  16669. * Adds a new plugin to the list of registered plugins
  16670. * @param plugin defines the plugin to add
  16671. */
  16672. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16673. /**
  16674. * Import meshes into a scene
  16675. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16676. * @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)
  16677. * @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)
  16678. * @param scene the instance of BABYLON.Scene to append to
  16679. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16680. * @param onProgress a callback with a progress event for each file being loaded
  16681. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16682. * @param pluginExtension the extension used to determine the plugin
  16683. * @returns The loaded plugin
  16684. */
  16685. 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>;
  16686. /**
  16687. * Import meshes into a scene
  16688. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16689. * @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)
  16690. * @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)
  16691. * @param scene the instance of BABYLON.Scene to append to
  16692. * @param onProgress a callback with a progress event for each file being loaded
  16693. * @param pluginExtension the extension used to determine the plugin
  16694. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16695. */
  16696. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16697. meshes: AbstractMesh[];
  16698. particleSystems: IParticleSystem[];
  16699. skeletons: Skeleton[];
  16700. animationGroups: AnimationGroup[];
  16701. }>;
  16702. /**
  16703. * Load a scene
  16704. * @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)
  16705. * @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)
  16706. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16707. * @param onSuccess a callback with the scene when import succeeds
  16708. * @param onProgress a callback with a progress event for each file being loaded
  16709. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16710. * @param pluginExtension the extension used to determine the plugin
  16711. * @returns The loaded plugin
  16712. */
  16713. 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>;
  16714. /**
  16715. * Load a scene
  16716. * @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)
  16717. * @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)
  16718. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16719. * @param onProgress a callback with a progress event for each file being loaded
  16720. * @param pluginExtension the extension used to determine the plugin
  16721. * @returns The loaded scene
  16722. */
  16723. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16724. /**
  16725. * Append a scene
  16726. * @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)
  16727. * @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)
  16728. * @param scene is the instance of BABYLON.Scene to append to
  16729. * @param onSuccess a callback with the scene when import succeeds
  16730. * @param onProgress a callback with a progress event for each file being loaded
  16731. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16732. * @param pluginExtension the extension used to determine the plugin
  16733. * @returns The loaded plugin
  16734. */
  16735. 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>;
  16736. /**
  16737. * Append a scene
  16738. * @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)
  16739. * @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)
  16740. * @param scene is the instance of BABYLON.Scene to append to
  16741. * @param onProgress a callback with a progress event for each file being loaded
  16742. * @param pluginExtension the extension used to determine the plugin
  16743. * @returns The given scene
  16744. */
  16745. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16746. /**
  16747. * Load a scene into an asset container
  16748. * @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)
  16749. * @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)
  16750. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16751. * @param onSuccess a callback with the scene when import succeeds
  16752. * @param onProgress a callback with a progress event for each file being loaded
  16753. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16754. * @param pluginExtension the extension used to determine the plugin
  16755. * @returns The loaded plugin
  16756. */
  16757. 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>;
  16758. /**
  16759. * Load a scene into an asset container
  16760. * @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)
  16761. * @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)
  16762. * @param scene is the instance of BABYLON.Scene to append to
  16763. * @param onProgress a callback with a progress event for each file being loaded
  16764. * @param pluginExtension the extension used to determine the plugin
  16765. * @returns The loaded asset container
  16766. */
  16767. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16768. }
  16769. }
  16770. declare module BABYLON {
  16771. /**
  16772. * Scalar computation library
  16773. */
  16774. class Scalar {
  16775. /**
  16776. * Two pi constants convenient for computation.
  16777. */
  16778. static TwoPi: number;
  16779. /**
  16780. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  16781. * @param a number
  16782. * @param b number
  16783. * @param epsilon (default = 1.401298E-45)
  16784. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  16785. */
  16786. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  16787. /**
  16788. * Returns a string : the upper case translation of the number i to hexadecimal.
  16789. * @param i number
  16790. * @returns the upper case translation of the number i to hexadecimal.
  16791. */
  16792. static ToHex(i: number): string;
  16793. /**
  16794. * Returns -1 if value is negative and +1 is value is positive.
  16795. * @param value the value
  16796. * @returns the value itself if it's equal to zero.
  16797. */
  16798. static Sign(value: number): number;
  16799. /**
  16800. * Returns the value itself if it's between min and max.
  16801. * Returns min if the value is lower than min.
  16802. * Returns max if the value is greater than max.
  16803. * @param value the value to clmap
  16804. * @param min the min value to clamp to (default: 0)
  16805. * @param max the max value to clamp to (default: 1)
  16806. * @returns the clamped value
  16807. */
  16808. static Clamp(value: number, min?: number, max?: number): number;
  16809. /**
  16810. * the log2 of value.
  16811. * @param value the value to compute log2 of
  16812. * @returns the log2 of value.
  16813. */
  16814. static Log2(value: number): number;
  16815. /**
  16816. * Loops the value, so that it is never larger than length and never smaller than 0.
  16817. *
  16818. * This is similar to the modulo operator but it works with floating point numbers.
  16819. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  16820. * With t = 5 and length = 2.5, the result would be 0.0.
  16821. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  16822. * @param value the value
  16823. * @param length the length
  16824. * @returns the looped value
  16825. */
  16826. static Repeat(value: number, length: number): number;
  16827. /**
  16828. * Normalize the value between 0.0 and 1.0 using min and max values
  16829. * @param value value to normalize
  16830. * @param min max to normalize between
  16831. * @param max min to normalize between
  16832. * @returns the normalized value
  16833. */
  16834. static Normalize(value: number, min: number, max: number): number;
  16835. /**
  16836. * Denormalize the value from 0.0 and 1.0 using min and max values
  16837. * @param normalized value to denormalize
  16838. * @param min max to denormalize between
  16839. * @param max min to denormalize between
  16840. * @returns the denormalized value
  16841. */
  16842. static Denormalize(normalized: number, min: number, max: number): number;
  16843. /**
  16844. * Calculates the shortest difference between two given angles given in degrees.
  16845. * @param current current angle in degrees
  16846. * @param target target angle in degrees
  16847. * @returns the delta
  16848. */
  16849. static DeltaAngle(current: number, target: number): number;
  16850. /**
  16851. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  16852. * @param tx value
  16853. * @param length length
  16854. * @returns The returned value will move back and forth between 0 and length
  16855. */
  16856. static PingPong(tx: number, length: number): number;
  16857. /**
  16858. * Interpolates between min and max with smoothing at the limits.
  16859. *
  16860. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  16861. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  16862. * @param from from
  16863. * @param to to
  16864. * @param tx value
  16865. * @returns the smooth stepped value
  16866. */
  16867. static SmoothStep(from: number, to: number, tx: number): number;
  16868. /**
  16869. * Moves a value current towards target.
  16870. *
  16871. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  16872. * Negative values of maxDelta pushes the value away from target.
  16873. * @param current current value
  16874. * @param target target value
  16875. * @param maxDelta max distance to move
  16876. * @returns resulting value
  16877. */
  16878. static MoveTowards(current: number, target: number, maxDelta: number): number;
  16879. /**
  16880. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  16881. *
  16882. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  16883. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  16884. * @param current current value
  16885. * @param target target value
  16886. * @param maxDelta max distance to move
  16887. * @returns resulting angle
  16888. */
  16889. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  16890. /**
  16891. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  16892. * @param start start value
  16893. * @param end target value
  16894. * @param amount amount to lerp between
  16895. * @returns the lerped value
  16896. */
  16897. static Lerp(start: number, end: number, amount: number): number;
  16898. /**
  16899. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  16900. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  16901. * @param start start value
  16902. * @param end target value
  16903. * @param amount amount to lerp between
  16904. * @returns the lerped value
  16905. */
  16906. static LerpAngle(start: number, end: number, amount: number): number;
  16907. /**
  16908. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  16909. * @param a start value
  16910. * @param b target value
  16911. * @param value value between a and b
  16912. * @returns the inverseLerp value
  16913. */
  16914. static InverseLerp(a: number, b: number, value: number): number;
  16915. /**
  16916. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  16917. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  16918. * @param value1 spline value
  16919. * @param tangent1 spline value
  16920. * @param value2 spline value
  16921. * @param tangent2 spline value
  16922. * @param amount input value
  16923. * @returns hermite result
  16924. */
  16925. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  16926. /**
  16927. * Returns a random float number between and min and max values
  16928. * @param min min value of random
  16929. * @param max max value of random
  16930. * @returns random value
  16931. */
  16932. static RandomRange(min: number, max: number): number;
  16933. /**
  16934. * This function returns percentage of a number in a given range.
  16935. *
  16936. * RangeToPercent(40,20,60) will return 0.5 (50%)
  16937. * RangeToPercent(34,0,100) will return 0.34 (34%)
  16938. * @param number to convert to percentage
  16939. * @param min min range
  16940. * @param max max range
  16941. * @returns the percentage
  16942. */
  16943. static RangeToPercent(number: number, min: number, max: number): number;
  16944. /**
  16945. * This function returns number that corresponds to the percentage in a given range.
  16946. *
  16947. * PercentToRange(0.34,0,100) will return 34.
  16948. * @param percent to convert to number
  16949. * @param min min range
  16950. * @param max max range
  16951. * @returns the number
  16952. */
  16953. static PercentToRange(percent: number, min: number, max: number): number;
  16954. /**
  16955. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  16956. * @param angle The angle to normalize in radian.
  16957. * @return The converted angle.
  16958. */
  16959. static NormalizeRadians(angle: number): number;
  16960. }
  16961. }
  16962. declare module BABYLON {
  16963. /**
  16964. * Constant used to convert a value to gamma space
  16965. * @ignorenaming
  16966. */
  16967. const ToGammaSpace: number;
  16968. /**
  16969. * Constant used to convert a value to linear space
  16970. * @ignorenaming
  16971. */
  16972. const ToLinearSpace = 2.2;
  16973. /**
  16974. * Constant used to define the minimal number value in Babylon.js
  16975. * @ignorenaming
  16976. */
  16977. const Epsilon = 0.001;
  16978. /**
  16979. * Class used to hold a RBG color
  16980. */
  16981. class Color3 {
  16982. /**
  16983. * Defines the red component (between 0 and 1, default is 0)
  16984. */
  16985. r: number;
  16986. /**
  16987. * Defines the green component (between 0 and 1, default is 0)
  16988. */
  16989. g: number;
  16990. /**
  16991. * Defines the blue component (between 0 and 1, default is 0)
  16992. */
  16993. b: number;
  16994. /**
  16995. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  16996. * @param r defines the red component (between 0 and 1, default is 0)
  16997. * @param g defines the green component (between 0 and 1, default is 0)
  16998. * @param b defines the blue component (between 0 and 1, default is 0)
  16999. */
  17000. constructor(
  17001. /**
  17002. * Defines the red component (between 0 and 1, default is 0)
  17003. */
  17004. r?: number,
  17005. /**
  17006. * Defines the green component (between 0 and 1, default is 0)
  17007. */
  17008. g?: number,
  17009. /**
  17010. * Defines the blue component (between 0 and 1, default is 0)
  17011. */
  17012. b?: number);
  17013. /**
  17014. * Creates a string with the Color3 current values
  17015. * @returns the string representation of the Color3 object
  17016. */
  17017. toString(): string;
  17018. /**
  17019. * Returns the string "Color3"
  17020. * @returns "Color3"
  17021. */
  17022. getClassName(): string;
  17023. /**
  17024. * Compute the Color3 hash code
  17025. * @returns an unique number that can be used to hash Color3 objects
  17026. */
  17027. getHashCode(): number;
  17028. /**
  17029. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  17030. * @param array defines the array where to store the r,g,b components
  17031. * @param index defines an optional index in the target array to define where to start storing values
  17032. * @returns the current Color3 object
  17033. */
  17034. toArray(array: FloatArray, index?: number): Color3;
  17035. /**
  17036. * Returns a new Color4 object from the current Color3 and the given alpha
  17037. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  17038. * @returns a new Color4 object
  17039. */
  17040. toColor4(alpha?: number): Color4;
  17041. /**
  17042. * Returns a new array populated with 3 numeric elements : red, green and blue values
  17043. * @returns the new array
  17044. */
  17045. asArray(): number[];
  17046. /**
  17047. * Returns the luminance value
  17048. * @returns a float value
  17049. */
  17050. toLuminance(): number;
  17051. /**
  17052. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  17053. * @param otherColor defines the second operand
  17054. * @returns the new Color3 object
  17055. */
  17056. multiply(otherColor: DeepImmutable<Color3>): Color3;
  17057. /**
  17058. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  17059. * @param otherColor defines the second operand
  17060. * @param result defines the Color3 object where to store the result
  17061. * @returns the current Color3
  17062. */
  17063. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  17064. /**
  17065. * Determines equality between Color3 objects
  17066. * @param otherColor defines the second operand
  17067. * @returns true if the rgb values are equal to the given ones
  17068. */
  17069. equals(otherColor: DeepImmutable<Color3>): boolean;
  17070. /**
  17071. * Determines equality between the current Color3 object and a set of r,b,g values
  17072. * @param r defines the red component to check
  17073. * @param g defines the green component to check
  17074. * @param b defines the blue component to check
  17075. * @returns true if the rgb values are equal to the given ones
  17076. */
  17077. equalsFloats(r: number, g: number, b: number): boolean;
  17078. /**
  17079. * Multiplies in place each rgb value by scale
  17080. * @param scale defines the scaling factor
  17081. * @returns the updated Color3
  17082. */
  17083. scale(scale: number): Color3;
  17084. /**
  17085. * Multiplies the rgb values by scale and stores the result into "result"
  17086. * @param scale defines the scaling factor
  17087. * @param result defines the Color3 object where to store the result
  17088. * @returns the unmodified current Color3
  17089. */
  17090. scaleToRef(scale: number, result: Color3): Color3;
  17091. /**
  17092. * Scale the current Color3 values by a factor and add the result to a given Color3
  17093. * @param scale defines the scale factor
  17094. * @param result defines color to store the result into
  17095. * @returns the unmodified current Color3
  17096. */
  17097. scaleAndAddToRef(scale: number, result: Color3): Color3;
  17098. /**
  17099. * Clamps the rgb values by the min and max values and stores the result into "result"
  17100. * @param min defines minimum clamping value (default is 0)
  17101. * @param max defines maximum clamping value (default is 1)
  17102. * @param result defines color to store the result into
  17103. * @returns the original Color3
  17104. */
  17105. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  17106. /**
  17107. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  17108. * @param otherColor defines the second operand
  17109. * @returns the new Color3
  17110. */
  17111. add(otherColor: DeepImmutable<Color3>): Color3;
  17112. /**
  17113. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  17114. * @param otherColor defines the second operand
  17115. * @param result defines Color3 object to store the result into
  17116. * @returns the unmodified current Color3
  17117. */
  17118. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  17119. /**
  17120. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  17121. * @param otherColor defines the second operand
  17122. * @returns the new Color3
  17123. */
  17124. subtract(otherColor: DeepImmutable<Color3>): Color3;
  17125. /**
  17126. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  17127. * @param otherColor defines the second operand
  17128. * @param result defines Color3 object to store the result into
  17129. * @returns the unmodified current Color3
  17130. */
  17131. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  17132. /**
  17133. * Copy the current object
  17134. * @returns a new Color3 copied the current one
  17135. */
  17136. clone(): Color3;
  17137. /**
  17138. * Copies the rgb values from the source in the current Color3
  17139. * @param source defines the source Color3 object
  17140. * @returns the updated Color3 object
  17141. */
  17142. copyFrom(source: DeepImmutable<Color3>): Color3;
  17143. /**
  17144. * Updates the Color3 rgb values from the given floats
  17145. * @param r defines the red component to read from
  17146. * @param g defines the green component to read from
  17147. * @param b defines the blue component to read from
  17148. * @returns the current Color3 object
  17149. */
  17150. copyFromFloats(r: number, g: number, b: number): Color3;
  17151. /**
  17152. * Updates the Color3 rgb values from the given floats
  17153. * @param r defines the red component to read from
  17154. * @param g defines the green component to read from
  17155. * @param b defines the blue component to read from
  17156. * @returns the current Color3 object
  17157. */
  17158. set(r: number, g: number, b: number): Color3;
  17159. /**
  17160. * Compute the Color3 hexadecimal code as a string
  17161. * @returns a string containing the hexadecimal representation of the Color3 object
  17162. */
  17163. toHexString(): string;
  17164. /**
  17165. * Computes a new Color3 converted from the current one to linear space
  17166. * @returns a new Color3 object
  17167. */
  17168. toLinearSpace(): Color3;
  17169. /**
  17170. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  17171. * @param convertedColor defines the Color3 object where to store the linear space version
  17172. * @returns the unmodified Color3
  17173. */
  17174. toLinearSpaceToRef(convertedColor: Color3): Color3;
  17175. /**
  17176. * Computes a new Color3 converted from the current one to gamma space
  17177. * @returns a new Color3 object
  17178. */
  17179. toGammaSpace(): Color3;
  17180. /**
  17181. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  17182. * @param convertedColor defines the Color3 object where to store the gamma space version
  17183. * @returns the unmodified Color3
  17184. */
  17185. toGammaSpaceToRef(convertedColor: Color3): Color3;
  17186. /**
  17187. * Creates a new Color3 from the string containing valid hexadecimal values
  17188. * @param hex defines a string containing valid hexadecimal values
  17189. * @returns a new Color3 object
  17190. */
  17191. static FromHexString(hex: string): Color3;
  17192. /**
  17193. * Creates a new Vector3 from the starting index of the given array
  17194. * @param array defines the source array
  17195. * @param offset defines an offset in the source array
  17196. * @returns a new Color3 object
  17197. */
  17198. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  17199. /**
  17200. * Creates a new Color3 from integer values (< 256)
  17201. * @param r defines the red component to read from (value between 0 and 255)
  17202. * @param g defines the green component to read from (value between 0 and 255)
  17203. * @param b defines the blue component to read from (value between 0 and 255)
  17204. * @returns a new Color3 object
  17205. */
  17206. static FromInts(r: number, g: number, b: number): Color3;
  17207. /**
  17208. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  17209. * @param start defines the start Color3 value
  17210. * @param end defines the end Color3 value
  17211. * @param amount defines the gradient value between start and end
  17212. * @returns a new Color3 object
  17213. */
  17214. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  17215. /**
  17216. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  17217. * @param left defines the start value
  17218. * @param right defines the end value
  17219. * @param amount defines the gradient factor
  17220. * @param result defines the Color3 object where to store the result
  17221. */
  17222. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  17223. /**
  17224. * Returns a Color3 value containing a red color
  17225. * @returns a new Color3 object
  17226. */
  17227. static Red(): Color3;
  17228. /**
  17229. * Returns a Color3 value containing a green color
  17230. * @returns a new Color3 object
  17231. */
  17232. static Green(): Color3;
  17233. /**
  17234. * Returns a Color3 value containing a blue color
  17235. * @returns a new Color3 object
  17236. */
  17237. static Blue(): Color3;
  17238. /**
  17239. * Returns a Color3 value containing a black color
  17240. * @returns a new Color3 object
  17241. */
  17242. static Black(): Color3;
  17243. /**
  17244. * Returns a Color3 value containing a white color
  17245. * @returns a new Color3 object
  17246. */
  17247. static White(): Color3;
  17248. /**
  17249. * Returns a Color3 value containing a purple color
  17250. * @returns a new Color3 object
  17251. */
  17252. static Purple(): Color3;
  17253. /**
  17254. * Returns a Color3 value containing a magenta color
  17255. * @returns a new Color3 object
  17256. */
  17257. static Magenta(): Color3;
  17258. /**
  17259. * Returns a Color3 value containing a yellow color
  17260. * @returns a new Color3 object
  17261. */
  17262. static Yellow(): Color3;
  17263. /**
  17264. * Returns a Color3 value containing a gray color
  17265. * @returns a new Color3 object
  17266. */
  17267. static Gray(): Color3;
  17268. /**
  17269. * Returns a Color3 value containing a teal color
  17270. * @returns a new Color3 object
  17271. */
  17272. static Teal(): Color3;
  17273. /**
  17274. * Returns a Color3 value containing a random color
  17275. * @returns a new Color3 object
  17276. */
  17277. static Random(): Color3;
  17278. }
  17279. /**
  17280. * Class used to hold a RBGA color
  17281. */
  17282. class Color4 {
  17283. /**
  17284. * Defines the red component (between 0 and 1, default is 0)
  17285. */
  17286. r: number;
  17287. /**
  17288. * Defines the green component (between 0 and 1, default is 0)
  17289. */
  17290. g: number;
  17291. /**
  17292. * Defines the blue component (between 0 and 1, default is 0)
  17293. */
  17294. b: number;
  17295. /**
  17296. * Defines the alpha component (between 0 and 1, default is 1)
  17297. */
  17298. a: number;
  17299. /**
  17300. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  17301. * @param r defines the red component (between 0 and 1, default is 0)
  17302. * @param g defines the green component (between 0 and 1, default is 0)
  17303. * @param b defines the blue component (between 0 and 1, default is 0)
  17304. * @param a defines the alpha component (between 0 and 1, default is 1)
  17305. */
  17306. constructor(
  17307. /**
  17308. * Defines the red component (between 0 and 1, default is 0)
  17309. */
  17310. r?: number,
  17311. /**
  17312. * Defines the green component (between 0 and 1, default is 0)
  17313. */
  17314. g?: number,
  17315. /**
  17316. * Defines the blue component (between 0 and 1, default is 0)
  17317. */
  17318. b?: number,
  17319. /**
  17320. * Defines the alpha component (between 0 and 1, default is 1)
  17321. */
  17322. a?: number);
  17323. /**
  17324. * Adds in place the given Color4 values to the current Color4 object
  17325. * @param right defines the second operand
  17326. * @returns the current updated Color4 object
  17327. */
  17328. addInPlace(right: DeepImmutable<Color4>): Color4;
  17329. /**
  17330. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  17331. * @returns the new array
  17332. */
  17333. asArray(): number[];
  17334. /**
  17335. * Stores from the starting index in the given array the Color4 successive values
  17336. * @param array defines the array where to store the r,g,b components
  17337. * @param index defines an optional index in the target array to define where to start storing values
  17338. * @returns the current Color4 object
  17339. */
  17340. toArray(array: number[], index?: number): Color4;
  17341. /**
  17342. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  17343. * @param right defines the second operand
  17344. * @returns a new Color4 object
  17345. */
  17346. add(right: DeepImmutable<Color4>): Color4;
  17347. /**
  17348. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  17349. * @param right defines the second operand
  17350. * @returns a new Color4 object
  17351. */
  17352. subtract(right: DeepImmutable<Color4>): Color4;
  17353. /**
  17354. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  17355. * @param right defines the second operand
  17356. * @param result defines the Color4 object where to store the result
  17357. * @returns the current Color4 object
  17358. */
  17359. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  17360. /**
  17361. * Creates a new Color4 with the current Color4 values multiplied by scale
  17362. * @param scale defines the scaling factor to apply
  17363. * @returns a new Color4 object
  17364. */
  17365. scale(scale: number): Color4;
  17366. /**
  17367. * Multiplies the current Color4 values by scale and stores the result in "result"
  17368. * @param scale defines the scaling factor to apply
  17369. * @param result defines the Color4 object where to store the result
  17370. * @returns the current unmodified Color4
  17371. */
  17372. scaleToRef(scale: number, result: Color4): Color4;
  17373. /**
  17374. * Scale the current Color4 values by a factor and add the result to a given Color4
  17375. * @param scale defines the scale factor
  17376. * @param result defines the Color4 object where to store the result
  17377. * @returns the unmodified current Color4
  17378. */
  17379. scaleAndAddToRef(scale: number, result: Color4): Color4;
  17380. /**
  17381. * Clamps the rgb values by the min and max values and stores the result into "result"
  17382. * @param min defines minimum clamping value (default is 0)
  17383. * @param max defines maximum clamping value (default is 1)
  17384. * @param result defines color to store the result into.
  17385. * @returns the cuurent Color4
  17386. */
  17387. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  17388. /**
  17389. * Multipy an Color4 value by another and return a new Color4 object
  17390. * @param color defines the Color4 value to multiply by
  17391. * @returns a new Color4 object
  17392. */
  17393. multiply(color: Color4): Color4;
  17394. /**
  17395. * Multipy a Color4 value by another and push the result in a reference value
  17396. * @param color defines the Color4 value to multiply by
  17397. * @param result defines the Color4 to fill the result in
  17398. * @returns the result Color4
  17399. */
  17400. multiplyToRef(color: Color4, result: Color4): Color4;
  17401. /**
  17402. * Creates a string with the Color4 current values
  17403. * @returns the string representation of the Color4 object
  17404. */
  17405. toString(): string;
  17406. /**
  17407. * Returns the string "Color4"
  17408. * @returns "Color4"
  17409. */
  17410. getClassName(): string;
  17411. /**
  17412. * Compute the Color4 hash code
  17413. * @returns an unique number that can be used to hash Color4 objects
  17414. */
  17415. getHashCode(): number;
  17416. /**
  17417. * Creates a new Color4 copied from the current one
  17418. * @returns a new Color4 object
  17419. */
  17420. clone(): Color4;
  17421. /**
  17422. * Copies the given Color4 values into the current one
  17423. * @param source defines the source Color4 object
  17424. * @returns the current updated Color4 object
  17425. */
  17426. copyFrom(source: Color4): Color4;
  17427. /**
  17428. * Copies the given float values into the current one
  17429. * @param r defines the red component to read from
  17430. * @param g defines the green component to read from
  17431. * @param b defines the blue component to read from
  17432. * @param a defines the alpha component to read from
  17433. * @returns the current updated Color4 object
  17434. */
  17435. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  17436. /**
  17437. * Copies the given float values into the current one
  17438. * @param r defines the red component to read from
  17439. * @param g defines the green component to read from
  17440. * @param b defines the blue component to read from
  17441. * @param a defines the alpha component to read from
  17442. * @returns the current updated Color4 object
  17443. */
  17444. set(r: number, g: number, b: number, a: number): Color4;
  17445. /**
  17446. * Compute the Color4 hexadecimal code as a string
  17447. * @returns a string containing the hexadecimal representation of the Color4 object
  17448. */
  17449. toHexString(): string;
  17450. /**
  17451. * Computes a new Color4 converted from the current one to linear space
  17452. * @returns a new Color4 object
  17453. */
  17454. toLinearSpace(): Color4;
  17455. /**
  17456. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  17457. * @param convertedColor defines the Color4 object where to store the linear space version
  17458. * @returns the unmodified Color4
  17459. */
  17460. toLinearSpaceToRef(convertedColor: Color4): Color4;
  17461. /**
  17462. * Computes a new Color4 converted from the current one to gamma space
  17463. * @returns a new Color4 object
  17464. */
  17465. toGammaSpace(): Color4;
  17466. /**
  17467. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  17468. * @param convertedColor defines the Color4 object where to store the gamma space version
  17469. * @returns the unmodified Color4
  17470. */
  17471. toGammaSpaceToRef(convertedColor: Color4): Color4;
  17472. /**
  17473. * Creates a new Color4 from the string containing valid hexadecimal values
  17474. * @param hex defines a string containing valid hexadecimal values
  17475. * @returns a new Color4 object
  17476. */
  17477. static FromHexString(hex: string): Color4;
  17478. /**
  17479. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  17480. * @param left defines the start value
  17481. * @param right defines the end value
  17482. * @param amount defines the gradient factor
  17483. * @returns a new Color4 object
  17484. */
  17485. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  17486. /**
  17487. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  17488. * @param left defines the start value
  17489. * @param right defines the end value
  17490. * @param amount defines the gradient factor
  17491. * @param result defines the Color4 object where to store data
  17492. */
  17493. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  17494. /**
  17495. * Creates a new Color4 from a Color3 and an alpha value
  17496. * @param color3 defines the source Color3 to read from
  17497. * @param alpha defines the alpha component (1.0 by default)
  17498. * @returns a new Color4 object
  17499. */
  17500. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  17501. /**
  17502. * Creates a new Color4 from the starting index element of the given array
  17503. * @param array defines the source array to read from
  17504. * @param offset defines the offset in the source array
  17505. * @returns a new Color4 object
  17506. */
  17507. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  17508. /**
  17509. * Creates a new Color3 from integer values (< 256)
  17510. * @param r defines the red component to read from (value between 0 and 255)
  17511. * @param g defines the green component to read from (value between 0 and 255)
  17512. * @param b defines the blue component to read from (value between 0 and 255)
  17513. * @param a defines the alpha component to read from (value between 0 and 255)
  17514. * @returns a new Color3 object
  17515. */
  17516. static FromInts(r: number, g: number, b: number, a: number): Color4;
  17517. /**
  17518. * Check the content of a given array and convert it to an array containing RGBA data
  17519. * If the original array was already containing count * 4 values then it is returned directly
  17520. * @param colors defines the array to check
  17521. * @param count defines the number of RGBA data to expect
  17522. * @returns an array containing count * 4 values (RGBA)
  17523. */
  17524. static CheckColors4(colors: number[], count: number): number[];
  17525. }
  17526. /**
  17527. * Class representing a vector containing 2 coordinates
  17528. */
  17529. class Vector2 {
  17530. /** defines the first coordinate */
  17531. x: number;
  17532. /** defines the second coordinate */
  17533. y: number;
  17534. /**
  17535. * Creates a new Vector2 from the given x and y coordinates
  17536. * @param x defines the first coordinate
  17537. * @param y defines the second coordinate
  17538. */
  17539. constructor(
  17540. /** defines the first coordinate */
  17541. x?: number,
  17542. /** defines the second coordinate */
  17543. y?: number);
  17544. /**
  17545. * Gets a string with the Vector2 coordinates
  17546. * @returns a string with the Vector2 coordinates
  17547. */
  17548. toString(): string;
  17549. /**
  17550. * Gets class name
  17551. * @returns the string "Vector2"
  17552. */
  17553. getClassName(): string;
  17554. /**
  17555. * Gets current vector hash code
  17556. * @returns the Vector2 hash code as a number
  17557. */
  17558. getHashCode(): number;
  17559. /**
  17560. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  17561. * @param array defines the source array
  17562. * @param index defines the offset in source array
  17563. * @returns the current Vector2
  17564. */
  17565. toArray(array: FloatArray, index?: number): Vector2;
  17566. /**
  17567. * Copy the current vector to an array
  17568. * @returns a new array with 2 elements: the Vector2 coordinates.
  17569. */
  17570. asArray(): number[];
  17571. /**
  17572. * Sets the Vector2 coordinates with the given Vector2 coordinates
  17573. * @param source defines the source Vector2
  17574. * @returns the current updated Vector2
  17575. */
  17576. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  17577. /**
  17578. * Sets the Vector2 coordinates with the given floats
  17579. * @param x defines the first coordinate
  17580. * @param y defines the second coordinate
  17581. * @returns the current updated Vector2
  17582. */
  17583. copyFromFloats(x: number, y: number): Vector2;
  17584. /**
  17585. * Sets the Vector2 coordinates with the given floats
  17586. * @param x defines the first coordinate
  17587. * @param y defines the second coordinate
  17588. * @returns the current updated Vector2
  17589. */
  17590. set(x: number, y: number): Vector2;
  17591. /**
  17592. * Add another vector with the current one
  17593. * @param otherVector defines the other vector
  17594. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  17595. */
  17596. add(otherVector: DeepImmutable<Vector2>): Vector2;
  17597. /**
  17598. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  17599. * @param otherVector defines the other vector
  17600. * @param result defines the target vector
  17601. * @returns the unmodified current Vector2
  17602. */
  17603. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17604. /**
  17605. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  17606. * @param otherVector defines the other vector
  17607. * @returns the current updated Vector2
  17608. */
  17609. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17610. /**
  17611. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  17612. * @param otherVector defines the other vector
  17613. * @returns a new Vector2
  17614. */
  17615. addVector3(otherVector: Vector3): Vector2;
  17616. /**
  17617. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  17618. * @param otherVector defines the other vector
  17619. * @returns a new Vector2
  17620. */
  17621. subtract(otherVector: Vector2): Vector2;
  17622. /**
  17623. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  17624. * @param otherVector defines the other vector
  17625. * @param result defines the target vector
  17626. * @returns the unmodified current Vector2
  17627. */
  17628. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17629. /**
  17630. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  17631. * @param otherVector defines the other vector
  17632. * @returns the current updated Vector2
  17633. */
  17634. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17635. /**
  17636. * Multiplies in place the current Vector2 coordinates by the given ones
  17637. * @param otherVector defines the other vector
  17638. * @returns the current updated Vector2
  17639. */
  17640. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17641. /**
  17642. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  17643. * @param otherVector defines the other vector
  17644. * @returns a new Vector2
  17645. */
  17646. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  17647. /**
  17648. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  17649. * @param otherVector defines the other vector
  17650. * @param result defines the target vector
  17651. * @returns the unmodified current Vector2
  17652. */
  17653. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17654. /**
  17655. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  17656. * @param x defines the first coordinate
  17657. * @param y defines the second coordinate
  17658. * @returns a new Vector2
  17659. */
  17660. multiplyByFloats(x: number, y: number): Vector2;
  17661. /**
  17662. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  17663. * @param otherVector defines the other vector
  17664. * @returns a new Vector2
  17665. */
  17666. divide(otherVector: Vector2): Vector2;
  17667. /**
  17668. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  17669. * @param otherVector defines the other vector
  17670. * @param result defines the target vector
  17671. * @returns the unmodified current Vector2
  17672. */
  17673. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  17674. /**
  17675. * Divides the current Vector2 coordinates by the given ones
  17676. * @param otherVector defines the other vector
  17677. * @returns the current updated Vector2
  17678. */
  17679. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  17680. /**
  17681. * Gets a new Vector2 with current Vector2 negated coordinates
  17682. * @returns a new Vector2
  17683. */
  17684. negate(): Vector2;
  17685. /**
  17686. * Multiply the Vector2 coordinates by scale
  17687. * @param scale defines the scaling factor
  17688. * @returns the current updated Vector2
  17689. */
  17690. scaleInPlace(scale: number): Vector2;
  17691. /**
  17692. * Returns a new Vector2 scaled by "scale" from the current Vector2
  17693. * @param scale defines the scaling factor
  17694. * @returns a new Vector2
  17695. */
  17696. scale(scale: number): Vector2;
  17697. /**
  17698. * Scale the current Vector2 values by a factor to a given Vector2
  17699. * @param scale defines the scale factor
  17700. * @param result defines the Vector2 object where to store the result
  17701. * @returns the unmodified current Vector2
  17702. */
  17703. scaleToRef(scale: number, result: Vector2): Vector2;
  17704. /**
  17705. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  17706. * @param scale defines the scale factor
  17707. * @param result defines the Vector2 object where to store the result
  17708. * @returns the unmodified current Vector2
  17709. */
  17710. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  17711. /**
  17712. * Gets a boolean if two vectors are equals
  17713. * @param otherVector defines the other vector
  17714. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  17715. */
  17716. equals(otherVector: DeepImmutable<Vector2>): boolean;
  17717. /**
  17718. * Gets a boolean if two vectors are equals (using an epsilon value)
  17719. * @param otherVector defines the other vector
  17720. * @param epsilon defines the minimal distance to consider equality
  17721. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  17722. */
  17723. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  17724. /**
  17725. * Gets a new Vector2 from current Vector2 floored values
  17726. * @returns a new Vector2
  17727. */
  17728. floor(): Vector2;
  17729. /**
  17730. * Gets a new Vector2 from current Vector2 floored values
  17731. * @returns a new Vector2
  17732. */
  17733. fract(): Vector2;
  17734. /**
  17735. * Gets the length of the vector
  17736. * @returns the vector length (float)
  17737. */
  17738. length(): number;
  17739. /**
  17740. * Gets the vector squared length
  17741. * @returns the vector squared length (float)
  17742. */
  17743. lengthSquared(): number;
  17744. /**
  17745. * Normalize the vector
  17746. * @returns the current updated Vector2
  17747. */
  17748. normalize(): Vector2;
  17749. /**
  17750. * Gets a new Vector2 copied from the Vector2
  17751. * @returns a new Vector2
  17752. */
  17753. clone(): Vector2;
  17754. /**
  17755. * Gets a new Vector2(0, 0)
  17756. * @returns a new Vector2
  17757. */
  17758. static Zero(): Vector2;
  17759. /**
  17760. * Gets a new Vector2(1, 1)
  17761. * @returns a new Vector2
  17762. */
  17763. static One(): Vector2;
  17764. /**
  17765. * Gets a new Vector2 set from the given index element of the given array
  17766. * @param array defines the data source
  17767. * @param offset defines the offset in the data source
  17768. * @returns a new Vector2
  17769. */
  17770. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  17771. /**
  17772. * Sets "result" from the given index element of the given array
  17773. * @param array defines the data source
  17774. * @param offset defines the offset in the data source
  17775. * @param result defines the target vector
  17776. */
  17777. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  17778. /**
  17779. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  17780. * @param value1 defines 1st point of control
  17781. * @param value2 defines 2nd point of control
  17782. * @param value3 defines 3rd point of control
  17783. * @param value4 defines 4th point of control
  17784. * @param amount defines the interpolation factor
  17785. * @returns a new Vector2
  17786. */
  17787. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  17788. /**
  17789. * 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".
  17790. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  17791. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  17792. * @param value defines the value to clamp
  17793. * @param min defines the lower limit
  17794. * @param max defines the upper limit
  17795. * @returns a new Vector2
  17796. */
  17797. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  17798. /**
  17799. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  17800. * @param value1 defines the 1st control point
  17801. * @param tangent1 defines the outgoing tangent
  17802. * @param value2 defines the 2nd control point
  17803. * @param tangent2 defines the incoming tangent
  17804. * @param amount defines the interpolation factor
  17805. * @returns a new Vector2
  17806. */
  17807. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  17808. /**
  17809. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  17810. * @param start defines the start vector
  17811. * @param end defines the end vector
  17812. * @param amount defines the interpolation factor
  17813. * @returns a new Vector2
  17814. */
  17815. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  17816. /**
  17817. * Gets the dot product of the vector "left" and the vector "right"
  17818. * @param left defines first vector
  17819. * @param right defines second vector
  17820. * @returns the dot product (float)
  17821. */
  17822. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  17823. /**
  17824. * Returns a new Vector2 equal to the normalized given vector
  17825. * @param vector defines the vector to normalize
  17826. * @returns a new Vector2
  17827. */
  17828. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  17829. /**
  17830. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  17831. * @param left defines 1st vector
  17832. * @param right defines 2nd vector
  17833. * @returns a new Vector2
  17834. */
  17835. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  17836. /**
  17837. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  17838. * @param left defines 1st vector
  17839. * @param right defines 2nd vector
  17840. * @returns a new Vector2
  17841. */
  17842. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  17843. /**
  17844. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  17845. * @param vector defines the vector to transform
  17846. * @param transformation defines the matrix to apply
  17847. * @returns a new Vector2
  17848. */
  17849. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  17850. /**
  17851. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  17852. * @param vector defines the vector to transform
  17853. * @param transformation defines the matrix to apply
  17854. * @param result defines the target vector
  17855. */
  17856. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  17857. /**
  17858. * Determines if a given vector is included in a triangle
  17859. * @param p defines the vector to test
  17860. * @param p0 defines 1st triangle point
  17861. * @param p1 defines 2nd triangle point
  17862. * @param p2 defines 3rd triangle point
  17863. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  17864. */
  17865. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  17866. /**
  17867. * Gets the distance between the vectors "value1" and "value2"
  17868. * @param value1 defines first vector
  17869. * @param value2 defines second vector
  17870. * @returns the distance between vectors
  17871. */
  17872. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  17873. /**
  17874. * Returns the squared distance between the vectors "value1" and "value2"
  17875. * @param value1 defines first vector
  17876. * @param value2 defines second vector
  17877. * @returns the squared distance between vectors
  17878. */
  17879. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  17880. /**
  17881. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  17882. * @param value1 defines first vector
  17883. * @param value2 defines second vector
  17884. * @returns a new Vector2
  17885. */
  17886. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  17887. /**
  17888. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  17889. * @param p defines the middle point
  17890. * @param segA defines one point of the segment
  17891. * @param segB defines the other point of the segment
  17892. * @returns the shortest distance
  17893. */
  17894. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  17895. }
  17896. /**
  17897. * Classed used to store (x,y,z) vector representation
  17898. * A Vector3 is the main object used in 3D geometry
  17899. * It can represent etiher the coordinates of a point the space, either a direction
  17900. * Reminder: Babylon.js uses a left handed forward facing system
  17901. */
  17902. class Vector3 {
  17903. /**
  17904. * Defines the first coordinates (on X axis)
  17905. */
  17906. x: number;
  17907. /**
  17908. * Defines the second coordinates (on Y axis)
  17909. */
  17910. y: number;
  17911. /**
  17912. * Defines the third coordinates (on Z axis)
  17913. */
  17914. z: number;
  17915. /**
  17916. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  17917. * @param x defines the first coordinates (on X axis)
  17918. * @param y defines the second coordinates (on Y axis)
  17919. * @param z defines the third coordinates (on Z axis)
  17920. */
  17921. constructor(
  17922. /**
  17923. * Defines the first coordinates (on X axis)
  17924. */
  17925. x?: number,
  17926. /**
  17927. * Defines the second coordinates (on Y axis)
  17928. */
  17929. y?: number,
  17930. /**
  17931. * Defines the third coordinates (on Z axis)
  17932. */
  17933. z?: number);
  17934. /**
  17935. * Creates a string representation of the Vector3
  17936. * @returns a string with the Vector3 coordinates.
  17937. */
  17938. toString(): string;
  17939. /**
  17940. * Gets the class name
  17941. * @returns the string "Vector3"
  17942. */
  17943. getClassName(): string;
  17944. /**
  17945. * Creates the Vector3 hash code
  17946. * @returns a number which tends to be unique between Vector3 instances
  17947. */
  17948. getHashCode(): number;
  17949. /**
  17950. * Creates an array containing three elements : the coordinates of the Vector3
  17951. * @returns a new array of numbers
  17952. */
  17953. asArray(): number[];
  17954. /**
  17955. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  17956. * @param array defines the destination array
  17957. * @param index defines the offset in the destination array
  17958. * @returns the current Vector3
  17959. */
  17960. toArray(array: FloatArray, index?: number): Vector3;
  17961. /**
  17962. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  17963. * @returns a new Quaternion object, computed from the Vector3 coordinates
  17964. */
  17965. toQuaternion(): Quaternion;
  17966. /**
  17967. * Adds the given vector to the current Vector3
  17968. * @param otherVector defines the second operand
  17969. * @returns the current updated Vector3
  17970. */
  17971. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  17972. /**
  17973. * Adds the given coordinates to the current Vector3
  17974. * @param x defines the x coordinate of the operand
  17975. * @param y defines the y coordinate of the operand
  17976. * @param z defines the z coordinate of the operand
  17977. * @returns the current updated Vector3
  17978. */
  17979. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  17980. /**
  17981. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  17982. * @param otherVector defines the second operand
  17983. * @returns the resulting Vector3
  17984. */
  17985. add(otherVector: DeepImmutable<Vector3>): Vector3;
  17986. /**
  17987. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  17988. * @param otherVector defines the second operand
  17989. * @param result defines the Vector3 object where to store the result
  17990. * @returns the current Vector3
  17991. */
  17992. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  17993. /**
  17994. * Subtract the given vector from the current Vector3
  17995. * @param otherVector defines the second operand
  17996. * @returns the current updated Vector3
  17997. */
  17998. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  17999. /**
  18000. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  18001. * @param otherVector defines the second operand
  18002. * @returns the resulting Vector3
  18003. */
  18004. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  18005. /**
  18006. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  18007. * @param otherVector defines the second operand
  18008. * @param result defines the Vector3 object where to store the result
  18009. * @returns the current Vector3
  18010. */
  18011. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18012. /**
  18013. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  18014. * @param x defines the x coordinate of the operand
  18015. * @param y defines the y coordinate of the operand
  18016. * @param z defines the z coordinate of the operand
  18017. * @returns the resulting Vector3
  18018. */
  18019. subtractFromFloats(x: number, y: number, z: number): Vector3;
  18020. /**
  18021. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  18022. * @param x defines the x coordinate of the operand
  18023. * @param y defines the y coordinate of the operand
  18024. * @param z defines the z coordinate of the operand
  18025. * @param result defines the Vector3 object where to store the result
  18026. * @returns the current Vector3
  18027. */
  18028. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  18029. /**
  18030. * Gets a new Vector3 set with the current Vector3 negated coordinates
  18031. * @returns a new Vector3
  18032. */
  18033. negate(): Vector3;
  18034. /**
  18035. * Multiplies the Vector3 coordinates by the float "scale"
  18036. * @param scale defines the multiplier factor
  18037. * @returns the current updated Vector3
  18038. */
  18039. scaleInPlace(scale: number): Vector3;
  18040. /**
  18041. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  18042. * @param scale defines the multiplier factor
  18043. * @returns a new Vector3
  18044. */
  18045. scale(scale: number): Vector3;
  18046. /**
  18047. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  18048. * @param scale defines the multiplier factor
  18049. * @param result defines the Vector3 object where to store the result
  18050. * @returns the current Vector3
  18051. */
  18052. scaleToRef(scale: number, result: Vector3): Vector3;
  18053. /**
  18054. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  18055. * @param scale defines the scale factor
  18056. * @param result defines the Vector3 object where to store the result
  18057. * @returns the unmodified current Vector3
  18058. */
  18059. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  18060. /**
  18061. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  18062. * @param otherVector defines the second operand
  18063. * @returns true if both vectors are equals
  18064. */
  18065. equals(otherVector: DeepImmutable<Vector3>): boolean;
  18066. /**
  18067. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  18068. * @param otherVector defines the second operand
  18069. * @param epsilon defines the minimal distance to define values as equals
  18070. * @returns true if both vectors are distant less than epsilon
  18071. */
  18072. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  18073. /**
  18074. * Returns true if the current Vector3 coordinates equals the given floats
  18075. * @param x defines the x coordinate of the operand
  18076. * @param y defines the y coordinate of the operand
  18077. * @param z defines the z coordinate of the operand
  18078. * @returns true if both vectors are equals
  18079. */
  18080. equalsToFloats(x: number, y: number, z: number): boolean;
  18081. /**
  18082. * Multiplies the current Vector3 coordinates by the given ones
  18083. * @param otherVector defines the second operand
  18084. * @returns the current updated Vector3
  18085. */
  18086. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  18087. /**
  18088. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  18089. * @param otherVector defines the second operand
  18090. * @returns the new Vector3
  18091. */
  18092. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  18093. /**
  18094. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  18095. * @param otherVector defines the second operand
  18096. * @param result defines the Vector3 object where to store the result
  18097. * @returns the current Vector3
  18098. */
  18099. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18100. /**
  18101. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  18102. * @param x defines the x coordinate of the operand
  18103. * @param y defines the y coordinate of the operand
  18104. * @param z defines the z coordinate of the operand
  18105. * @returns the new Vector3
  18106. */
  18107. multiplyByFloats(x: number, y: number, z: number): Vector3;
  18108. /**
  18109. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  18110. * @param otherVector defines the second operand
  18111. * @returns the new Vector3
  18112. */
  18113. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  18114. /**
  18115. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  18116. * @param otherVector defines the second operand
  18117. * @param result defines the Vector3 object where to store the result
  18118. * @returns the current Vector3
  18119. */
  18120. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  18121. /**
  18122. * Divides the current Vector3 coordinates by the given ones.
  18123. * @param otherVector defines the second operand
  18124. * @returns the current updated Vector3
  18125. */
  18126. divideInPlace(otherVector: Vector3): Vector3;
  18127. /**
  18128. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  18129. * @param other defines the second operand
  18130. * @returns the current updated Vector3
  18131. */
  18132. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  18133. /**
  18134. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  18135. * @param other defines the second operand
  18136. * @returns the current updated Vector3
  18137. */
  18138. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  18139. /**
  18140. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  18141. * @param x defines the x coordinate of the operand
  18142. * @param y defines the y coordinate of the operand
  18143. * @param z defines the z coordinate of the operand
  18144. * @returns the current updated Vector3
  18145. */
  18146. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18147. /**
  18148. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  18149. * @param x defines the x coordinate of the operand
  18150. * @param y defines the y coordinate of the operand
  18151. * @param z defines the z coordinate of the operand
  18152. * @returns the current updated Vector3
  18153. */
  18154. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18155. /**
  18156. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  18157. */
  18158. readonly isNonUniform: boolean;
  18159. /**
  18160. * Gets a new Vector3 from current Vector3 floored values
  18161. * @returns a new Vector3
  18162. */
  18163. floor(): Vector3;
  18164. /**
  18165. * Gets a new Vector3 from current Vector3 floored values
  18166. * @returns a new Vector3
  18167. */
  18168. fract(): Vector3;
  18169. /**
  18170. * Gets the length of the Vector3
  18171. * @returns the length of the Vecto3
  18172. */
  18173. length(): number;
  18174. /**
  18175. * Gets the squared length of the Vector3
  18176. * @returns squared length of the Vector3
  18177. */
  18178. lengthSquared(): number;
  18179. /**
  18180. * Normalize the current Vector3.
  18181. * Please note that this is an in place operation.
  18182. * @returns the current updated Vector3
  18183. */
  18184. normalize(): Vector3;
  18185. /**
  18186. * Reorders the x y z properties of the vector in place
  18187. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  18188. * @returns the current updated vector
  18189. */
  18190. reorderInPlace(order: string): this;
  18191. /**
  18192. * Rotates the vector around 0,0,0 by a quaternion
  18193. * @param quaternion the rotation quaternion
  18194. * @param result vector to store the result
  18195. * @returns the resulting vector
  18196. */
  18197. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  18198. /**
  18199. * Rotates a vector around a given point
  18200. * @param quaternion the rotation quaternion
  18201. * @param point the point to rotate around
  18202. * @param result vector to store the result
  18203. * @returns the resulting vector
  18204. */
  18205. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  18206. /**
  18207. * Normalize the current Vector3 with the given input length.
  18208. * Please note that this is an in place operation.
  18209. * @param len the length of the vector
  18210. * @returns the current updated Vector3
  18211. */
  18212. normalizeFromLength(len: number): Vector3;
  18213. /**
  18214. * Normalize the current Vector3 to a new vector
  18215. * @returns the new Vector3
  18216. */
  18217. normalizeToNew(): Vector3;
  18218. /**
  18219. * Normalize the current Vector3 to the reference
  18220. * @param reference define the Vector3 to update
  18221. * @returns the updated Vector3
  18222. */
  18223. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  18224. /**
  18225. * Creates a new Vector3 copied from the current Vector3
  18226. * @returns the new Vector3
  18227. */
  18228. clone(): Vector3;
  18229. /**
  18230. * Copies the given vector coordinates to the current Vector3 ones
  18231. * @param source defines the source Vector3
  18232. * @returns the current updated Vector3
  18233. */
  18234. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  18235. /**
  18236. * Copies the given floats to the current Vector3 coordinates
  18237. * @param x defines the x coordinate of the operand
  18238. * @param y defines the y coordinate of the operand
  18239. * @param z defines the z coordinate of the operand
  18240. * @returns the current updated Vector3
  18241. */
  18242. copyFromFloats(x: number, y: number, z: number): Vector3;
  18243. /**
  18244. * Copies the given floats to the current Vector3 coordinates
  18245. * @param x defines the x coordinate of the operand
  18246. * @param y defines the y coordinate of the operand
  18247. * @param z defines the z coordinate of the operand
  18248. * @returns the current updated Vector3
  18249. */
  18250. set(x: number, y: number, z: number): Vector3;
  18251. /**
  18252. * Copies the given float to the current Vector3 coordinates
  18253. * @param v defines the x, y and z coordinates of the operand
  18254. * @returns the current updated Vector3
  18255. */
  18256. setAll(v: number): Vector3;
  18257. /**
  18258. * Get the clip factor between two vectors
  18259. * @param vector0 defines the first operand
  18260. * @param vector1 defines the second operand
  18261. * @param axis defines the axis to use
  18262. * @param size defines the size along the axis
  18263. * @returns the clip factor
  18264. */
  18265. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  18266. /**
  18267. * Get angle between two vectors
  18268. * @param vector0 angle between vector0 and vector1
  18269. * @param vector1 angle between vector0 and vector1
  18270. * @param normal direction of the normal
  18271. * @return the angle between vector0 and vector1
  18272. */
  18273. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  18274. /**
  18275. * Returns a new Vector3 set from the index "offset" of the given array
  18276. * @param array defines the source array
  18277. * @param offset defines the offset in the source array
  18278. * @returns the new Vector3
  18279. */
  18280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  18281. /**
  18282. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  18283. * This function is deprecated. Use FromArray instead
  18284. * @param array defines the source array
  18285. * @param offset defines the offset in the source array
  18286. * @returns the new Vector3
  18287. */
  18288. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  18289. /**
  18290. * Sets the given vector "result" with the element values from the index "offset" of the given array
  18291. * @param array defines the source array
  18292. * @param offset defines the offset in the source array
  18293. * @param result defines the Vector3 where to store the result
  18294. */
  18295. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  18296. /**
  18297. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  18298. * This function is deprecated. Use FromArrayToRef instead.
  18299. * @param array defines the source array
  18300. * @param offset defines the offset in the source array
  18301. * @param result defines the Vector3 where to store the result
  18302. */
  18303. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  18304. /**
  18305. * Sets the given vector "result" with the given floats.
  18306. * @param x defines the x coordinate of the source
  18307. * @param y defines the y coordinate of the source
  18308. * @param z defines the z coordinate of the source
  18309. * @param result defines the Vector3 where to store the result
  18310. */
  18311. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  18312. /**
  18313. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  18314. * @returns a new empty Vector3
  18315. */
  18316. static Zero(): Vector3;
  18317. /**
  18318. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  18319. * @returns a new unit Vector3
  18320. */
  18321. static One(): Vector3;
  18322. /**
  18323. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  18324. * @returns a new up Vector3
  18325. */
  18326. static Up(): Vector3;
  18327. /**
  18328. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  18329. * @returns a new down Vector3
  18330. */
  18331. static Down(): Vector3;
  18332. /**
  18333. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  18334. * @returns a new forward Vector3
  18335. */
  18336. static Forward(): Vector3;
  18337. /**
  18338. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  18339. * @returns a new forward Vector3
  18340. */
  18341. static Backward(): Vector3;
  18342. /**
  18343. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  18344. * @returns a new right Vector3
  18345. */
  18346. static Right(): Vector3;
  18347. /**
  18348. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  18349. * @returns a new left Vector3
  18350. */
  18351. static Left(): Vector3;
  18352. /**
  18353. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  18354. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  18355. * @param vector defines the Vector3 to transform
  18356. * @param transformation defines the transformation matrix
  18357. * @returns the transformed Vector3
  18358. */
  18359. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  18360. /**
  18361. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  18362. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  18363. * @param vector defines the Vector3 to transform
  18364. * @param transformation defines the transformation matrix
  18365. * @param result defines the Vector3 where to store the result
  18366. */
  18367. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18368. /**
  18369. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  18370. * This method computes tranformed coordinates only, not transformed direction vectors
  18371. * @param x define the x coordinate of the source vector
  18372. * @param y define the y coordinate of the source vector
  18373. * @param z define the z coordinate of the source vector
  18374. * @param transformation defines the transformation matrix
  18375. * @param result defines the Vector3 where to store the result
  18376. */
  18377. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18378. /**
  18379. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  18380. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18381. * @param vector defines the Vector3 to transform
  18382. * @param transformation defines the transformation matrix
  18383. * @returns the new Vector3
  18384. */
  18385. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  18386. /**
  18387. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  18388. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18389. * @param vector defines the Vector3 to transform
  18390. * @param transformation defines the transformation matrix
  18391. * @param result defines the Vector3 where to store the result
  18392. */
  18393. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18394. /**
  18395. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  18396. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18397. * @param x define the x coordinate of the source vector
  18398. * @param y define the y coordinate of the source vector
  18399. * @param z define the z coordinate of the source vector
  18400. * @param transformation defines the transformation matrix
  18401. * @param result defines the Vector3 where to store the result
  18402. */
  18403. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  18404. /**
  18405. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  18406. * @param value1 defines the first control point
  18407. * @param value2 defines the second control point
  18408. * @param value3 defines the third control point
  18409. * @param value4 defines the fourth control point
  18410. * @param amount defines the amount on the spline to use
  18411. * @returns the new Vector3
  18412. */
  18413. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  18414. /**
  18415. * 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"
  18416. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  18417. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  18418. * @param value defines the current value
  18419. * @param min defines the lower range value
  18420. * @param max defines the upper range value
  18421. * @returns the new Vector3
  18422. */
  18423. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  18424. /**
  18425. * 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"
  18426. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  18427. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  18428. * @param value defines the current value
  18429. * @param min defines the lower range value
  18430. * @param max defines the upper range value
  18431. * @param result defines the Vector3 where to store the result
  18432. */
  18433. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  18434. /**
  18435. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  18436. * @param value1 defines the first control point
  18437. * @param tangent1 defines the first tangent vector
  18438. * @param value2 defines the second control point
  18439. * @param tangent2 defines the second tangent vector
  18440. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  18441. * @returns the new Vector3
  18442. */
  18443. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  18444. /**
  18445. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  18446. * @param start defines the start value
  18447. * @param end defines the end value
  18448. * @param amount max defines amount between both (between 0 and 1)
  18449. * @returns the new Vector3
  18450. */
  18451. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  18452. /**
  18453. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  18454. * @param start defines the start value
  18455. * @param end defines the end value
  18456. * @param amount max defines amount between both (between 0 and 1)
  18457. * @param result defines the Vector3 where to store the result
  18458. */
  18459. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  18460. /**
  18461. * Returns the dot product (float) between the vectors "left" and "right"
  18462. * @param left defines the left operand
  18463. * @param right defines the right operand
  18464. * @returns the dot product
  18465. */
  18466. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  18467. /**
  18468. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  18469. * The cross product is then orthogonal to both "left" and "right"
  18470. * @param left defines the left operand
  18471. * @param right defines the right operand
  18472. * @returns the cross product
  18473. */
  18474. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  18475. /**
  18476. * Sets the given vector "result" with the cross product of "left" and "right"
  18477. * The cross product is then orthogonal to both "left" and "right"
  18478. * @param left defines the left operand
  18479. * @param right defines the right operand
  18480. * @param result defines the Vector3 where to store the result
  18481. */
  18482. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  18483. /**
  18484. * Returns a new Vector3 as the normalization of the given vector
  18485. * @param vector defines the Vector3 to normalize
  18486. * @returns the new Vector3
  18487. */
  18488. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  18489. /**
  18490. * Sets the given vector "result" with the normalization of the given first vector
  18491. * @param vector defines the Vector3 to normalize
  18492. * @param result defines the Vector3 where to store the result
  18493. */
  18494. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  18495. /**
  18496. * Project a Vector3 onto screen space
  18497. * @param vector defines the Vector3 to project
  18498. * @param world defines the world matrix to use
  18499. * @param transform defines the transform (view x projection) matrix to use
  18500. * @param viewport defines the screen viewport to use
  18501. * @returns the new Vector3
  18502. */
  18503. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  18504. /** @hidden */
  18505. private static UnprojectFromInvertedMatrixToRef;
  18506. /**
  18507. * Unproject from screen space to object space
  18508. * @param source defines the screen space Vector3 to use
  18509. * @param viewportWidth defines the current width of the viewport
  18510. * @param viewportHeight defines the current height of the viewport
  18511. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18512. * @param transform defines the transform (view x projection) matrix to use
  18513. * @returns the new Vector3
  18514. */
  18515. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  18516. /**
  18517. * Unproject from screen space to object space
  18518. * @param source defines the screen space Vector3 to use
  18519. * @param viewportWidth defines the current width of the viewport
  18520. * @param viewportHeight defines the current height of the viewport
  18521. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18522. * @param view defines the view matrix to use
  18523. * @param projection defines the projection matrix to use
  18524. * @returns the new Vector3
  18525. */
  18526. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  18527. /**
  18528. * Unproject from screen space to object space
  18529. * @param source defines the screen space Vector3 to use
  18530. * @param viewportWidth defines the current width of the viewport
  18531. * @param viewportHeight defines the current height of the viewport
  18532. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18533. * @param view defines the view matrix to use
  18534. * @param projection defines the projection matrix to use
  18535. * @param result defines the Vector3 where to store the result
  18536. */
  18537. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  18538. /**
  18539. * Unproject from screen space to object space
  18540. * @param sourceX defines the screen space x coordinate to use
  18541. * @param sourceY defines the screen space y coordinate to use
  18542. * @param sourceZ defines the screen space z coordinate to use
  18543. * @param viewportWidth defines the current width of the viewport
  18544. * @param viewportHeight defines the current height of the viewport
  18545. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18546. * @param view defines the view matrix to use
  18547. * @param projection defines the projection matrix to use
  18548. * @param result defines the Vector3 where to store the result
  18549. */
  18550. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  18551. /**
  18552. * Unproject a ray from screen space to object space
  18553. * @param sourceX defines the screen space x coordinate to use
  18554. * @param sourceY defines the screen space y coordinate to use
  18555. * @param viewportWidth defines the current width of the viewport
  18556. * @param viewportHeight defines the current height of the viewport
  18557. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18558. * @param view defines the view matrix to use
  18559. * @param projection defines the projection matrix to use
  18560. * @param ray defines the Ray where to store the result
  18561. */
  18562. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  18563. /**
  18564. * Gets the minimal coordinate values between two Vector3
  18565. * @param left defines the first operand
  18566. * @param right defines the second operand
  18567. * @returns the new Vector3
  18568. */
  18569. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  18570. /**
  18571. * Gets the maximal coordinate values between two Vector3
  18572. * @param left defines the first operand
  18573. * @param right defines the second operand
  18574. * @returns the new Vector3
  18575. */
  18576. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  18577. /**
  18578. * Returns the distance between the vectors "value1" and "value2"
  18579. * @param value1 defines the first operand
  18580. * @param value2 defines the second operand
  18581. * @returns the distance
  18582. */
  18583. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  18584. /**
  18585. * Returns the squared distance between the vectors "value1" and "value2"
  18586. * @param value1 defines the first operand
  18587. * @param value2 defines the second operand
  18588. * @returns the squared distance
  18589. */
  18590. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  18591. /**
  18592. * Returns a new Vector3 located at the center between "value1" and "value2"
  18593. * @param value1 defines the first operand
  18594. * @param value2 defines the second operand
  18595. * @returns the new Vector3
  18596. */
  18597. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  18598. /**
  18599. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  18600. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  18601. * to something in order to rotate it from its local system to the given target system
  18602. * Note: axis1, axis2 and axis3 are normalized during this operation
  18603. * @param axis1 defines the first axis
  18604. * @param axis2 defines the second axis
  18605. * @param axis3 defines the third axis
  18606. * @returns a new Vector3
  18607. */
  18608. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  18609. /**
  18610. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  18611. * @param axis1 defines the first axis
  18612. * @param axis2 defines the second axis
  18613. * @param axis3 defines the third axis
  18614. * @param ref defines the Vector3 where to store the result
  18615. */
  18616. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  18617. }
  18618. /**
  18619. * Vector4 class created for EulerAngle class conversion to Quaternion
  18620. */
  18621. class Vector4 {
  18622. /** x value of the vector */
  18623. x: number;
  18624. /** y value of the vector */
  18625. y: number;
  18626. /** z value of the vector */
  18627. z: number;
  18628. /** w value of the vector */
  18629. w: number;
  18630. /**
  18631. * Creates a Vector4 object from the given floats.
  18632. * @param x x value of the vector
  18633. * @param y y value of the vector
  18634. * @param z z value of the vector
  18635. * @param w w value of the vector
  18636. */
  18637. constructor(
  18638. /** x value of the vector */
  18639. x: number,
  18640. /** y value of the vector */
  18641. y: number,
  18642. /** z value of the vector */
  18643. z: number,
  18644. /** w value of the vector */
  18645. w: number);
  18646. /**
  18647. * Returns the string with the Vector4 coordinates.
  18648. * @returns a string containing all the vector values
  18649. */
  18650. toString(): string;
  18651. /**
  18652. * Returns the string "Vector4".
  18653. * @returns "Vector4"
  18654. */
  18655. getClassName(): string;
  18656. /**
  18657. * Returns the Vector4 hash code.
  18658. * @returns a unique hash code
  18659. */
  18660. getHashCode(): number;
  18661. /**
  18662. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  18663. * @returns the resulting array
  18664. */
  18665. asArray(): number[];
  18666. /**
  18667. * Populates the given array from the given index with the Vector4 coordinates.
  18668. * @param array array to populate
  18669. * @param index index of the array to start at (default: 0)
  18670. * @returns the Vector4.
  18671. */
  18672. toArray(array: FloatArray, index?: number): Vector4;
  18673. /**
  18674. * Adds the given vector to the current Vector4.
  18675. * @param otherVector the vector to add
  18676. * @returns the updated Vector4.
  18677. */
  18678. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  18679. /**
  18680. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  18681. * @param otherVector the vector to add
  18682. * @returns the resulting vector
  18683. */
  18684. add(otherVector: DeepImmutable<Vector4>): Vector4;
  18685. /**
  18686. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  18687. * @param otherVector the vector to add
  18688. * @param result the vector to store the result
  18689. * @returns the current Vector4.
  18690. */
  18691. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  18692. /**
  18693. * Subtract in place the given vector from the current Vector4.
  18694. * @param otherVector the vector to subtract
  18695. * @returns the updated Vector4.
  18696. */
  18697. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  18698. /**
  18699. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  18700. * @param otherVector the vector to add
  18701. * @returns the new vector with the result
  18702. */
  18703. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  18704. /**
  18705. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  18706. * @param otherVector the vector to subtract
  18707. * @param result the vector to store the result
  18708. * @returns the current Vector4.
  18709. */
  18710. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  18711. /**
  18712. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18713. */
  18714. /**
  18715. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18716. * @param x value to subtract
  18717. * @param y value to subtract
  18718. * @param z value to subtract
  18719. * @param w value to subtract
  18720. * @returns new vector containing the result
  18721. */
  18722. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  18723. /**
  18724. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18725. * @param x value to subtract
  18726. * @param y value to subtract
  18727. * @param z value to subtract
  18728. * @param w value to subtract
  18729. * @param result the vector to store the result in
  18730. * @returns the current Vector4.
  18731. */
  18732. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  18733. /**
  18734. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  18735. * @returns a new vector with the negated values
  18736. */
  18737. negate(): Vector4;
  18738. /**
  18739. * Multiplies the current Vector4 coordinates by scale (float).
  18740. * @param scale the number to scale with
  18741. * @returns the updated Vector4.
  18742. */
  18743. scaleInPlace(scale: number): Vector4;
  18744. /**
  18745. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  18746. * @param scale the number to scale with
  18747. * @returns a new vector with the result
  18748. */
  18749. scale(scale: number): Vector4;
  18750. /**
  18751. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  18752. * @param scale the number to scale with
  18753. * @param result a vector to store the result in
  18754. * @returns the current Vector4.
  18755. */
  18756. scaleToRef(scale: number, result: Vector4): Vector4;
  18757. /**
  18758. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  18759. * @param scale defines the scale factor
  18760. * @param result defines the Vector4 object where to store the result
  18761. * @returns the unmodified current Vector4
  18762. */
  18763. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  18764. /**
  18765. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  18766. * @param otherVector the vector to compare against
  18767. * @returns true if they are equal
  18768. */
  18769. equals(otherVector: DeepImmutable<Vector4>): boolean;
  18770. /**
  18771. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  18772. * @param otherVector vector to compare against
  18773. * @param epsilon (Default: very small number)
  18774. * @returns true if they are equal
  18775. */
  18776. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  18777. /**
  18778. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  18779. * @param x x value to compare against
  18780. * @param y y value to compare against
  18781. * @param z z value to compare against
  18782. * @param w w value to compare against
  18783. * @returns true if equal
  18784. */
  18785. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  18786. /**
  18787. * Multiplies in place the current Vector4 by the given one.
  18788. * @param otherVector vector to multiple with
  18789. * @returns the updated Vector4.
  18790. */
  18791. multiplyInPlace(otherVector: Vector4): Vector4;
  18792. /**
  18793. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  18794. * @param otherVector vector to multiple with
  18795. * @returns resulting new vector
  18796. */
  18797. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  18798. /**
  18799. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  18800. * @param otherVector vector to multiple with
  18801. * @param result vector to store the result
  18802. * @returns the current Vector4.
  18803. */
  18804. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  18805. /**
  18806. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  18807. * @param x x value multiply with
  18808. * @param y y value multiply with
  18809. * @param z z value multiply with
  18810. * @param w w value multiply with
  18811. * @returns resulting new vector
  18812. */
  18813. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  18814. /**
  18815. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  18816. * @param otherVector vector to devide with
  18817. * @returns resulting new vector
  18818. */
  18819. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  18820. /**
  18821. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  18822. * @param otherVector vector to devide with
  18823. * @param result vector to store the result
  18824. * @returns the current Vector4.
  18825. */
  18826. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  18827. /**
  18828. * Divides the current Vector3 coordinates by the given ones.
  18829. * @param otherVector vector to devide with
  18830. * @returns the updated Vector3.
  18831. */
  18832. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  18833. /**
  18834. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  18835. * @param other defines the second operand
  18836. * @returns the current updated Vector4
  18837. */
  18838. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  18839. /**
  18840. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  18841. * @param other defines the second operand
  18842. * @returns the current updated Vector4
  18843. */
  18844. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  18845. /**
  18846. * Gets a new Vector4 from current Vector4 floored values
  18847. * @returns a new Vector4
  18848. */
  18849. floor(): Vector4;
  18850. /**
  18851. * Gets a new Vector4 from current Vector3 floored values
  18852. * @returns a new Vector4
  18853. */
  18854. fract(): Vector4;
  18855. /**
  18856. * Returns the Vector4 length (float).
  18857. * @returns the length
  18858. */
  18859. length(): number;
  18860. /**
  18861. * Returns the Vector4 squared length (float).
  18862. * @returns the length squared
  18863. */
  18864. lengthSquared(): number;
  18865. /**
  18866. * Normalizes in place the Vector4.
  18867. * @returns the updated Vector4.
  18868. */
  18869. normalize(): Vector4;
  18870. /**
  18871. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  18872. * @returns this converted to a new vector3
  18873. */
  18874. toVector3(): Vector3;
  18875. /**
  18876. * Returns a new Vector4 copied from the current one.
  18877. * @returns the new cloned vector
  18878. */
  18879. clone(): Vector4;
  18880. /**
  18881. * Updates the current Vector4 with the given one coordinates.
  18882. * @param source the source vector to copy from
  18883. * @returns the updated Vector4.
  18884. */
  18885. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  18886. /**
  18887. * Updates the current Vector4 coordinates with the given floats.
  18888. * @param x float to copy from
  18889. * @param y float to copy from
  18890. * @param z float to copy from
  18891. * @param w float to copy from
  18892. * @returns the updated Vector4.
  18893. */
  18894. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  18895. /**
  18896. * Updates the current Vector4 coordinates with the given floats.
  18897. * @param x float to set from
  18898. * @param y float to set from
  18899. * @param z float to set from
  18900. * @param w float to set from
  18901. * @returns the updated Vector4.
  18902. */
  18903. set(x: number, y: number, z: number, w: number): Vector4;
  18904. /**
  18905. * Copies the given float to the current Vector3 coordinates
  18906. * @param v defines the x, y, z and w coordinates of the operand
  18907. * @returns the current updated Vector3
  18908. */
  18909. setAll(v: number): Vector4;
  18910. /**
  18911. * Returns a new Vector4 set from the starting index of the given array.
  18912. * @param array the array to pull values from
  18913. * @param offset the offset into the array to start at
  18914. * @returns the new vector
  18915. */
  18916. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  18917. /**
  18918. * Updates the given vector "result" from the starting index of the given array.
  18919. * @param array the array to pull values from
  18920. * @param offset the offset into the array to start at
  18921. * @param result the vector to store the result in
  18922. */
  18923. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  18924. /**
  18925. * Updates the given vector "result" from the starting index of the given Float32Array.
  18926. * @param array the array to pull values from
  18927. * @param offset the offset into the array to start at
  18928. * @param result the vector to store the result in
  18929. */
  18930. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  18931. /**
  18932. * Updates the given vector "result" coordinates from the given floats.
  18933. * @param x float to set from
  18934. * @param y float to set from
  18935. * @param z float to set from
  18936. * @param w float to set from
  18937. * @param result the vector to the floats in
  18938. */
  18939. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  18940. /**
  18941. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  18942. * @returns the new vector
  18943. */
  18944. static Zero(): Vector4;
  18945. /**
  18946. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  18947. * @returns the new vector
  18948. */
  18949. static One(): Vector4;
  18950. /**
  18951. * Returns a new normalized Vector4 from the given one.
  18952. * @param vector the vector to normalize
  18953. * @returns the vector
  18954. */
  18955. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  18956. /**
  18957. * Updates the given vector "result" from the normalization of the given one.
  18958. * @param vector the vector to normalize
  18959. * @param result the vector to store the result in
  18960. */
  18961. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  18962. /**
  18963. * Returns a vector with the minimum values from the left and right vectors
  18964. * @param left left vector to minimize
  18965. * @param right right vector to minimize
  18966. * @returns a new vector with the minimum of the left and right vector values
  18967. */
  18968. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  18969. /**
  18970. * Returns a vector with the maximum values from the left and right vectors
  18971. * @param left left vector to maximize
  18972. * @param right right vector to maximize
  18973. * @returns a new vector with the maximum of the left and right vector values
  18974. */
  18975. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  18976. /**
  18977. * Returns the distance (float) between the vectors "value1" and "value2".
  18978. * @param value1 value to calulate the distance between
  18979. * @param value2 value to calulate the distance between
  18980. * @return the distance between the two vectors
  18981. */
  18982. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  18983. /**
  18984. * Returns the squared distance (float) between the vectors "value1" and "value2".
  18985. * @param value1 value to calulate the distance between
  18986. * @param value2 value to calulate the distance between
  18987. * @return the distance between the two vectors squared
  18988. */
  18989. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  18990. /**
  18991. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  18992. * @param value1 value to calulate the center between
  18993. * @param value2 value to calulate the center between
  18994. * @return the center between the two vectors
  18995. */
  18996. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  18997. /**
  18998. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  18999. * This methods computes transformed normalized direction vectors only.
  19000. * @param vector the vector to transform
  19001. * @param transformation the transformation matrix to apply
  19002. * @returns the new vector
  19003. */
  19004. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  19005. /**
  19006. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  19007. * This methods computes transformed normalized direction vectors only.
  19008. * @param vector the vector to transform
  19009. * @param transformation the transformation matrix to apply
  19010. * @param result the vector to store the result in
  19011. */
  19012. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  19013. /**
  19014. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  19015. * This methods computes transformed normalized direction vectors only.
  19016. * @param x value to transform
  19017. * @param y value to transform
  19018. * @param z value to transform
  19019. * @param w value to transform
  19020. * @param transformation the transformation matrix to apply
  19021. * @param result the vector to store the results in
  19022. */
  19023. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  19024. }
  19025. /**
  19026. * Interface for the size containing width and height
  19027. */
  19028. interface ISize {
  19029. /**
  19030. * Width
  19031. */
  19032. width: number;
  19033. /**
  19034. * Heighht
  19035. */
  19036. height: number;
  19037. }
  19038. /**
  19039. * Size containing widht and height
  19040. */
  19041. class Size implements ISize {
  19042. /**
  19043. * Width
  19044. */
  19045. width: number;
  19046. /**
  19047. * Height
  19048. */
  19049. height: number;
  19050. /**
  19051. * Creates a Size object from the given width and height (floats).
  19052. * @param width width of the new size
  19053. * @param height height of the new size
  19054. */
  19055. constructor(width: number, height: number);
  19056. /**
  19057. * Returns a string with the Size width and height
  19058. * @returns a string with the Size width and height
  19059. */
  19060. toString(): string;
  19061. /**
  19062. * "Size"
  19063. * @returns the string "Size"
  19064. */
  19065. getClassName(): string;
  19066. /**
  19067. * Returns the Size hash code.
  19068. * @returns a hash code for a unique width and height
  19069. */
  19070. getHashCode(): number;
  19071. /**
  19072. * Updates the current size from the given one.
  19073. * @param src the given size
  19074. */
  19075. copyFrom(src: Size): void;
  19076. /**
  19077. * Updates in place the current Size from the given floats.
  19078. * @param width width of the new size
  19079. * @param height height of the new size
  19080. * @returns the updated Size.
  19081. */
  19082. copyFromFloats(width: number, height: number): Size;
  19083. /**
  19084. * Updates in place the current Size from the given floats.
  19085. * @param width width to set
  19086. * @param height height to set
  19087. * @returns the updated Size.
  19088. */
  19089. set(width: number, height: number): Size;
  19090. /**
  19091. * Multiplies the width and height by numbers
  19092. * @param w factor to multiple the width by
  19093. * @param h factor to multiple the height by
  19094. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  19095. */
  19096. multiplyByFloats(w: number, h: number): Size;
  19097. /**
  19098. * Clones the size
  19099. * @returns a new Size copied from the given one.
  19100. */
  19101. clone(): Size;
  19102. /**
  19103. * True if the current Size and the given one width and height are strictly equal.
  19104. * @param other the other size to compare against
  19105. * @returns True if the current Size and the given one width and height are strictly equal.
  19106. */
  19107. equals(other: Size): boolean;
  19108. /**
  19109. * The surface of the Size : width * height (float).
  19110. */
  19111. readonly surface: number;
  19112. /**
  19113. * Create a new size of zero
  19114. * @returns a new Size set to (0.0, 0.0)
  19115. */
  19116. static Zero(): Size;
  19117. /**
  19118. * Sums the width and height of two sizes
  19119. * @param otherSize size to add to this size
  19120. * @returns a new Size set as the addition result of the current Size and the given one.
  19121. */
  19122. add(otherSize: Size): Size;
  19123. /**
  19124. * Subtracts the width and height of two
  19125. * @param otherSize size to subtract to this size
  19126. * @returns a new Size set as the subtraction result of the given one from the current Size.
  19127. */
  19128. subtract(otherSize: Size): Size;
  19129. /**
  19130. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  19131. * @param start starting size to lerp between
  19132. * @param end end size to lerp between
  19133. * @param amount amount to lerp between the start and end values
  19134. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  19135. */
  19136. static Lerp(start: Size, end: Size, amount: number): Size;
  19137. }
  19138. /**
  19139. * Class used to store quaternion data
  19140. * @see https://en.wikipedia.org/wiki/Quaternion
  19141. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  19142. */
  19143. class Quaternion {
  19144. /** defines the first component (0 by default) */
  19145. x: number;
  19146. /** defines the second component (0 by default) */
  19147. y: number;
  19148. /** defines the third component (0 by default) */
  19149. z: number;
  19150. /** defines the fourth component (1.0 by default) */
  19151. w: number;
  19152. /**
  19153. * Creates a new Quaternion from the given floats
  19154. * @param x defines the first component (0 by default)
  19155. * @param y defines the second component (0 by default)
  19156. * @param z defines the third component (0 by default)
  19157. * @param w defines the fourth component (1.0 by default)
  19158. */
  19159. constructor(
  19160. /** defines the first component (0 by default) */
  19161. x?: number,
  19162. /** defines the second component (0 by default) */
  19163. y?: number,
  19164. /** defines the third component (0 by default) */
  19165. z?: number,
  19166. /** defines the fourth component (1.0 by default) */
  19167. w?: number);
  19168. /**
  19169. * Gets a string representation for the current quaternion
  19170. * @returns a string with the Quaternion coordinates
  19171. */
  19172. toString(): string;
  19173. /**
  19174. * Gets the class name of the quaternion
  19175. * @returns the string "Quaternion"
  19176. */
  19177. getClassName(): string;
  19178. /**
  19179. * Gets a hash code for this quaternion
  19180. * @returns the quaternion hash code
  19181. */
  19182. getHashCode(): number;
  19183. /**
  19184. * Copy the quaternion to an array
  19185. * @returns a new array populated with 4 elements from the quaternion coordinates
  19186. */
  19187. asArray(): number[];
  19188. /**
  19189. * Check if two quaternions are equals
  19190. * @param otherQuaternion defines the second operand
  19191. * @return true if the current quaternion and the given one coordinates are strictly equals
  19192. */
  19193. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  19194. /**
  19195. * Clone the current quaternion
  19196. * @returns a new quaternion copied from the current one
  19197. */
  19198. clone(): Quaternion;
  19199. /**
  19200. * Copy a quaternion to the current one
  19201. * @param other defines the other quaternion
  19202. * @returns the updated current quaternion
  19203. */
  19204. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  19205. /**
  19206. * Updates the current quaternion with the given float coordinates
  19207. * @param x defines the x coordinate
  19208. * @param y defines the y coordinate
  19209. * @param z defines the z coordinate
  19210. * @param w defines the w coordinate
  19211. * @returns the updated current quaternion
  19212. */
  19213. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  19214. /**
  19215. * Updates the current quaternion from the given float coordinates
  19216. * @param x defines the x coordinate
  19217. * @param y defines the y coordinate
  19218. * @param z defines the z coordinate
  19219. * @param w defines the w coordinate
  19220. * @returns the updated current quaternion
  19221. */
  19222. set(x: number, y: number, z: number, w: number): Quaternion;
  19223. /**
  19224. * Adds two quaternions
  19225. * @param other defines the second operand
  19226. * @returns a new quaternion as the addition result of the given one and the current quaternion
  19227. */
  19228. add(other: DeepImmutable<Quaternion>): Quaternion;
  19229. /**
  19230. * Add a quaternion to the current one
  19231. * @param other defines the quaternion to add
  19232. * @returns the current quaternion
  19233. */
  19234. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  19235. /**
  19236. * Subtract two quaternions
  19237. * @param other defines the second operand
  19238. * @returns a new quaternion as the subtraction result of the given one from the current one
  19239. */
  19240. subtract(other: Quaternion): Quaternion;
  19241. /**
  19242. * Multiplies the current quaternion by a scale factor
  19243. * @param value defines the scale factor
  19244. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  19245. */
  19246. scale(value: number): Quaternion;
  19247. /**
  19248. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  19249. * @param scale defines the scale factor
  19250. * @param result defines the Quaternion object where to store the result
  19251. * @returns the unmodified current quaternion
  19252. */
  19253. scaleToRef(scale: number, result: Quaternion): Quaternion;
  19254. /**
  19255. * Multiplies in place the current quaternion by a scale factor
  19256. * @param value defines the scale factor
  19257. * @returns the current modified quaternion
  19258. */
  19259. scaleInPlace(value: number): Quaternion;
  19260. /**
  19261. * Scale the current quaternion values by a factor and add the result to a given quaternion
  19262. * @param scale defines the scale factor
  19263. * @param result defines the Quaternion object where to store the result
  19264. * @returns the unmodified current quaternion
  19265. */
  19266. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  19267. /**
  19268. * Multiplies two quaternions
  19269. * @param q1 defines the second operand
  19270. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  19271. */
  19272. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  19273. /**
  19274. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  19275. * @param q1 defines the second operand
  19276. * @param result defines the target quaternion
  19277. * @returns the current quaternion
  19278. */
  19279. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  19280. /**
  19281. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  19282. * @param q1 defines the second operand
  19283. * @returns the currentupdated quaternion
  19284. */
  19285. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  19286. /**
  19287. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  19288. * @param ref defines the target quaternion
  19289. * @returns the current quaternion
  19290. */
  19291. conjugateToRef(ref: Quaternion): Quaternion;
  19292. /**
  19293. * Conjugates in place (1-q) the current quaternion
  19294. * @returns the current updated quaternion
  19295. */
  19296. conjugateInPlace(): Quaternion;
  19297. /**
  19298. * Conjugates in place (1-q) the current quaternion
  19299. * @returns a new quaternion
  19300. */
  19301. conjugate(): Quaternion;
  19302. /**
  19303. * Gets length of current quaternion
  19304. * @returns the quaternion length (float)
  19305. */
  19306. length(): number;
  19307. /**
  19308. * Normalize in place the current quaternion
  19309. * @returns the current updated quaternion
  19310. */
  19311. normalize(): Quaternion;
  19312. /**
  19313. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  19314. * @param order is a reserved parameter and is ignore for now
  19315. * @returns a new Vector3 containing the Euler angles
  19316. */
  19317. toEulerAngles(order?: string): Vector3;
  19318. /**
  19319. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  19320. * @param result defines the vector which will be filled with the Euler angles
  19321. * @param order is a reserved parameter and is ignore for now
  19322. * @returns the current unchanged quaternion
  19323. */
  19324. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  19325. /**
  19326. * Updates the given rotation matrix with the current quaternion values
  19327. * @param result defines the target matrix
  19328. * @returns the current unchanged quaternion
  19329. */
  19330. toRotationMatrix(result: Matrix): Quaternion;
  19331. /**
  19332. * Updates the current quaternion from the given rotation matrix values
  19333. * @param matrix defines the source matrix
  19334. * @returns the current updated quaternion
  19335. */
  19336. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  19337. /**
  19338. * Creates a new quaternion from a rotation matrix
  19339. * @param matrix defines the source matrix
  19340. * @returns a new quaternion created from the given rotation matrix values
  19341. */
  19342. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  19343. /**
  19344. * Updates the given quaternion with the given rotation matrix values
  19345. * @param matrix defines the source matrix
  19346. * @param result defines the target quaternion
  19347. */
  19348. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  19349. /**
  19350. * Returns the dot product (float) between the quaternions "left" and "right"
  19351. * @param left defines the left operand
  19352. * @param right defines the right operand
  19353. * @returns the dot product
  19354. */
  19355. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  19356. /**
  19357. * Checks if the two quaternions are close to each other
  19358. * @param quat0 defines the first quaternion to check
  19359. * @param quat1 defines the second quaternion to check
  19360. * @returns true if the two quaternions are close to each other
  19361. */
  19362. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  19363. /**
  19364. * Creates an empty quaternion
  19365. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  19366. */
  19367. static Zero(): Quaternion;
  19368. /**
  19369. * Inverse a given quaternion
  19370. * @param q defines the source quaternion
  19371. * @returns a new quaternion as the inverted current quaternion
  19372. */
  19373. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  19374. /**
  19375. * Inverse a given quaternion
  19376. * @param q defines the source quaternion
  19377. * @param result the quaternion the result will be stored in
  19378. * @returns the result quaternion
  19379. */
  19380. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  19381. /**
  19382. * Creates an identity quaternion
  19383. * @returns the identity quaternion
  19384. */
  19385. static Identity(): Quaternion;
  19386. /**
  19387. * Gets a boolean indicating if the given quaternion is identity
  19388. * @param quaternion defines the quaternion to check
  19389. * @returns true if the quaternion is identity
  19390. */
  19391. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  19392. /**
  19393. * Creates a quaternion from a rotation around an axis
  19394. * @param axis defines the axis to use
  19395. * @param angle defines the angle to use
  19396. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  19397. */
  19398. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  19399. /**
  19400. * Creates a rotation around an axis and stores it into the given quaternion
  19401. * @param axis defines the axis to use
  19402. * @param angle defines the angle to use
  19403. * @param result defines the target quaternion
  19404. * @returns the target quaternion
  19405. */
  19406. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  19407. /**
  19408. * Creates a new quaternion from data stored into an array
  19409. * @param array defines the data source
  19410. * @param offset defines the offset in the source array where the data starts
  19411. * @returns a new quaternion
  19412. */
  19413. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  19414. /**
  19415. * Create a quaternion from Euler rotation angles
  19416. * @param x Pitch
  19417. * @param y Yaw
  19418. * @param z Roll
  19419. * @returns the new Quaternion
  19420. */
  19421. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  19422. /**
  19423. * Updates a quaternion from Euler rotation angles
  19424. * @param x Pitch
  19425. * @param y Yaw
  19426. * @param z Roll
  19427. * @param result the quaternion to store the result
  19428. * @returns the updated quaternion
  19429. */
  19430. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  19431. /**
  19432. * Create a quaternion from Euler rotation vector
  19433. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  19434. * @returns the new Quaternion
  19435. */
  19436. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  19437. /**
  19438. * Updates a quaternion from Euler rotation vector
  19439. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  19440. * @param result the quaternion to store the result
  19441. * @returns the updated quaternion
  19442. */
  19443. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  19444. /**
  19445. * Creates a new quaternion from the given Euler float angles (y, x, z)
  19446. * @param yaw defines the rotation around Y axis
  19447. * @param pitch defines the rotation around X axis
  19448. * @param roll defines the rotation around Z axis
  19449. * @returns the new quaternion
  19450. */
  19451. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  19452. /**
  19453. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  19454. * @param yaw defines the rotation around Y axis
  19455. * @param pitch defines the rotation around X axis
  19456. * @param roll defines the rotation around Z axis
  19457. * @param result defines the target quaternion
  19458. */
  19459. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  19460. /**
  19461. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  19462. * @param alpha defines the rotation around first axis
  19463. * @param beta defines the rotation around second axis
  19464. * @param gamma defines the rotation around third axis
  19465. * @returns the new quaternion
  19466. */
  19467. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  19468. /**
  19469. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  19470. * @param alpha defines the rotation around first axis
  19471. * @param beta defines the rotation around second axis
  19472. * @param gamma defines the rotation around third axis
  19473. * @param result defines the target quaternion
  19474. */
  19475. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  19476. /**
  19477. * 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)
  19478. * @param axis1 defines the first axis
  19479. * @param axis2 defines the second axis
  19480. * @param axis3 defines the third axis
  19481. * @returns the new quaternion
  19482. */
  19483. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  19484. /**
  19485. * 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
  19486. * @param axis1 defines the first axis
  19487. * @param axis2 defines the second axis
  19488. * @param axis3 defines the third axis
  19489. * @param ref defines the target quaternion
  19490. */
  19491. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  19492. /**
  19493. * Interpolates between two quaternions
  19494. * @param left defines first quaternion
  19495. * @param right defines second quaternion
  19496. * @param amount defines the gradient to use
  19497. * @returns the new interpolated quaternion
  19498. */
  19499. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  19500. /**
  19501. * Interpolates between two quaternions and stores it into a target quaternion
  19502. * @param left defines first quaternion
  19503. * @param right defines second quaternion
  19504. * @param amount defines the gradient to use
  19505. * @param result defines the target quaternion
  19506. */
  19507. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  19508. /**
  19509. * Interpolate between two quaternions using Hermite interpolation
  19510. * @param value1 defines first quaternion
  19511. * @param tangent1 defines the incoming tangent
  19512. * @param value2 defines second quaternion
  19513. * @param tangent2 defines the outgoing tangent
  19514. * @param amount defines the target quaternion
  19515. * @returns the new interpolated quaternion
  19516. */
  19517. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  19518. }
  19519. /**
  19520. * Class used to store matrix data (4x4)
  19521. */
  19522. class Matrix {
  19523. private static _updateFlagSeed;
  19524. private static _identityReadOnly;
  19525. private _isIdentity;
  19526. private _isIdentityDirty;
  19527. private _isIdentity3x2;
  19528. private _isIdentity3x2Dirty;
  19529. /**
  19530. * Gets the update flag of the matrix which is an unique number for the matrix.
  19531. * It will be incremented every time the matrix data change.
  19532. * You can use it to speed the comparison between two versions of the same matrix.
  19533. */
  19534. updateFlag: number;
  19535. private readonly _m;
  19536. /**
  19537. * Gets the internal data of the matrix
  19538. */
  19539. readonly m: DeepImmutable<Float32Array>;
  19540. /** @hidden */
  19541. _markAsUpdated(): void;
  19542. /** @hidden */
  19543. private _updateIdentityStatus;
  19544. /**
  19545. * Creates an empty matrix (filled with zeros)
  19546. */
  19547. constructor();
  19548. /**
  19549. * Check if the current matrix is identity
  19550. * @returns true is the matrix is the identity matrix
  19551. */
  19552. isIdentity(): boolean;
  19553. /**
  19554. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  19555. * @returns true is the matrix is the identity matrix
  19556. */
  19557. isIdentityAs3x2(): boolean;
  19558. /**
  19559. * Gets the determinant of the matrix
  19560. * @returns the matrix determinant
  19561. */
  19562. determinant(): number;
  19563. /**
  19564. * Returns the matrix as a Float32Array
  19565. * @returns the matrix underlying array
  19566. */
  19567. toArray(): DeepImmutable<Float32Array>;
  19568. /**
  19569. * Returns the matrix as a Float32Array
  19570. * @returns the matrix underlying array.
  19571. */
  19572. asArray(): DeepImmutable<Float32Array>;
  19573. /**
  19574. * Inverts the current matrix in place
  19575. * @returns the current inverted matrix
  19576. */
  19577. invert(): Matrix;
  19578. /**
  19579. * Sets all the matrix elements to zero
  19580. * @returns the current matrix
  19581. */
  19582. reset(): Matrix;
  19583. /**
  19584. * Adds the current matrix with a second one
  19585. * @param other defines the matrix to add
  19586. * @returns a new matrix as the addition of the current matrix and the given one
  19587. */
  19588. add(other: DeepImmutable<Matrix>): Matrix;
  19589. /**
  19590. * Sets the given matrix "result" to the addition of the current matrix and the given one
  19591. * @param other defines the matrix to add
  19592. * @param result defines the target matrix
  19593. * @returns the current matrix
  19594. */
  19595. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  19596. /**
  19597. * Adds in place the given matrix to the current matrix
  19598. * @param other defines the second operand
  19599. * @returns the current updated matrix
  19600. */
  19601. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  19602. /**
  19603. * Sets the given matrix to the current inverted Matrix
  19604. * @param other defines the target matrix
  19605. * @returns the unmodified current matrix
  19606. */
  19607. invertToRef(other: Matrix): Matrix;
  19608. /**
  19609. * add a value at the specified position in the current Matrix
  19610. * @param index the index of the value within the matrix. between 0 and 15.
  19611. * @param value the value to be added
  19612. * @returns the current updated matrix
  19613. */
  19614. addAtIndex(index: number, value: number): Matrix;
  19615. /**
  19616. * mutiply the specified position in the current Matrix by a value
  19617. * @param index the index of the value within the matrix. between 0 and 15.
  19618. * @param value the value to be added
  19619. * @returns the current updated matrix
  19620. */
  19621. multiplyAtIndex(index: number, value: number): Matrix;
  19622. /**
  19623. * Inserts the translation vector (using 3 floats) in the current matrix
  19624. * @param x defines the 1st component of the translation
  19625. * @param y defines the 2nd component of the translation
  19626. * @param z defines the 3rd component of the translation
  19627. * @returns the current updated matrix
  19628. */
  19629. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  19630. /**
  19631. * Inserts the translation vector in the current matrix
  19632. * @param vector3 defines the translation to insert
  19633. * @returns the current updated matrix
  19634. */
  19635. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  19636. /**
  19637. * Gets the translation value of the current matrix
  19638. * @returns a new Vector3 as the extracted translation from the matrix
  19639. */
  19640. getTranslation(): Vector3;
  19641. /**
  19642. * Fill a Vector3 with the extracted translation from the matrix
  19643. * @param result defines the Vector3 where to store the translation
  19644. * @returns the current matrix
  19645. */
  19646. getTranslationToRef(result: Vector3): Matrix;
  19647. /**
  19648. * Remove rotation and scaling part from the matrix
  19649. * @returns the updated matrix
  19650. */
  19651. removeRotationAndScaling(): Matrix;
  19652. /**
  19653. * Multiply two matrices
  19654. * @param other defines the second operand
  19655. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  19656. */
  19657. multiply(other: DeepImmutable<Matrix>): Matrix;
  19658. /**
  19659. * Copy the current matrix from the given one
  19660. * @param other defines the source matrix
  19661. * @returns the current updated matrix
  19662. */
  19663. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  19664. /**
  19665. * Populates the given array from the starting index with the current matrix values
  19666. * @param array defines the target array
  19667. * @param offset defines the offset in the target array where to start storing values
  19668. * @returns the current matrix
  19669. */
  19670. copyToArray(array: Float32Array, offset?: number): Matrix;
  19671. /**
  19672. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  19673. * @param other defines the second operand
  19674. * @param result defines the matrix where to store the multiplication
  19675. * @returns the current matrix
  19676. */
  19677. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  19678. /**
  19679. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  19680. * @param other defines the second operand
  19681. * @param result defines the array where to store the multiplication
  19682. * @param offset defines the offset in the target array where to start storing values
  19683. * @returns the current matrix
  19684. */
  19685. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  19686. /**
  19687. * Check equality between this matrix and a second one
  19688. * @param value defines the second matrix to compare
  19689. * @returns true is the current matrix and the given one values are strictly equal
  19690. */
  19691. equals(value: DeepImmutable<Matrix>): boolean;
  19692. /**
  19693. * Clone the current matrix
  19694. * @returns a new matrix from the current matrix
  19695. */
  19696. clone(): Matrix;
  19697. /**
  19698. * Returns the name of the current matrix class
  19699. * @returns the string "Matrix"
  19700. */
  19701. getClassName(): string;
  19702. /**
  19703. * Gets the hash code of the current matrix
  19704. * @returns the hash code
  19705. */
  19706. getHashCode(): number;
  19707. /**
  19708. * Decomposes the current Matrix into a translation, rotation and scaling components
  19709. * @param scale defines the scale vector3 given as a reference to update
  19710. * @param rotation defines the rotation quaternion given as a reference to update
  19711. * @param translation defines the translation vector3 given as a reference to update
  19712. * @returns true if operation was successful
  19713. */
  19714. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  19715. /**
  19716. * Gets specific row of the matrix
  19717. * @param index defines the number of the row to get
  19718. * @returns the index-th row of the current matrix as a new Vector4
  19719. */
  19720. getRow(index: number): Nullable<Vector4>;
  19721. /**
  19722. * Sets the index-th row of the current matrix to the vector4 values
  19723. * @param index defines the number of the row to set
  19724. * @param row defines the target vector4
  19725. * @returns the updated current matrix
  19726. */
  19727. setRow(index: number, row: Vector4): Matrix;
  19728. /**
  19729. * Compute the transpose of the matrix
  19730. * @returns the new transposed matrix
  19731. */
  19732. transpose(): Matrix;
  19733. /**
  19734. * Compute the transpose of the matrix and store it in a given matrix
  19735. * @param result defines the target matrix
  19736. * @returns the current matrix
  19737. */
  19738. transposeToRef(result: Matrix): Matrix;
  19739. /**
  19740. * Sets the index-th row of the current matrix with the given 4 x float values
  19741. * @param index defines the row index
  19742. * @param x defines the x component to set
  19743. * @param y defines the y component to set
  19744. * @param z defines the z component to set
  19745. * @param w defines the w component to set
  19746. * @returns the updated current matrix
  19747. */
  19748. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  19749. /**
  19750. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  19751. * @param scale defines the scale factor
  19752. * @returns a new matrix
  19753. */
  19754. scale(scale: number): Matrix;
  19755. /**
  19756. * Scale the current matrix values by a factor to a given result matrix
  19757. * @param scale defines the scale factor
  19758. * @param result defines the matrix to store the result
  19759. * @returns the current matrix
  19760. */
  19761. scaleToRef(scale: number, result: Matrix): Matrix;
  19762. /**
  19763. * Scale the current matrix values by a factor and add the result to a given matrix
  19764. * @param scale defines the scale factor
  19765. * @param result defines the Matrix to store the result
  19766. * @returns the current matrix
  19767. */
  19768. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  19769. /**
  19770. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  19771. * @param ref matrix to store the result
  19772. */
  19773. toNormalMatrix(ref: Matrix): void;
  19774. /**
  19775. * Gets only rotation part of the current matrix
  19776. * @returns a new matrix sets to the extracted rotation matrix from the current one
  19777. */
  19778. getRotationMatrix(): Matrix;
  19779. /**
  19780. * Extracts the rotation matrix from the current one and sets it as the given "result"
  19781. * @param result defines the target matrix to store data to
  19782. * @returns the current matrix
  19783. */
  19784. getRotationMatrixToRef(result: Matrix): Matrix;
  19785. /**
  19786. * Toggles model matrix from being right handed to left handed in place and vice versa
  19787. */
  19788. toggleModelMatrixHandInPlace(): void;
  19789. /**
  19790. * Toggles projection matrix from being right handed to left handed in place and vice versa
  19791. */
  19792. toggleProjectionMatrixHandInPlace(): void;
  19793. /**
  19794. * Creates a matrix from an array
  19795. * @param array defines the source array
  19796. * @param offset defines an offset in the source array
  19797. * @returns a new Matrix set from the starting index of the given array
  19798. */
  19799. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  19800. /**
  19801. * Copy the content of an array into a given matrix
  19802. * @param array defines the source array
  19803. * @param offset defines an offset in the source array
  19804. * @param result defines the target matrix
  19805. */
  19806. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  19807. /**
  19808. * Stores an array into a matrix after having multiplied each component by a given factor
  19809. * @param array defines the source array
  19810. * @param offset defines the offset in the source array
  19811. * @param scale defines the scaling factor
  19812. * @param result defines the target matrix
  19813. */
  19814. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  19815. /**
  19816. * Gets an identity matrix that must not be updated
  19817. */
  19818. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  19819. /**
  19820. * Stores a list of values (16) inside a given matrix
  19821. * @param initialM11 defines 1st value of 1st row
  19822. * @param initialM12 defines 2nd value of 1st row
  19823. * @param initialM13 defines 3rd value of 1st row
  19824. * @param initialM14 defines 4th value of 1st row
  19825. * @param initialM21 defines 1st value of 2nd row
  19826. * @param initialM22 defines 2nd value of 2nd row
  19827. * @param initialM23 defines 3rd value of 2nd row
  19828. * @param initialM24 defines 4th value of 2nd row
  19829. * @param initialM31 defines 1st value of 3rd row
  19830. * @param initialM32 defines 2nd value of 3rd row
  19831. * @param initialM33 defines 3rd value of 3rd row
  19832. * @param initialM34 defines 4th value of 3rd row
  19833. * @param initialM41 defines 1st value of 4th row
  19834. * @param initialM42 defines 2nd value of 4th row
  19835. * @param initialM43 defines 3rd value of 4th row
  19836. * @param initialM44 defines 4th value of 4th row
  19837. * @param result defines the target matrix
  19838. */
  19839. 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;
  19840. /**
  19841. * Creates new matrix from a list of values (16)
  19842. * @param initialM11 defines 1st value of 1st row
  19843. * @param initialM12 defines 2nd value of 1st row
  19844. * @param initialM13 defines 3rd value of 1st row
  19845. * @param initialM14 defines 4th value of 1st row
  19846. * @param initialM21 defines 1st value of 2nd row
  19847. * @param initialM22 defines 2nd value of 2nd row
  19848. * @param initialM23 defines 3rd value of 2nd row
  19849. * @param initialM24 defines 4th value of 2nd row
  19850. * @param initialM31 defines 1st value of 3rd row
  19851. * @param initialM32 defines 2nd value of 3rd row
  19852. * @param initialM33 defines 3rd value of 3rd row
  19853. * @param initialM34 defines 4th value of 3rd row
  19854. * @param initialM41 defines 1st value of 4th row
  19855. * @param initialM42 defines 2nd value of 4th row
  19856. * @param initialM43 defines 3rd value of 4th row
  19857. * @param initialM44 defines 4th value of 4th row
  19858. * @returns the new matrix
  19859. */
  19860. 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;
  19861. /**
  19862. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  19863. * @param scale defines the scale vector3
  19864. * @param rotation defines the rotation quaternion
  19865. * @param translation defines the translation vector3
  19866. * @returns a new matrix
  19867. */
  19868. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  19869. /**
  19870. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  19871. * @param scale defines the scale vector3
  19872. * @param rotation defines the rotation quaternion
  19873. * @param translation defines the translation vector3
  19874. * @param result defines the target matrix
  19875. */
  19876. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  19877. /**
  19878. * Creates a new identity matrix
  19879. * @returns a new identity matrix
  19880. */
  19881. static Identity(): Matrix;
  19882. /**
  19883. * Creates a new identity matrix and stores the result in a given matrix
  19884. * @param result defines the target matrix
  19885. */
  19886. static IdentityToRef(result: Matrix): void;
  19887. /**
  19888. * Creates a new zero matrix
  19889. * @returns a new zero matrix
  19890. */
  19891. static Zero(): Matrix;
  19892. /**
  19893. * Creates a new rotation matrix for "angle" radians around the X axis
  19894. * @param angle defines the angle (in radians) to use
  19895. * @return the new matrix
  19896. */
  19897. static RotationX(angle: number): Matrix;
  19898. /**
  19899. * Creates a new matrix as the invert of a given matrix
  19900. * @param source defines the source matrix
  19901. * @returns the new matrix
  19902. */
  19903. static Invert(source: DeepImmutable<Matrix>): Matrix;
  19904. /**
  19905. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  19906. * @param angle defines the angle (in radians) to use
  19907. * @param result defines the target matrix
  19908. */
  19909. static RotationXToRef(angle: number, result: Matrix): void;
  19910. /**
  19911. * Creates a new rotation matrix for "angle" radians around the Y axis
  19912. * @param angle defines the angle (in radians) to use
  19913. * @return the new matrix
  19914. */
  19915. static RotationY(angle: number): Matrix;
  19916. /**
  19917. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  19918. * @param angle defines the angle (in radians) to use
  19919. * @param result defines the target matrix
  19920. */
  19921. static RotationYToRef(angle: number, result: Matrix): void;
  19922. /**
  19923. * Creates a new rotation matrix for "angle" radians around the Z axis
  19924. * @param angle defines the angle (in radians) to use
  19925. * @return the new matrix
  19926. */
  19927. static RotationZ(angle: number): Matrix;
  19928. /**
  19929. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  19930. * @param angle defines the angle (in radians) to use
  19931. * @param result defines the target matrix
  19932. */
  19933. static RotationZToRef(angle: number, result: Matrix): void;
  19934. /**
  19935. * Creates a new rotation matrix for "angle" radians around the given axis
  19936. * @param axis defines the axis to use
  19937. * @param angle defines the angle (in radians) to use
  19938. * @return the new matrix
  19939. */
  19940. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  19941. /**
  19942. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  19943. * @param axis defines the axis to use
  19944. * @param angle defines the angle (in radians) to use
  19945. * @param result defines the target matrix
  19946. */
  19947. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  19948. /**
  19949. * Creates a rotation matrix
  19950. * @param yaw defines the yaw angle in radians (Y axis)
  19951. * @param pitch defines the pitch angle in radians (X axis)
  19952. * @param roll defines the roll angle in radians (X axis)
  19953. * @returns the new rotation matrix
  19954. */
  19955. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  19956. /**
  19957. * Creates a rotation matrix and stores it in a given matrix
  19958. * @param yaw defines the yaw angle in radians (Y axis)
  19959. * @param pitch defines the pitch angle in radians (X axis)
  19960. * @param roll defines the roll angle in radians (X axis)
  19961. * @param result defines the target matrix
  19962. */
  19963. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  19964. /**
  19965. * Creates a scaling matrix
  19966. * @param x defines the scale factor on X axis
  19967. * @param y defines the scale factor on Y axis
  19968. * @param z defines the scale factor on Z axis
  19969. * @returns the new matrix
  19970. */
  19971. static Scaling(x: number, y: number, z: number): Matrix;
  19972. /**
  19973. * Creates a scaling matrix and stores it in a given matrix
  19974. * @param x defines the scale factor on X axis
  19975. * @param y defines the scale factor on Y axis
  19976. * @param z defines the scale factor on Z axis
  19977. * @param result defines the target matrix
  19978. */
  19979. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  19980. /**
  19981. * Creates a translation matrix
  19982. * @param x defines the translation on X axis
  19983. * @param y defines the translation on Y axis
  19984. * @param z defines the translationon Z axis
  19985. * @returns the new matrix
  19986. */
  19987. static Translation(x: number, y: number, z: number): Matrix;
  19988. /**
  19989. * Creates a translation matrix and stores it in a given matrix
  19990. * @param x defines the translation on X axis
  19991. * @param y defines the translation on Y axis
  19992. * @param z defines the translationon Z axis
  19993. * @param result defines the target matrix
  19994. */
  19995. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  19996. /**
  19997. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  19998. * @param startValue defines the start value
  19999. * @param endValue defines the end value
  20000. * @param gradient defines the gradient factor
  20001. * @returns the new matrix
  20002. */
  20003. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  20004. /**
  20005. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  20006. * @param startValue defines the start value
  20007. * @param endValue defines the end value
  20008. * @param gradient defines the gradient factor
  20009. * @param result defines the Matrix object where to store data
  20010. */
  20011. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  20012. /**
  20013. * Builds a new matrix whose values are computed by:
  20014. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  20015. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  20016. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  20017. * @param startValue defines the first matrix
  20018. * @param endValue defines the second matrix
  20019. * @param gradient defines the gradient between the two matrices
  20020. * @returns the new matrix
  20021. */
  20022. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  20023. /**
  20024. * Update a matrix to values which are computed by:
  20025. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  20026. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  20027. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  20028. * @param startValue defines the first matrix
  20029. * @param endValue defines the second matrix
  20030. * @param gradient defines the gradient between the two matrices
  20031. * @param result defines the target matrix
  20032. */
  20033. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  20034. /**
  20035. * 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"
  20036. * This function works in left handed mode
  20037. * @param eye defines the final position of the entity
  20038. * @param target defines where the entity should look at
  20039. * @param up defines the up vector for the entity
  20040. * @returns the new matrix
  20041. */
  20042. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  20043. /**
  20044. * 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".
  20045. * This function works in left handed mode
  20046. * @param eye defines the final position of the entity
  20047. * @param target defines where the entity should look at
  20048. * @param up defines the up vector for the entity
  20049. * @param result defines the target matrix
  20050. */
  20051. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  20052. /**
  20053. * 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"
  20054. * This function works in right handed mode
  20055. * @param eye defines the final position of the entity
  20056. * @param target defines where the entity should look at
  20057. * @param up defines the up vector for the entity
  20058. * @returns the new matrix
  20059. */
  20060. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  20061. /**
  20062. * 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".
  20063. * This function works in right handed mode
  20064. * @param eye defines the final position of the entity
  20065. * @param target defines where the entity should look at
  20066. * @param up defines the up vector for the entity
  20067. * @param result defines the target matrix
  20068. */
  20069. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  20070. /**
  20071. * Create a left-handed orthographic projection matrix
  20072. * @param width defines the viewport width
  20073. * @param height defines the viewport height
  20074. * @param znear defines the near clip plane
  20075. * @param zfar defines the far clip plane
  20076. * @returns a new matrix as a left-handed orthographic projection matrix
  20077. */
  20078. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  20079. /**
  20080. * Store a left-handed orthographic projection to a given matrix
  20081. * @param width defines the viewport width
  20082. * @param height defines the viewport height
  20083. * @param znear defines the near clip plane
  20084. * @param zfar defines the far clip plane
  20085. * @param result defines the target matrix
  20086. */
  20087. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  20088. /**
  20089. * Create a left-handed orthographic projection matrix
  20090. * @param left defines the viewport left coordinate
  20091. * @param right defines the viewport right coordinate
  20092. * @param bottom defines the viewport bottom coordinate
  20093. * @param top defines the viewport top coordinate
  20094. * @param znear defines the near clip plane
  20095. * @param zfar defines the far clip plane
  20096. * @returns a new matrix as a left-handed orthographic projection matrix
  20097. */
  20098. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  20099. /**
  20100. * Stores a left-handed orthographic projection into a given matrix
  20101. * @param left defines the viewport left coordinate
  20102. * @param right defines the viewport right coordinate
  20103. * @param bottom defines the viewport bottom coordinate
  20104. * @param top defines the viewport top coordinate
  20105. * @param znear defines the near clip plane
  20106. * @param zfar defines the far clip plane
  20107. * @param result defines the target matrix
  20108. */
  20109. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  20110. /**
  20111. * Creates a right-handed orthographic projection matrix
  20112. * @param left defines the viewport left coordinate
  20113. * @param right defines the viewport right coordinate
  20114. * @param bottom defines the viewport bottom coordinate
  20115. * @param top defines the viewport top coordinate
  20116. * @param znear defines the near clip plane
  20117. * @param zfar defines the far clip plane
  20118. * @returns a new matrix as a right-handed orthographic projection matrix
  20119. */
  20120. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  20121. /**
  20122. * Stores a right-handed orthographic projection into a given matrix
  20123. * @param left defines the viewport left coordinate
  20124. * @param right defines the viewport right coordinate
  20125. * @param bottom defines the viewport bottom coordinate
  20126. * @param top defines the viewport top coordinate
  20127. * @param znear defines the near clip plane
  20128. * @param zfar defines the far clip plane
  20129. * @param result defines the target matrix
  20130. */
  20131. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  20132. /**
  20133. * Creates a left-handed perspective projection matrix
  20134. * @param width defines the viewport width
  20135. * @param height defines the viewport height
  20136. * @param znear defines the near clip plane
  20137. * @param zfar defines the far clip plane
  20138. * @returns a new matrix as a left-handed perspective projection matrix
  20139. */
  20140. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  20141. /**
  20142. * Creates a left-handed perspective projection matrix
  20143. * @param fov defines the horizontal field of view
  20144. * @param aspect defines the aspect ratio
  20145. * @param znear defines the near clip plane
  20146. * @param zfar defines the far clip plane
  20147. * @returns a new matrix as a left-handed perspective projection matrix
  20148. */
  20149. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  20150. /**
  20151. * Stores a left-handed perspective projection into a given matrix
  20152. * @param fov defines the horizontal field of view
  20153. * @param aspect defines the aspect ratio
  20154. * @param znear defines the near clip plane
  20155. * @param zfar defines the far clip plane
  20156. * @param result defines the target matrix
  20157. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  20158. */
  20159. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  20160. /**
  20161. * Creates a right-handed perspective projection matrix
  20162. * @param fov defines the horizontal field of view
  20163. * @param aspect defines the aspect ratio
  20164. * @param znear defines the near clip plane
  20165. * @param zfar defines the far clip plane
  20166. * @returns a new matrix as a right-handed perspective projection matrix
  20167. */
  20168. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  20169. /**
  20170. * Stores a right-handed perspective projection into a given matrix
  20171. * @param fov defines the horizontal field of view
  20172. * @param aspect defines the aspect ratio
  20173. * @param znear defines the near clip plane
  20174. * @param zfar defines the far clip plane
  20175. * @param result defines the target matrix
  20176. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  20177. */
  20178. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  20179. /**
  20180. * Stores a perspective projection for WebVR info a given matrix
  20181. * @param fov defines the field of view
  20182. * @param znear defines the near clip plane
  20183. * @param zfar defines the far clip plane
  20184. * @param result defines the target matrix
  20185. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  20186. */
  20187. static PerspectiveFovWebVRToRef(fov: {
  20188. upDegrees: number;
  20189. downDegrees: number;
  20190. leftDegrees: number;
  20191. rightDegrees: number;
  20192. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  20193. /**
  20194. * Computes a complete transformation matrix
  20195. * @param viewport defines the viewport to use
  20196. * @param world defines the world matrix
  20197. * @param view defines the view matrix
  20198. * @param projection defines the projection matrix
  20199. * @param zmin defines the near clip plane
  20200. * @param zmax defines the far clip plane
  20201. * @returns the transformation matrix
  20202. */
  20203. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  20204. /**
  20205. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  20206. * @param matrix defines the matrix to use
  20207. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  20208. */
  20209. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  20210. /**
  20211. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  20212. * @param matrix defines the matrix to use
  20213. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  20214. */
  20215. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  20216. /**
  20217. * Compute the transpose of a given matrix
  20218. * @param matrix defines the matrix to transpose
  20219. * @returns the new matrix
  20220. */
  20221. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  20222. /**
  20223. * Compute the transpose of a matrix and store it in a target matrix
  20224. * @param matrix defines the matrix to transpose
  20225. * @param result defines the target matrix
  20226. */
  20227. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  20228. /**
  20229. * Computes a reflection matrix from a plane
  20230. * @param plane defines the reflection plane
  20231. * @returns a new matrix
  20232. */
  20233. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  20234. /**
  20235. * Computes a reflection matrix from a plane
  20236. * @param plane defines the reflection plane
  20237. * @param result defines the target matrix
  20238. */
  20239. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  20240. /**
  20241. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  20242. * @param xaxis defines the value of the 1st axis
  20243. * @param yaxis defines the value of the 2nd axis
  20244. * @param zaxis defines the value of the 3rd axis
  20245. * @param result defines the target matrix
  20246. */
  20247. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  20248. /**
  20249. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  20250. * @param quat defines the quaternion to use
  20251. * @param result defines the target matrix
  20252. */
  20253. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  20254. }
  20255. /**
  20256. * Represens a plane by the equation ax + by + cz + d = 0
  20257. */
  20258. class Plane {
  20259. /**
  20260. * Normal of the plane (a,b,c)
  20261. */
  20262. normal: Vector3;
  20263. /**
  20264. * d component of the plane
  20265. */
  20266. d: number;
  20267. /**
  20268. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  20269. * @param a a component of the plane
  20270. * @param b b component of the plane
  20271. * @param c c component of the plane
  20272. * @param d d component of the plane
  20273. */
  20274. constructor(a: number, b: number, c: number, d: number);
  20275. /**
  20276. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  20277. */
  20278. asArray(): number[];
  20279. /**
  20280. * @returns a new plane copied from the current Plane.
  20281. */
  20282. clone(): Plane;
  20283. /**
  20284. * @returns the string "Plane".
  20285. */
  20286. getClassName(): string;
  20287. /**
  20288. * @returns the Plane hash code.
  20289. */
  20290. getHashCode(): number;
  20291. /**
  20292. * Normalize the current Plane in place.
  20293. * @returns the updated Plane.
  20294. */
  20295. normalize(): Plane;
  20296. /**
  20297. * Applies a transformation the plane and returns the result
  20298. * @param transformation the transformation matrix to be applied to the plane
  20299. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  20300. */
  20301. transform(transformation: DeepImmutable<Matrix>): Plane;
  20302. /**
  20303. * Calcualtte the dot product between the point and the plane normal
  20304. * @param point point to calculate the dot product with
  20305. * @returns the dot product (float) of the point coordinates and the plane normal.
  20306. */
  20307. dotCoordinate(point: DeepImmutable<Vector3>): number;
  20308. /**
  20309. * Updates the current Plane from the plane defined by the three given points.
  20310. * @param point1 one of the points used to contruct the plane
  20311. * @param point2 one of the points used to contruct the plane
  20312. * @param point3 one of the points used to contruct the plane
  20313. * @returns the updated Plane.
  20314. */
  20315. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  20316. /**
  20317. * Checks if the plane is facing a given direction
  20318. * @param direction the direction to check if the plane is facing
  20319. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  20320. * @returns True is the vector "direction" is the same side than the plane normal.
  20321. */
  20322. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  20323. /**
  20324. * Calculates the distance to a point
  20325. * @param point point to calculate distance to
  20326. * @returns the signed distance (float) from the given point to the Plane.
  20327. */
  20328. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  20329. /**
  20330. * Creates a plane from an array
  20331. * @param array the array to create a plane from
  20332. * @returns a new Plane from the given array.
  20333. */
  20334. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  20335. /**
  20336. * Creates a plane from three points
  20337. * @param point1 point used to create the plane
  20338. * @param point2 point used to create the plane
  20339. * @param point3 point used to create the plane
  20340. * @returns a new Plane defined by the three given points.
  20341. */
  20342. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  20343. /**
  20344. * Creates a plane from an origin point and a normal
  20345. * @param origin origin of the plane to be constructed
  20346. * @param normal normal of the plane to be constructed
  20347. * @returns a new Plane the normal vector to this plane at the given origin point.
  20348. * Note : the vector "normal" is updated because normalized.
  20349. */
  20350. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  20351. /**
  20352. * Calculates the distance from a plane and a point
  20353. * @param origin origin of the plane to be constructed
  20354. * @param normal normal of the plane to be constructed
  20355. * @param point point to calculate distance to
  20356. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  20357. */
  20358. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  20359. }
  20360. /**
  20361. * Class used to represent a viewport on screen
  20362. */
  20363. class Viewport {
  20364. /** viewport left coordinate */
  20365. x: number;
  20366. /** viewport top coordinate */
  20367. y: number;
  20368. /**viewport width */
  20369. width: number;
  20370. /** viewport height */
  20371. height: number;
  20372. /**
  20373. * Creates a Viewport object located at (x, y) and sized (width, height)
  20374. * @param x defines viewport left coordinate
  20375. * @param y defines viewport top coordinate
  20376. * @param width defines the viewport width
  20377. * @param height defines the viewport height
  20378. */
  20379. constructor(
  20380. /** viewport left coordinate */
  20381. x: number,
  20382. /** viewport top coordinate */
  20383. y: number,
  20384. /**viewport width */
  20385. width: number,
  20386. /** viewport height */
  20387. height: number);
  20388. /**
  20389. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  20390. * @param renderWidthOrEngine defines either an engine or the rendering width
  20391. * @param renderHeight defines the rendering height
  20392. * @returns a new Viewport
  20393. */
  20394. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  20395. /**
  20396. * Returns a new Viewport copied from the current one
  20397. * @returns a new Viewport
  20398. */
  20399. clone(): Viewport;
  20400. }
  20401. /**
  20402. * Reprasents a camera frustum
  20403. */
  20404. class Frustum {
  20405. /**
  20406. * Gets the planes representing the frustum
  20407. * @param transform matrix to be applied to the returned planes
  20408. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  20409. */
  20410. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  20411. /**
  20412. * Gets the near frustum plane transformed by the transform matrix
  20413. * @param transform transformation matrix to be applied to the resulting frustum plane
  20414. * @param frustumPlane the resuling frustum plane
  20415. */
  20416. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20417. /**
  20418. * Gets the far frustum plane transformed by the transform matrix
  20419. * @param transform transformation matrix to be applied to the resulting frustum plane
  20420. * @param frustumPlane the resuling frustum plane
  20421. */
  20422. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20423. /**
  20424. * Gets the left frustum plane transformed by the transform matrix
  20425. * @param transform transformation matrix to be applied to the resulting frustum plane
  20426. * @param frustumPlane the resuling frustum plane
  20427. */
  20428. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20429. /**
  20430. * Gets the right frustum plane transformed by the transform matrix
  20431. * @param transform transformation matrix to be applied to the resulting frustum plane
  20432. * @param frustumPlane the resuling frustum plane
  20433. */
  20434. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20435. /**
  20436. * Gets the top frustum plane transformed by the transform matrix
  20437. * @param transform transformation matrix to be applied to the resulting frustum plane
  20438. * @param frustumPlane the resuling frustum plane
  20439. */
  20440. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20441. /**
  20442. * Gets the bottom frustum plane transformed by the transform matrix
  20443. * @param transform transformation matrix to be applied to the resulting frustum plane
  20444. * @param frustumPlane the resuling frustum plane
  20445. */
  20446. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  20447. /**
  20448. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  20449. * @param transform transformation matrix to be applied to the resulting frustum planes
  20450. * @param frustumPlanes the resuling frustum planes
  20451. */
  20452. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  20453. }
  20454. /** Defines supported spaces */
  20455. enum Space {
  20456. /** Local (object) space */
  20457. LOCAL = 0,
  20458. /** World space */
  20459. WORLD = 1,
  20460. /** Bone space */
  20461. BONE = 2
  20462. }
  20463. /** Defines the 3 main axes */
  20464. class Axis {
  20465. /** X axis */
  20466. static X: Vector3;
  20467. /** Y axis */
  20468. static Y: Vector3;
  20469. /** Z axis */
  20470. static Z: Vector3;
  20471. }
  20472. /** Class used to represent a Bezier curve */
  20473. class BezierCurve {
  20474. /**
  20475. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  20476. * @param t defines the time
  20477. * @param x1 defines the left coordinate on X axis
  20478. * @param y1 defines the left coordinate on Y axis
  20479. * @param x2 defines the right coordinate on X axis
  20480. * @param y2 defines the right coordinate on Y axis
  20481. * @returns the interpolated value
  20482. */
  20483. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  20484. }
  20485. /**
  20486. * Defines potential orientation for back face culling
  20487. */
  20488. enum Orientation {
  20489. /**
  20490. * Clockwise
  20491. */
  20492. CW = 0,
  20493. /** Counter clockwise */
  20494. CCW = 1
  20495. }
  20496. /**
  20497. * Defines angle representation
  20498. */
  20499. class Angle {
  20500. private _radians;
  20501. /**
  20502. * Creates an Angle object of "radians" radians (float).
  20503. */
  20504. constructor(radians: number);
  20505. /**
  20506. * Get value in degrees
  20507. * @returns the Angle value in degrees (float)
  20508. */
  20509. degrees(): number;
  20510. /**
  20511. * Get value in radians
  20512. * @returns the Angle value in radians (float)
  20513. */
  20514. radians(): number;
  20515. /**
  20516. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  20517. * @param a defines first vector
  20518. * @param b defines second vector
  20519. * @returns a new Angle
  20520. */
  20521. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  20522. /**
  20523. * Gets a new Angle object from the given float in radians
  20524. * @param radians defines the angle value in radians
  20525. * @returns a new Angle
  20526. */
  20527. static FromRadians(radians: number): Angle;
  20528. /**
  20529. * Gets a new Angle object from the given float in degrees
  20530. * @param degrees defines the angle value in degrees
  20531. * @returns a new Angle
  20532. */
  20533. static FromDegrees(degrees: number): Angle;
  20534. }
  20535. /**
  20536. * This represents an arc in a 2d space.
  20537. */
  20538. class Arc2 {
  20539. /** Defines the start point of the arc */
  20540. startPoint: Vector2;
  20541. /** Defines the mid point of the arc */
  20542. midPoint: Vector2;
  20543. /** Defines the end point of the arc */
  20544. endPoint: Vector2;
  20545. /**
  20546. * Defines the center point of the arc.
  20547. */
  20548. centerPoint: Vector2;
  20549. /**
  20550. * Defines the radius of the arc.
  20551. */
  20552. radius: number;
  20553. /**
  20554. * Defines the angle of the arc (from mid point to end point).
  20555. */
  20556. angle: Angle;
  20557. /**
  20558. * Defines the start angle of the arc (from start point to middle point).
  20559. */
  20560. startAngle: Angle;
  20561. /**
  20562. * Defines the orientation of the arc (clock wise/counter clock wise).
  20563. */
  20564. orientation: Orientation;
  20565. /**
  20566. * Creates an Arc object from the three given points : start, middle and end.
  20567. * @param startPoint Defines the start point of the arc
  20568. * @param midPoint Defines the midlle point of the arc
  20569. * @param endPoint Defines the end point of the arc
  20570. */
  20571. constructor(
  20572. /** Defines the start point of the arc */
  20573. startPoint: Vector2,
  20574. /** Defines the mid point of the arc */
  20575. midPoint: Vector2,
  20576. /** Defines the end point of the arc */
  20577. endPoint: Vector2);
  20578. }
  20579. /**
  20580. * Represents a 2D path made up of multiple 2D points
  20581. */
  20582. class Path2 {
  20583. private _points;
  20584. private _length;
  20585. /**
  20586. * If the path start and end point are the same
  20587. */
  20588. closed: boolean;
  20589. /**
  20590. * Creates a Path2 object from the starting 2D coordinates x and y.
  20591. * @param x the starting points x value
  20592. * @param y the starting points y value
  20593. */
  20594. constructor(x: number, y: number);
  20595. /**
  20596. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  20597. * @param x the added points x value
  20598. * @param y the added points y value
  20599. * @returns the updated Path2.
  20600. */
  20601. addLineTo(x: number, y: number): Path2;
  20602. /**
  20603. * 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.
  20604. * @param midX middle point x value
  20605. * @param midY middle point y value
  20606. * @param endX end point x value
  20607. * @param endY end point y value
  20608. * @param numberOfSegments (default: 36)
  20609. * @returns the updated Path2.
  20610. */
  20611. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  20612. /**
  20613. * Closes the Path2.
  20614. * @returns the Path2.
  20615. */
  20616. close(): Path2;
  20617. /**
  20618. * Gets the sum of the distance between each sequential point in the path
  20619. * @returns the Path2 total length (float).
  20620. */
  20621. length(): number;
  20622. /**
  20623. * Gets the points which construct the path
  20624. * @returns the Path2 internal array of points.
  20625. */
  20626. getPoints(): Vector2[];
  20627. /**
  20628. * Retreives the point at the distance aways from the starting point
  20629. * @param normalizedLengthPosition the length along the path to retreive the point from
  20630. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  20631. */
  20632. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  20633. /**
  20634. * Creates a new path starting from an x and y position
  20635. * @param x starting x value
  20636. * @param y starting y value
  20637. * @returns a new Path2 starting at the coordinates (x, y).
  20638. */
  20639. static StartingAt(x: number, y: number): Path2;
  20640. }
  20641. /**
  20642. * Represents a 3D path made up of multiple 3D points
  20643. */
  20644. class Path3D {
  20645. /**
  20646. * an array of Vector3, the curve axis of the Path3D
  20647. */
  20648. path: Vector3[];
  20649. private _curve;
  20650. private _distances;
  20651. private _tangents;
  20652. private _normals;
  20653. private _binormals;
  20654. private _raw;
  20655. /**
  20656. * new Path3D(path, normal, raw)
  20657. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  20658. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  20659. * @param path an array of Vector3, the curve axis of the Path3D
  20660. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  20661. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  20662. */
  20663. constructor(
  20664. /**
  20665. * an array of Vector3, the curve axis of the Path3D
  20666. */
  20667. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  20668. /**
  20669. * Returns the Path3D array of successive Vector3 designing its curve.
  20670. * @returns the Path3D array of successive Vector3 designing its curve.
  20671. */
  20672. getCurve(): Vector3[];
  20673. /**
  20674. * Returns an array populated with tangent vectors on each Path3D curve point.
  20675. * @returns an array populated with tangent vectors on each Path3D curve point.
  20676. */
  20677. getTangents(): Vector3[];
  20678. /**
  20679. * Returns an array populated with normal vectors on each Path3D curve point.
  20680. * @returns an array populated with normal vectors on each Path3D curve point.
  20681. */
  20682. getNormals(): Vector3[];
  20683. /**
  20684. * Returns an array populated with binormal vectors on each Path3D curve point.
  20685. * @returns an array populated with binormal vectors on each Path3D curve point.
  20686. */
  20687. getBinormals(): Vector3[];
  20688. /**
  20689. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  20690. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  20691. */
  20692. getDistances(): number[];
  20693. /**
  20694. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  20695. * @param path path which all values are copied into the curves points
  20696. * @param firstNormal which should be projected onto the curve
  20697. * @returns the same object updated.
  20698. */
  20699. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  20700. private _compute;
  20701. private _getFirstNonNullVector;
  20702. private _getLastNonNullVector;
  20703. private _normalVector;
  20704. }
  20705. /**
  20706. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  20707. * A Curve3 is designed from a series of successive Vector3.
  20708. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  20709. */
  20710. class Curve3 {
  20711. private _points;
  20712. private _length;
  20713. /**
  20714. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  20715. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  20716. * @param v1 (Vector3) the control point
  20717. * @param v2 (Vector3) the end point of the Quadratic Bezier
  20718. * @param nbPoints (integer) the wanted number of points in the curve
  20719. * @returns the created Curve3
  20720. */
  20721. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  20722. /**
  20723. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  20724. * @param v0 (Vector3) the origin point of the Cubic Bezier
  20725. * @param v1 (Vector3) the first control point
  20726. * @param v2 (Vector3) the second control point
  20727. * @param v3 (Vector3) the end point of the Cubic Bezier
  20728. * @param nbPoints (integer) the wanted number of points in the curve
  20729. * @returns the created Curve3
  20730. */
  20731. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  20732. /**
  20733. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  20734. * @param p1 (Vector3) the origin point of the Hermite Spline
  20735. * @param t1 (Vector3) the tangent vector at the origin point
  20736. * @param p2 (Vector3) the end point of the Hermite Spline
  20737. * @param t2 (Vector3) the tangent vector at the end point
  20738. * @param nbPoints (integer) the wanted number of points in the curve
  20739. * @returns the created Curve3
  20740. */
  20741. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  20742. /**
  20743. * Returns a Curve3 object along a CatmullRom Spline curve :
  20744. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  20745. * @param nbPoints (integer) the wanted number of points between each curve control points
  20746. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  20747. * @returns the created Curve3
  20748. */
  20749. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  20750. /**
  20751. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  20752. * A Curve3 is designed from a series of successive Vector3.
  20753. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  20754. * @param points points which make up the curve
  20755. */
  20756. constructor(points: Vector3[]);
  20757. /**
  20758. * @returns the Curve3 stored array of successive Vector3
  20759. */
  20760. getPoints(): Vector3[];
  20761. /**
  20762. * @returns the computed length (float) of the curve.
  20763. */
  20764. length(): number;
  20765. /**
  20766. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  20767. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  20768. * curveA and curveB keep unchanged.
  20769. * @param curve the curve to continue from this curve
  20770. * @returns the newly constructed curve
  20771. */
  20772. continue(curve: DeepImmutable<Curve3>): Curve3;
  20773. private _computeLength;
  20774. }
  20775. /**
  20776. * Contains position and normal vectors for a vertex
  20777. */
  20778. class PositionNormalVertex {
  20779. /** the position of the vertex (defaut: 0,0,0) */
  20780. position: Vector3;
  20781. /** the normal of the vertex (defaut: 0,1,0) */
  20782. normal: Vector3;
  20783. /**
  20784. * Creates a PositionNormalVertex
  20785. * @param position the position of the vertex (defaut: 0,0,0)
  20786. * @param normal the normal of the vertex (defaut: 0,1,0)
  20787. */
  20788. constructor(
  20789. /** the position of the vertex (defaut: 0,0,0) */
  20790. position?: Vector3,
  20791. /** the normal of the vertex (defaut: 0,1,0) */
  20792. normal?: Vector3);
  20793. /**
  20794. * Clones the PositionNormalVertex
  20795. * @returns the cloned PositionNormalVertex
  20796. */
  20797. clone(): PositionNormalVertex;
  20798. }
  20799. /**
  20800. * Contains position, normal and uv vectors for a vertex
  20801. */
  20802. class PositionNormalTextureVertex {
  20803. /** the position of the vertex (defaut: 0,0,0) */
  20804. position: Vector3;
  20805. /** the normal of the vertex (defaut: 0,1,0) */
  20806. normal: Vector3;
  20807. /** the uv of the vertex (default: 0,0) */
  20808. uv: Vector2;
  20809. /**
  20810. * Creates a PositionNormalTextureVertex
  20811. * @param position the position of the vertex (defaut: 0,0,0)
  20812. * @param normal the normal of the vertex (defaut: 0,1,0)
  20813. * @param uv the uv of the vertex (default: 0,0)
  20814. */
  20815. constructor(
  20816. /** the position of the vertex (defaut: 0,0,0) */
  20817. position?: Vector3,
  20818. /** the normal of the vertex (defaut: 0,1,0) */
  20819. normal?: Vector3,
  20820. /** the uv of the vertex (default: 0,0) */
  20821. uv?: Vector2);
  20822. /**
  20823. * Clones the PositionNormalTextureVertex
  20824. * @returns the cloned PositionNormalTextureVertex
  20825. */
  20826. clone(): PositionNormalTextureVertex;
  20827. }
  20828. /**
  20829. * @hidden
  20830. */
  20831. class Tmp {
  20832. static Color3: Color3[];
  20833. static Color4: Color4[];
  20834. static Vector2: Vector2[];
  20835. static Vector3: Vector3[];
  20836. static Vector4: Vector4[];
  20837. static Quaternion: Quaternion[];
  20838. static Matrix: Matrix[];
  20839. }
  20840. }
  20841. declare module BABYLON {
  20842. /**
  20843. * Class representing spherical polynomial coefficients to the 3rd degree
  20844. */
  20845. class SphericalPolynomial {
  20846. /**
  20847. * The x coefficients of the spherical polynomial
  20848. */
  20849. x: Vector3;
  20850. /**
  20851. * The y coefficients of the spherical polynomial
  20852. */
  20853. y: Vector3;
  20854. /**
  20855. * The z coefficients of the spherical polynomial
  20856. */
  20857. z: Vector3;
  20858. /**
  20859. * The xx coefficients of the spherical polynomial
  20860. */
  20861. xx: Vector3;
  20862. /**
  20863. * The yy coefficients of the spherical polynomial
  20864. */
  20865. yy: Vector3;
  20866. /**
  20867. * The zz coefficients of the spherical polynomial
  20868. */
  20869. zz: Vector3;
  20870. /**
  20871. * The xy coefficients of the spherical polynomial
  20872. */
  20873. xy: Vector3;
  20874. /**
  20875. * The yz coefficients of the spherical polynomial
  20876. */
  20877. yz: Vector3;
  20878. /**
  20879. * The zx coefficients of the spherical polynomial
  20880. */
  20881. zx: Vector3;
  20882. /**
  20883. * Adds an ambient color to the spherical polynomial
  20884. * @param color the color to add
  20885. */
  20886. addAmbient(color: Color3): void;
  20887. /**
  20888. * Scales the spherical polynomial by the given amount
  20889. * @param scale the amount to scale
  20890. */
  20891. scale(scale: number): void;
  20892. /**
  20893. * Gets the spherical polynomial from harmonics
  20894. * @param harmonics the spherical harmonics
  20895. * @returns the spherical polynomial
  20896. */
  20897. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  20898. /**
  20899. * Constructs a spherical polynomial from an array.
  20900. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  20901. * @returns the spherical polynomial
  20902. */
  20903. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  20904. }
  20905. /**
  20906. * Class representing spherical harmonics coefficients to the 3rd degree
  20907. */
  20908. class SphericalHarmonics {
  20909. /**
  20910. * The l0,0 coefficients of the spherical harmonics
  20911. */
  20912. l00: Vector3;
  20913. /**
  20914. * The l1,-1 coefficients of the spherical harmonics
  20915. */
  20916. l1_1: Vector3;
  20917. /**
  20918. * The l1,0 coefficients of the spherical harmonics
  20919. */
  20920. l10: Vector3;
  20921. /**
  20922. * The l1,1 coefficients of the spherical harmonics
  20923. */
  20924. l11: Vector3;
  20925. /**
  20926. * The l2,-2 coefficients of the spherical harmonics
  20927. */
  20928. l2_2: Vector3;
  20929. /**
  20930. * The l2,-1 coefficients of the spherical harmonics
  20931. */
  20932. l2_1: Vector3;
  20933. /**
  20934. * The l2,0 coefficients of the spherical harmonics
  20935. */
  20936. l20: Vector3;
  20937. /**
  20938. * The l2,1 coefficients of the spherical harmonics
  20939. */
  20940. l21: Vector3;
  20941. /**
  20942. * The l2,2 coefficients of the spherical harmonics
  20943. */
  20944. lL22: Vector3;
  20945. /**
  20946. * Adds a light to the spherical harmonics
  20947. * @param direction the direction of the light
  20948. * @param color the color of the light
  20949. * @param deltaSolidAngle the delta solid angle of the light
  20950. */
  20951. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20952. /**
  20953. * Scales the spherical harmonics by the given amount
  20954. * @param scale the amount to scale
  20955. */
  20956. scale(scale: number): void;
  20957. /**
  20958. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20959. *
  20960. * ```
  20961. * E_lm = A_l * L_lm
  20962. * ```
  20963. *
  20964. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20965. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20966. * the scaling factors are given in equation 9.
  20967. */
  20968. convertIncidentRadianceToIrradiance(): void;
  20969. /**
  20970. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20971. *
  20972. * ```
  20973. * L = (1/pi) * E * rho
  20974. * ```
  20975. *
  20976. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20977. */
  20978. convertIrradianceToLambertianRadiance(): void;
  20979. /**
  20980. * Gets the spherical harmonics from polynomial
  20981. * @param polynomial the spherical polynomial
  20982. * @returns the spherical harmonics
  20983. */
  20984. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20985. /**
  20986. * Constructs a spherical harmonics from an array.
  20987. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20988. * @returns the spherical harmonics
  20989. */
  20990. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20991. }
  20992. }
  20993. declare module BABYLON {
  20994. /**
  20995. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20996. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20997. * 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;
  20998. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20999. */
  21000. class ColorCurves {
  21001. private _dirty;
  21002. private _tempColor;
  21003. private _globalCurve;
  21004. private _highlightsCurve;
  21005. private _midtonesCurve;
  21006. private _shadowsCurve;
  21007. private _positiveCurve;
  21008. private _negativeCurve;
  21009. private _globalHue;
  21010. private _globalDensity;
  21011. private _globalSaturation;
  21012. private _globalExposure;
  21013. /**
  21014. * Gets the global Hue value.
  21015. * 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).
  21016. */
  21017. /**
  21018. * Sets the global Hue value.
  21019. * 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).
  21020. */
  21021. globalHue: number;
  21022. /**
  21023. * Gets the global Density value.
  21024. * 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.
  21025. * Values less than zero provide a filter of opposite hue.
  21026. */
  21027. /**
  21028. * Sets the global Density value.
  21029. * 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.
  21030. * Values less than zero provide a filter of opposite hue.
  21031. */
  21032. globalDensity: number;
  21033. /**
  21034. * Gets the global Saturation value.
  21035. * 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.
  21036. */
  21037. /**
  21038. * Sets the global Saturation value.
  21039. * 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.
  21040. */
  21041. globalSaturation: number;
  21042. /**
  21043. * Gets the global Exposure value.
  21044. * 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.
  21045. */
  21046. /**
  21047. * Sets the global Exposure value.
  21048. * 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.
  21049. */
  21050. globalExposure: number;
  21051. private _highlightsHue;
  21052. private _highlightsDensity;
  21053. private _highlightsSaturation;
  21054. private _highlightsExposure;
  21055. /**
  21056. * Gets the highlights Hue value.
  21057. * 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).
  21058. */
  21059. /**
  21060. * Sets the highlights Hue value.
  21061. * 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).
  21062. */
  21063. highlightsHue: number;
  21064. /**
  21065. * Gets the highlights Density value.
  21066. * 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.
  21067. * Values less than zero provide a filter of opposite hue.
  21068. */
  21069. /**
  21070. * Sets the highlights Density value.
  21071. * 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.
  21072. * Values less than zero provide a filter of opposite hue.
  21073. */
  21074. highlightsDensity: number;
  21075. /**
  21076. * Gets the highlights Saturation value.
  21077. * 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.
  21078. */
  21079. /**
  21080. * Sets the highlights Saturation value.
  21081. * 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.
  21082. */
  21083. highlightsSaturation: number;
  21084. /**
  21085. * Gets the highlights Exposure value.
  21086. * 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.
  21087. */
  21088. /**
  21089. * Sets the highlights Exposure value.
  21090. * 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.
  21091. */
  21092. highlightsExposure: number;
  21093. private _midtonesHue;
  21094. private _midtonesDensity;
  21095. private _midtonesSaturation;
  21096. private _midtonesExposure;
  21097. /**
  21098. * Gets the midtones Hue value.
  21099. * 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).
  21100. */
  21101. /**
  21102. * Sets the midtones Hue value.
  21103. * 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).
  21104. */
  21105. midtonesHue: number;
  21106. /**
  21107. * Gets the midtones Density value.
  21108. * 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.
  21109. * Values less than zero provide a filter of opposite hue.
  21110. */
  21111. /**
  21112. * Sets the midtones Density value.
  21113. * 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.
  21114. * Values less than zero provide a filter of opposite hue.
  21115. */
  21116. midtonesDensity: number;
  21117. /**
  21118. * Gets the midtones Saturation value.
  21119. * 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.
  21120. */
  21121. /**
  21122. * Sets the midtones Saturation value.
  21123. * 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.
  21124. */
  21125. midtonesSaturation: number;
  21126. /**
  21127. * Gets the midtones Exposure value.
  21128. * 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.
  21129. */
  21130. /**
  21131. * Sets the midtones Exposure value.
  21132. * 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.
  21133. */
  21134. midtonesExposure: number;
  21135. private _shadowsHue;
  21136. private _shadowsDensity;
  21137. private _shadowsSaturation;
  21138. private _shadowsExposure;
  21139. /**
  21140. * Gets the shadows Hue value.
  21141. * 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).
  21142. */
  21143. /**
  21144. * Sets the shadows Hue value.
  21145. * 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).
  21146. */
  21147. shadowsHue: number;
  21148. /**
  21149. * Gets the shadows Density value.
  21150. * 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.
  21151. * Values less than zero provide a filter of opposite hue.
  21152. */
  21153. /**
  21154. * Sets the shadows Density value.
  21155. * 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.
  21156. * Values less than zero provide a filter of opposite hue.
  21157. */
  21158. shadowsDensity: number;
  21159. /**
  21160. * Gets the shadows Saturation value.
  21161. * 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.
  21162. */
  21163. /**
  21164. * Sets the shadows Saturation value.
  21165. * 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.
  21166. */
  21167. shadowsSaturation: number;
  21168. /**
  21169. * Gets the shadows Exposure value.
  21170. * 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.
  21171. */
  21172. /**
  21173. * Sets the shadows Exposure value.
  21174. * 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.
  21175. */
  21176. shadowsExposure: number;
  21177. /**
  21178. * Returns the class name
  21179. * @returns The class name
  21180. */
  21181. getClassName(): string;
  21182. /**
  21183. * Binds the color curves to the shader.
  21184. * @param colorCurves The color curve to bind
  21185. * @param effect The effect to bind to
  21186. * @param positiveUniform The positive uniform shader parameter
  21187. * @param neutralUniform The neutral uniform shader parameter
  21188. * @param negativeUniform The negative uniform shader parameter
  21189. */
  21190. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  21191. /**
  21192. * Prepare the list of uniforms associated with the ColorCurves effects.
  21193. * @param uniformsList The list of uniforms used in the effect
  21194. */
  21195. static PrepareUniforms(uniformsList: string[]): void;
  21196. /**
  21197. * Returns color grading data based on a hue, density, saturation and exposure value.
  21198. * @param filterHue The hue of the color filter.
  21199. * @param filterDensity The density of the color filter.
  21200. * @param saturation The saturation.
  21201. * @param exposure The exposure.
  21202. * @param result The result data container.
  21203. */
  21204. private getColorGradingDataToRef;
  21205. /**
  21206. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  21207. * @param value The input slider value in range [-100,100].
  21208. * @returns Adjusted value.
  21209. */
  21210. private static applyColorGradingSliderNonlinear;
  21211. /**
  21212. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  21213. * @param hue The hue (H) input.
  21214. * @param saturation The saturation (S) input.
  21215. * @param brightness The brightness (B) input.
  21216. * @result An RGBA color represented as Vector4.
  21217. */
  21218. private static fromHSBToRef;
  21219. /**
  21220. * Returns a value clamped between min and max
  21221. * @param value The value to clamp
  21222. * @param min The minimum of value
  21223. * @param max The maximum of value
  21224. * @returns The clamped value.
  21225. */
  21226. private static clamp;
  21227. /**
  21228. * Clones the current color curve instance.
  21229. * @return The cloned curves
  21230. */
  21231. clone(): ColorCurves;
  21232. /**
  21233. * Serializes the current color curve instance to a json representation.
  21234. * @return a JSON representation
  21235. */
  21236. serialize(): any;
  21237. /**
  21238. * Parses the color curve from a json representation.
  21239. * @param source the JSON source to parse
  21240. * @return The parsed curves
  21241. */
  21242. static Parse(source: any): ColorCurves;
  21243. }
  21244. }
  21245. declare module BABYLON {
  21246. /**
  21247. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  21248. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  21249. */
  21250. class EffectFallbacks {
  21251. private _defines;
  21252. private _currentRank;
  21253. private _maxRank;
  21254. private _mesh;
  21255. /**
  21256. * Removes the fallback from the bound mesh.
  21257. */
  21258. unBindMesh(): void;
  21259. /**
  21260. * Adds a fallback on the specified property.
  21261. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  21262. * @param define The name of the define in the shader
  21263. */
  21264. addFallback(rank: number, define: string): void;
  21265. /**
  21266. * Sets the mesh to use CPU skinning when needing to fallback.
  21267. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  21268. * @param mesh The mesh to use the fallbacks.
  21269. */
  21270. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  21271. /**
  21272. * Checks to see if more fallbacks are still availible.
  21273. */
  21274. readonly isMoreFallbacks: boolean;
  21275. /**
  21276. * Removes the defines that shoould be removed when falling back.
  21277. * @param currentDefines defines the current define statements for the shader.
  21278. * @param effect defines the current effect we try to compile
  21279. * @returns The resulting defines with defines of the current rank removed.
  21280. */
  21281. reduce(currentDefines: string, effect: Effect): string;
  21282. }
  21283. /**
  21284. * Options to be used when creating an effect.
  21285. */
  21286. class EffectCreationOptions {
  21287. /**
  21288. * Atrributes that will be used in the shader.
  21289. */
  21290. attributes: string[];
  21291. /**
  21292. * Uniform varible names that will be set in the shader.
  21293. */
  21294. uniformsNames: string[];
  21295. /**
  21296. * Uniform buffer varible names that will be set in the shader.
  21297. */
  21298. uniformBuffersNames: string[];
  21299. /**
  21300. * Sampler texture variable names that will be set in the shader.
  21301. */
  21302. samplers: string[];
  21303. /**
  21304. * Define statements that will be set in the shader.
  21305. */
  21306. defines: any;
  21307. /**
  21308. * Possible fallbacks for this effect to improve performance when needed.
  21309. */
  21310. fallbacks: Nullable<EffectFallbacks>;
  21311. /**
  21312. * Callback that will be called when the shader is compiled.
  21313. */
  21314. onCompiled: Nullable<(effect: Effect) => void>;
  21315. /**
  21316. * Callback that will be called if an error occurs during shader compilation.
  21317. */
  21318. onError: Nullable<(effect: Effect, errors: string) => void>;
  21319. /**
  21320. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  21321. */
  21322. indexParameters: any;
  21323. /**
  21324. * Max number of lights that can be used in the shader.
  21325. */
  21326. maxSimultaneousLights: number;
  21327. /**
  21328. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  21329. */
  21330. transformFeedbackVaryings: Nullable<string[]>;
  21331. }
  21332. /**
  21333. * Effect containing vertex and fragment shader that can be executed on an object.
  21334. */
  21335. class Effect {
  21336. /**
  21337. * Name of the effect.
  21338. */
  21339. name: any;
  21340. /**
  21341. * String container all the define statements that should be set on the shader.
  21342. */
  21343. defines: string;
  21344. /**
  21345. * Callback that will be called when the shader is compiled.
  21346. */
  21347. onCompiled: Nullable<(effect: Effect) => void>;
  21348. /**
  21349. * Callback that will be called if an error occurs during shader compilation.
  21350. */
  21351. onError: Nullable<(effect: Effect, errors: string) => void>;
  21352. /**
  21353. * Callback that will be called when effect is bound.
  21354. */
  21355. onBind: Nullable<(effect: Effect) => void>;
  21356. /**
  21357. * Unique ID of the effect.
  21358. */
  21359. uniqueId: number;
  21360. /**
  21361. * Observable that will be called when the shader is compiled.
  21362. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  21363. */
  21364. onCompileObservable: Observable<Effect>;
  21365. /**
  21366. * Observable that will be called if an error occurs during shader compilation.
  21367. */
  21368. onErrorObservable: Observable<Effect>;
  21369. /** @hidden */
  21370. _onBindObservable: Nullable<Observable<Effect>>;
  21371. /**
  21372. * Observable that will be called when effect is bound.
  21373. */
  21374. readonly onBindObservable: Observable<Effect>;
  21375. /** @hidden */
  21376. _bonesComputationForcedToCPU: boolean;
  21377. private static _uniqueIdSeed;
  21378. private _engine;
  21379. private _uniformBuffersNames;
  21380. private _uniformsNames;
  21381. private _samplers;
  21382. private _isReady;
  21383. private _compilationError;
  21384. private _attributesNames;
  21385. private _attributes;
  21386. private _uniforms;
  21387. /**
  21388. * Key for the effect.
  21389. * @hidden
  21390. */
  21391. _key: string;
  21392. private _indexParameters;
  21393. private _fallbacks;
  21394. private _vertexSourceCode;
  21395. private _fragmentSourceCode;
  21396. private _vertexSourceCodeOverride;
  21397. private _fragmentSourceCodeOverride;
  21398. private _transformFeedbackVaryings;
  21399. /**
  21400. * Compiled shader to webGL program.
  21401. * @hidden
  21402. */
  21403. _program: WebGLProgram;
  21404. private _valueCache;
  21405. private static _baseCache;
  21406. /**
  21407. * Instantiates an effect.
  21408. * An effect can be used to create/manage/execute vertex and fragment shaders.
  21409. * @param baseName Name of the effect.
  21410. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  21411. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  21412. * @param samplers List of sampler variables that will be passed to the shader.
  21413. * @param engine Engine to be used to render the effect
  21414. * @param defines Define statements to be added to the shader.
  21415. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  21416. * @param onCompiled Callback that will be called when the shader is compiled.
  21417. * @param onError Callback that will be called if an error occurs during shader compilation.
  21418. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  21419. */
  21420. 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);
  21421. /**
  21422. * Unique key for this effect
  21423. */
  21424. readonly key: string;
  21425. /**
  21426. * If the effect has been compiled and prepared.
  21427. * @returns if the effect is compiled and prepared.
  21428. */
  21429. isReady(): boolean;
  21430. /**
  21431. * The engine the effect was initialized with.
  21432. * @returns the engine.
  21433. */
  21434. getEngine(): Engine;
  21435. /**
  21436. * The compiled webGL program for the effect
  21437. * @returns the webGL program.
  21438. */
  21439. getProgram(): WebGLProgram;
  21440. /**
  21441. * The set of names of attribute variables for the shader.
  21442. * @returns An array of attribute names.
  21443. */
  21444. getAttributesNames(): string[];
  21445. /**
  21446. * Returns the attribute at the given index.
  21447. * @param index The index of the attribute.
  21448. * @returns The location of the attribute.
  21449. */
  21450. getAttributeLocation(index: number): number;
  21451. /**
  21452. * Returns the attribute based on the name of the variable.
  21453. * @param name of the attribute to look up.
  21454. * @returns the attribute location.
  21455. */
  21456. getAttributeLocationByName(name: string): number;
  21457. /**
  21458. * The number of attributes.
  21459. * @returns the numnber of attributes.
  21460. */
  21461. getAttributesCount(): number;
  21462. /**
  21463. * Gets the index of a uniform variable.
  21464. * @param uniformName of the uniform to look up.
  21465. * @returns the index.
  21466. */
  21467. getUniformIndex(uniformName: string): number;
  21468. /**
  21469. * Returns the attribute based on the name of the variable.
  21470. * @param uniformName of the uniform to look up.
  21471. * @returns the location of the uniform.
  21472. */
  21473. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  21474. /**
  21475. * Returns an array of sampler variable names
  21476. * @returns The array of sampler variable neames.
  21477. */
  21478. getSamplers(): string[];
  21479. /**
  21480. * The error from the last compilation.
  21481. * @returns the error string.
  21482. */
  21483. getCompilationError(): string;
  21484. /**
  21485. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  21486. * @param func The callback to be used.
  21487. */
  21488. executeWhenCompiled(func: (effect: Effect) => void): void;
  21489. private _checkIsReady;
  21490. /** @hidden */
  21491. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  21492. /** @hidden */
  21493. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  21494. /** @hidden */
  21495. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  21496. private _processShaderConversion;
  21497. private _processIncludes;
  21498. private _processPrecision;
  21499. /**
  21500. * Recompiles the webGL program
  21501. * @param vertexSourceCode The source code for the vertex shader.
  21502. * @param fragmentSourceCode The source code for the fragment shader.
  21503. * @param onCompiled Callback called when completed.
  21504. * @param onError Callback called on error.
  21505. * @hidden
  21506. */
  21507. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  21508. /**
  21509. * Gets the uniform locations of the the specified variable names
  21510. * @param names THe names of the variables to lookup.
  21511. * @returns Array of locations in the same order as variable names.
  21512. */
  21513. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  21514. /**
  21515. * Prepares the effect
  21516. * @hidden
  21517. */
  21518. _prepareEffect(): void;
  21519. /**
  21520. * Checks if the effect is supported. (Must be called after compilation)
  21521. */
  21522. readonly isSupported: boolean;
  21523. /**
  21524. * Binds a texture to the engine to be used as output of the shader.
  21525. * @param channel Name of the output variable.
  21526. * @param texture Texture to bind.
  21527. * @hidden
  21528. */
  21529. _bindTexture(channel: string, texture: InternalTexture): void;
  21530. /**
  21531. * Sets a texture on the engine to be used in the shader.
  21532. * @param channel Name of the sampler variable.
  21533. * @param texture Texture to set.
  21534. */
  21535. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  21536. /**
  21537. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  21538. * @param channel Name of the sampler variable.
  21539. * @param texture Texture to set.
  21540. */
  21541. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  21542. /**
  21543. * Sets an array of textures on the engine to be used in the shader.
  21544. * @param channel Name of the variable.
  21545. * @param textures Textures to set.
  21546. */
  21547. setTextureArray(channel: string, textures: BaseTexture[]): void;
  21548. /**
  21549. * 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)
  21550. * @param channel Name of the sampler variable.
  21551. * @param postProcess Post process to get the input texture from.
  21552. */
  21553. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  21554. /**
  21555. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  21556. * 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)
  21557. * @param channel Name of the sampler variable.
  21558. * @param postProcess Post process to get the output texture from.
  21559. */
  21560. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  21561. /** @hidden */
  21562. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  21563. /** @hidden */
  21564. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  21565. /** @hidden */
  21566. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  21567. /** @hidden */
  21568. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  21569. /**
  21570. * Binds a buffer to a uniform.
  21571. * @param buffer Buffer to bind.
  21572. * @param name Name of the uniform variable to bind to.
  21573. */
  21574. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  21575. /**
  21576. * Binds block to a uniform.
  21577. * @param blockName Name of the block to bind.
  21578. * @param index Index to bind.
  21579. */
  21580. bindUniformBlock(blockName: string, index: number): void;
  21581. /**
  21582. * Sets an interger value on a uniform variable.
  21583. * @param uniformName Name of the variable.
  21584. * @param value Value to be set.
  21585. * @returns this effect.
  21586. */
  21587. setInt(uniformName: string, value: number): Effect;
  21588. /**
  21589. * Sets an int array on a uniform variable.
  21590. * @param uniformName Name of the variable.
  21591. * @param array array to be set.
  21592. * @returns this effect.
  21593. */
  21594. setIntArray(uniformName: string, array: Int32Array): Effect;
  21595. /**
  21596. * 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)
  21597. * @param uniformName Name of the variable.
  21598. * @param array array to be set.
  21599. * @returns this effect.
  21600. */
  21601. setIntArray2(uniformName: string, array: Int32Array): Effect;
  21602. /**
  21603. * 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)
  21604. * @param uniformName Name of the variable.
  21605. * @param array array to be set.
  21606. * @returns this effect.
  21607. */
  21608. setIntArray3(uniformName: string, array: Int32Array): Effect;
  21609. /**
  21610. * 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)
  21611. * @param uniformName Name of the variable.
  21612. * @param array array to be set.
  21613. * @returns this effect.
  21614. */
  21615. setIntArray4(uniformName: string, array: Int32Array): Effect;
  21616. /**
  21617. * Sets an float array on a uniform variable.
  21618. * @param uniformName Name of the variable.
  21619. * @param array array to be set.
  21620. * @returns this effect.
  21621. */
  21622. setFloatArray(uniformName: string, array: Float32Array): Effect;
  21623. /**
  21624. * 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)
  21625. * @param uniformName Name of the variable.
  21626. * @param array array to be set.
  21627. * @returns this effect.
  21628. */
  21629. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  21630. /**
  21631. * 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)
  21632. * @param uniformName Name of the variable.
  21633. * @param array array to be set.
  21634. * @returns this effect.
  21635. */
  21636. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  21637. /**
  21638. * 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)
  21639. * @param uniformName Name of the variable.
  21640. * @param array array to be set.
  21641. * @returns this effect.
  21642. */
  21643. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  21644. /**
  21645. * Sets an array on a uniform variable.
  21646. * @param uniformName Name of the variable.
  21647. * @param array array to be set.
  21648. * @returns this effect.
  21649. */
  21650. setArray(uniformName: string, array: number[]): Effect;
  21651. /**
  21652. * 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)
  21653. * @param uniformName Name of the variable.
  21654. * @param array array to be set.
  21655. * @returns this effect.
  21656. */
  21657. setArray2(uniformName: string, array: number[]): Effect;
  21658. /**
  21659. * 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)
  21660. * @param uniformName Name of the variable.
  21661. * @param array array to be set.
  21662. * @returns this effect.
  21663. */
  21664. setArray3(uniformName: string, array: number[]): Effect;
  21665. /**
  21666. * 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)
  21667. * @param uniformName Name of the variable.
  21668. * @param array array to be set.
  21669. * @returns this effect.
  21670. */
  21671. setArray4(uniformName: string, array: number[]): Effect;
  21672. /**
  21673. * Sets matrices on a uniform variable.
  21674. * @param uniformName Name of the variable.
  21675. * @param matrices matrices to be set.
  21676. * @returns this effect.
  21677. */
  21678. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  21679. /**
  21680. * Sets matrix on a uniform variable.
  21681. * @param uniformName Name of the variable.
  21682. * @param matrix matrix to be set.
  21683. * @returns this effect.
  21684. */
  21685. setMatrix(uniformName: string, matrix: Matrix): Effect;
  21686. /**
  21687. * 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)
  21688. * @param uniformName Name of the variable.
  21689. * @param matrix matrix to be set.
  21690. * @returns this effect.
  21691. */
  21692. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  21693. /**
  21694. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  21695. * @param uniformName Name of the variable.
  21696. * @param matrix matrix to be set.
  21697. * @returns this effect.
  21698. */
  21699. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  21700. /**
  21701. * Sets a float on a uniform variable.
  21702. * @param uniformName Name of the variable.
  21703. * @param value value to be set.
  21704. * @returns this effect.
  21705. */
  21706. setFloat(uniformName: string, value: number): Effect;
  21707. /**
  21708. * Sets a boolean on a uniform variable.
  21709. * @param uniformName Name of the variable.
  21710. * @param bool value to be set.
  21711. * @returns this effect.
  21712. */
  21713. setBool(uniformName: string, bool: boolean): Effect;
  21714. /**
  21715. * Sets a Vector2 on a uniform variable.
  21716. * @param uniformName Name of the variable.
  21717. * @param vector2 vector2 to be set.
  21718. * @returns this effect.
  21719. */
  21720. setVector2(uniformName: string, vector2: Vector2): Effect;
  21721. /**
  21722. * Sets a float2 on a uniform variable.
  21723. * @param uniformName Name of the variable.
  21724. * @param x First float in float2.
  21725. * @param y Second float in float2.
  21726. * @returns this effect.
  21727. */
  21728. setFloat2(uniformName: string, x: number, y: number): Effect;
  21729. /**
  21730. * Sets a Vector3 on a uniform variable.
  21731. * @param uniformName Name of the variable.
  21732. * @param vector3 Value to be set.
  21733. * @returns this effect.
  21734. */
  21735. setVector3(uniformName: string, vector3: Vector3): Effect;
  21736. /**
  21737. * Sets a float3 on a uniform variable.
  21738. * @param uniformName Name of the variable.
  21739. * @param x First float in float3.
  21740. * @param y Second float in float3.
  21741. * @param z Third float in float3.
  21742. * @returns this effect.
  21743. */
  21744. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  21745. /**
  21746. * Sets a Vector4 on a uniform variable.
  21747. * @param uniformName Name of the variable.
  21748. * @param vector4 Value to be set.
  21749. * @returns this effect.
  21750. */
  21751. setVector4(uniformName: string, vector4: Vector4): Effect;
  21752. /**
  21753. * Sets a float4 on a uniform variable.
  21754. * @param uniformName Name of the variable.
  21755. * @param x First float in float4.
  21756. * @param y Second float in float4.
  21757. * @param z Third float in float4.
  21758. * @param w Fourth float in float4.
  21759. * @returns this effect.
  21760. */
  21761. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  21762. /**
  21763. * Sets a Color3 on a uniform variable.
  21764. * @param uniformName Name of the variable.
  21765. * @param color3 Value to be set.
  21766. * @returns this effect.
  21767. */
  21768. setColor3(uniformName: string, color3: Color3): Effect;
  21769. /**
  21770. * Sets a Color4 on a uniform variable.
  21771. * @param uniformName Name of the variable.
  21772. * @param color3 Value to be set.
  21773. * @param alpha Alpha value to be set.
  21774. * @returns this effect.
  21775. */
  21776. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  21777. /**
  21778. * Sets a Color4 on a uniform variable
  21779. * @param uniformName defines the name of the variable
  21780. * @param color4 defines the value to be set
  21781. * @returns this effect.
  21782. */
  21783. setDirectColor4(uniformName: string, color4: Color4): Effect;
  21784. /**
  21785. * This function will add a new shader to the shader store
  21786. * @param name the name of the shader
  21787. * @param pixelShader optional pixel shader content
  21788. * @param vertexShader optional vertex shader content
  21789. */
  21790. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  21791. /**
  21792. * Store of each shader (The can be looked up using effect.key)
  21793. */
  21794. static ShadersStore: {
  21795. [key: string]: string;
  21796. };
  21797. /**
  21798. * Store of each included file for a shader (The can be looked up using effect.key)
  21799. */
  21800. static IncludesShadersStore: {
  21801. [key: string]: string;
  21802. };
  21803. /**
  21804. * Resets the cache of effects.
  21805. */
  21806. static ResetCache(): void;
  21807. }
  21808. }
  21809. declare module BABYLON {
  21810. /**
  21811. * This represents all the required information to add a fresnel effect on a material:
  21812. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  21813. */
  21814. class FresnelParameters {
  21815. private _isEnabled;
  21816. /**
  21817. * Define if the fresnel effect is enable or not.
  21818. */
  21819. isEnabled: boolean;
  21820. /**
  21821. * Define the color used on edges (grazing angle)
  21822. */
  21823. leftColor: Color3;
  21824. /**
  21825. * Define the color used on center
  21826. */
  21827. rightColor: Color3;
  21828. /**
  21829. * Define bias applied to computed fresnel term
  21830. */
  21831. bias: number;
  21832. /**
  21833. * Defined the power exponent applied to fresnel term
  21834. */
  21835. power: number;
  21836. /**
  21837. * Clones the current fresnel and its valuues
  21838. * @returns a clone fresnel configuration
  21839. */
  21840. clone(): FresnelParameters;
  21841. /**
  21842. * Serializes the current fresnel parameters to a JSON representation.
  21843. * @return the JSON serialization
  21844. */
  21845. serialize(): any;
  21846. /**
  21847. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  21848. * @param parsedFresnelParameters Define the JSON representation
  21849. * @returns the parsed parameters
  21850. */
  21851. static Parse(parsedFresnelParameters: any): FresnelParameters;
  21852. }
  21853. }
  21854. declare module BABYLON {
  21855. /**
  21856. * Interface to follow in your material defines to integrate easily the
  21857. * Image proccessing functions.
  21858. * @hidden
  21859. */
  21860. interface IImageProcessingConfigurationDefines {
  21861. IMAGEPROCESSING: boolean;
  21862. VIGNETTE: boolean;
  21863. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21864. VIGNETTEBLENDMODEOPAQUE: boolean;
  21865. TONEMAPPING: boolean;
  21866. TONEMAPPING_ACES: boolean;
  21867. CONTRAST: boolean;
  21868. EXPOSURE: boolean;
  21869. COLORCURVES: boolean;
  21870. COLORGRADING: boolean;
  21871. COLORGRADING3D: boolean;
  21872. SAMPLER3DGREENDEPTH: boolean;
  21873. SAMPLER3DBGRMAP: boolean;
  21874. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21875. }
  21876. /**
  21877. * @hidden
  21878. */
  21879. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21880. IMAGEPROCESSING: boolean;
  21881. VIGNETTE: boolean;
  21882. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21883. VIGNETTEBLENDMODEOPAQUE: boolean;
  21884. TONEMAPPING: boolean;
  21885. TONEMAPPING_ACES: boolean;
  21886. CONTRAST: boolean;
  21887. COLORCURVES: boolean;
  21888. COLORGRADING: boolean;
  21889. COLORGRADING3D: boolean;
  21890. SAMPLER3DGREENDEPTH: boolean;
  21891. SAMPLER3DBGRMAP: boolean;
  21892. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21893. EXPOSURE: boolean;
  21894. constructor();
  21895. }
  21896. /**
  21897. * This groups together the common properties used for image processing either in direct forward pass
  21898. * or through post processing effect depending on the use of the image processing pipeline in your scene
  21899. * or not.
  21900. */
  21901. class ImageProcessingConfiguration {
  21902. /**
  21903. * Default tone mapping applied in BabylonJS.
  21904. */
  21905. static readonly TONEMAPPING_STANDARD: number;
  21906. /**
  21907. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  21908. * to other engines rendering to increase portability.
  21909. */
  21910. static readonly TONEMAPPING_ACES: number;
  21911. /**
  21912. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  21913. */
  21914. colorCurves: Nullable<ColorCurves>;
  21915. private _colorCurvesEnabled;
  21916. /**
  21917. * Gets wether the color curves effect is enabled.
  21918. */
  21919. /**
  21920. * Sets wether the color curves effect is enabled.
  21921. */
  21922. colorCurvesEnabled: boolean;
  21923. private _colorGradingTexture;
  21924. /**
  21925. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  21926. */
  21927. /**
  21928. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  21929. */
  21930. colorGradingTexture: Nullable<BaseTexture>;
  21931. private _colorGradingEnabled;
  21932. /**
  21933. * Gets wether the color grading effect is enabled.
  21934. */
  21935. /**
  21936. * Sets wether the color grading effect is enabled.
  21937. */
  21938. colorGradingEnabled: boolean;
  21939. private _colorGradingWithGreenDepth;
  21940. /**
  21941. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  21942. */
  21943. /**
  21944. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  21945. */
  21946. colorGradingWithGreenDepth: boolean;
  21947. private _colorGradingBGR;
  21948. /**
  21949. * Gets wether the color grading texture contains BGR values.
  21950. */
  21951. /**
  21952. * Sets wether the color grading texture contains BGR values.
  21953. */
  21954. colorGradingBGR: boolean;
  21955. /** @hidden */
  21956. _exposure: number;
  21957. /**
  21958. * Gets the Exposure used in the effect.
  21959. */
  21960. /**
  21961. * Sets the Exposure used in the effect.
  21962. */
  21963. exposure: number;
  21964. private _toneMappingEnabled;
  21965. /**
  21966. * Gets wether the tone mapping effect is enabled.
  21967. */
  21968. /**
  21969. * Sets wether the tone mapping effect is enabled.
  21970. */
  21971. toneMappingEnabled: boolean;
  21972. private _toneMappingType;
  21973. /**
  21974. * Gets the type of tone mapping effect.
  21975. */
  21976. /**
  21977. * Sets the type of tone mapping effect used in BabylonJS.
  21978. */
  21979. toneMappingType: number;
  21980. protected _contrast: number;
  21981. /**
  21982. * Gets the contrast used in the effect.
  21983. */
  21984. /**
  21985. * Sets the contrast used in the effect.
  21986. */
  21987. contrast: number;
  21988. /**
  21989. * Vignette stretch size.
  21990. */
  21991. vignetteStretch: number;
  21992. /**
  21993. * Vignette centre X Offset.
  21994. */
  21995. vignetteCentreX: number;
  21996. /**
  21997. * Vignette centre Y Offset.
  21998. */
  21999. vignetteCentreY: number;
  22000. /**
  22001. * Vignette weight or intensity of the vignette effect.
  22002. */
  22003. vignetteWeight: number;
  22004. /**
  22005. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  22006. * if vignetteEnabled is set to true.
  22007. */
  22008. vignetteColor: Color4;
  22009. /**
  22010. * Camera field of view used by the Vignette effect.
  22011. */
  22012. vignetteCameraFov: number;
  22013. private _vignetteBlendMode;
  22014. /**
  22015. * Gets the vignette blend mode allowing different kind of effect.
  22016. */
  22017. /**
  22018. * Sets the vignette blend mode allowing different kind of effect.
  22019. */
  22020. vignetteBlendMode: number;
  22021. private _vignetteEnabled;
  22022. /**
  22023. * Gets wether the vignette effect is enabled.
  22024. */
  22025. /**
  22026. * Sets wether the vignette effect is enabled.
  22027. */
  22028. vignetteEnabled: boolean;
  22029. private _applyByPostProcess;
  22030. /**
  22031. * Gets wether the image processing is applied through a post process or not.
  22032. */
  22033. /**
  22034. * Sets wether the image processing is applied through a post process or not.
  22035. */
  22036. applyByPostProcess: boolean;
  22037. private _isEnabled;
  22038. /**
  22039. * Gets wether the image processing is enabled or not.
  22040. */
  22041. /**
  22042. * Sets wether the image processing is enabled or not.
  22043. */
  22044. isEnabled: boolean;
  22045. /**
  22046. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  22047. */
  22048. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  22049. /**
  22050. * Method called each time the image processing information changes requires to recompile the effect.
  22051. */
  22052. protected _updateParameters(): void;
  22053. /**
  22054. * Gets the current class name.
  22055. * @return "ImageProcessingConfiguration"
  22056. */
  22057. getClassName(): string;
  22058. /**
  22059. * Prepare the list of uniforms associated with the Image Processing effects.
  22060. * @param uniforms The list of uniforms used in the effect
  22061. * @param defines the list of defines currently in use
  22062. */
  22063. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  22064. /**
  22065. * Prepare the list of samplers associated with the Image Processing effects.
  22066. * @param samplersList The list of uniforms used in the effect
  22067. * @param defines the list of defines currently in use
  22068. */
  22069. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  22070. /**
  22071. * Prepare the list of defines associated to the shader.
  22072. * @param defines the list of defines to complete
  22073. * @param forPostProcess Define if we are currently in post process mode or not
  22074. */
  22075. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  22076. /**
  22077. * Returns true if all the image processing information are ready.
  22078. * @returns True if ready, otherwise, false
  22079. */
  22080. isReady(): boolean;
  22081. /**
  22082. * Binds the image processing to the shader.
  22083. * @param effect The effect to bind to
  22084. * @param aspectRatio Define the current aspect ratio of the effect
  22085. */
  22086. bind(effect: Effect, aspectRatio?: number): void;
  22087. /**
  22088. * Clones the current image processing instance.
  22089. * @return The cloned image processing
  22090. */
  22091. clone(): ImageProcessingConfiguration;
  22092. /**
  22093. * Serializes the current image processing instance to a json representation.
  22094. * @return a JSON representation
  22095. */
  22096. serialize(): any;
  22097. /**
  22098. * Parses the image processing from a json representation.
  22099. * @param source the JSON source to parse
  22100. * @return The parsed image processing
  22101. */
  22102. static Parse(source: any): ImageProcessingConfiguration;
  22103. private static _VIGNETTEMODE_MULTIPLY;
  22104. private static _VIGNETTEMODE_OPAQUE;
  22105. /**
  22106. * Used to apply the vignette as a mix with the pixel color.
  22107. */
  22108. static readonly VIGNETTEMODE_MULTIPLY: number;
  22109. /**
  22110. * Used to apply the vignette as a replacement of the pixel color.
  22111. */
  22112. static readonly VIGNETTEMODE_OPAQUE: number;
  22113. }
  22114. }
  22115. declare module BABYLON {
  22116. /**
  22117. * Manages the defines for the Material
  22118. */
  22119. class MaterialDefines {
  22120. private _keys;
  22121. private _isDirty;
  22122. /** @hidden */
  22123. _renderId: number;
  22124. /** @hidden */
  22125. _areLightsDirty: boolean;
  22126. /** @hidden */
  22127. _areAttributesDirty: boolean;
  22128. /** @hidden */
  22129. _areTexturesDirty: boolean;
  22130. /** @hidden */
  22131. _areFresnelDirty: boolean;
  22132. /** @hidden */
  22133. _areMiscDirty: boolean;
  22134. /** @hidden */
  22135. _areImageProcessingDirty: boolean;
  22136. /** @hidden */
  22137. _normals: boolean;
  22138. /** @hidden */
  22139. _uvs: boolean;
  22140. /** @hidden */
  22141. _needNormals: boolean;
  22142. /** @hidden */
  22143. _needUVs: boolean;
  22144. /**
  22145. * Specifies if the material needs to be re-calculated
  22146. */
  22147. readonly isDirty: boolean;
  22148. /**
  22149. * Marks the material to indicate that it has been re-calculated
  22150. */
  22151. markAsProcessed(): void;
  22152. /**
  22153. * Marks the material to indicate that it needs to be re-calculated
  22154. */
  22155. markAsUnprocessed(): void;
  22156. /**
  22157. * Marks the material to indicate all of its defines need to be re-calculated
  22158. */
  22159. markAllAsDirty(): void;
  22160. /**
  22161. * Marks the material to indicate that image processing needs to be re-calculated
  22162. */
  22163. markAsImageProcessingDirty(): void;
  22164. /**
  22165. * Marks the material to indicate the lights need to be re-calculated
  22166. */
  22167. markAsLightDirty(): void;
  22168. /**
  22169. * Marks the attribute state as changed
  22170. */
  22171. markAsAttributesDirty(): void;
  22172. /**
  22173. * Marks the texture state as changed
  22174. */
  22175. markAsTexturesDirty(): void;
  22176. /**
  22177. * Marks the fresnel state as changed
  22178. */
  22179. markAsFresnelDirty(): void;
  22180. /**
  22181. * Marks the misc state as changed
  22182. */
  22183. markAsMiscDirty(): void;
  22184. /**
  22185. * Rebuilds the material defines
  22186. */
  22187. rebuild(): void;
  22188. /**
  22189. * Specifies if two material defines are equal
  22190. * @param other - A material define instance to compare to
  22191. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  22192. */
  22193. isEqual(other: MaterialDefines): boolean;
  22194. /**
  22195. * Clones this instance's defines to another instance
  22196. * @param other - material defines to clone values to
  22197. */
  22198. cloneTo(other: MaterialDefines): void;
  22199. /**
  22200. * Resets the material define values
  22201. */
  22202. reset(): void;
  22203. /**
  22204. * Converts the material define values to a string
  22205. * @returns - String of material define information
  22206. */
  22207. toString(): string;
  22208. }
  22209. /**
  22210. * Base class for the main features of a material in Babylon.js
  22211. */
  22212. class Material implements IAnimatable {
  22213. private static _TriangleFillMode;
  22214. private static _WireFrameFillMode;
  22215. private static _PointFillMode;
  22216. private static _PointListDrawMode;
  22217. private static _LineListDrawMode;
  22218. private static _LineLoopDrawMode;
  22219. private static _LineStripDrawMode;
  22220. private static _TriangleStripDrawMode;
  22221. private static _TriangleFanDrawMode;
  22222. /**
  22223. * Returns the triangle fill mode
  22224. */
  22225. static readonly TriangleFillMode: number;
  22226. /**
  22227. * Returns the wireframe mode
  22228. */
  22229. static readonly WireFrameFillMode: number;
  22230. /**
  22231. * Returns the point fill mode
  22232. */
  22233. static readonly PointFillMode: number;
  22234. /**
  22235. * Returns the point list draw mode
  22236. */
  22237. static readonly PointListDrawMode: number;
  22238. /**
  22239. * Returns the line list draw mode
  22240. */
  22241. static readonly LineListDrawMode: number;
  22242. /**
  22243. * Returns the line loop draw mode
  22244. */
  22245. static readonly LineLoopDrawMode: number;
  22246. /**
  22247. * Returns the line strip draw mode
  22248. */
  22249. static readonly LineStripDrawMode: number;
  22250. /**
  22251. * Returns the triangle strip draw mode
  22252. */
  22253. static readonly TriangleStripDrawMode: number;
  22254. /**
  22255. * Returns the triangle fan draw mode
  22256. */
  22257. static readonly TriangleFanDrawMode: number;
  22258. /**
  22259. * Stores the clock-wise side orientation
  22260. */
  22261. private static _ClockWiseSideOrientation;
  22262. /**
  22263. * Stores the counter clock-wise side orientation
  22264. */
  22265. private static _CounterClockWiseSideOrientation;
  22266. /**
  22267. * Returns the clock-wise side orientation
  22268. */
  22269. static readonly ClockWiseSideOrientation: number;
  22270. /**
  22271. * Returns the counter clock-wise side orientation
  22272. */
  22273. static readonly CounterClockWiseSideOrientation: number;
  22274. /**
  22275. * The dirty texture flag value
  22276. */
  22277. static readonly TextureDirtyFlag: number;
  22278. /**
  22279. * The dirty light flag value
  22280. */
  22281. static readonly LightDirtyFlag: number;
  22282. /**
  22283. * The dirty fresnel flag value
  22284. */
  22285. static readonly FresnelDirtyFlag: number;
  22286. /**
  22287. * The dirty attribute flag value
  22288. */
  22289. static readonly AttributesDirtyFlag: number;
  22290. /**
  22291. * The dirty misc flag value
  22292. */
  22293. static readonly MiscDirtyFlag: number;
  22294. /**
  22295. * The all dirty flag value
  22296. */
  22297. static readonly AllDirtyFlag: number;
  22298. /**
  22299. * The ID of the material
  22300. */
  22301. id: string;
  22302. /**
  22303. * Gets or sets the unique id of the material
  22304. */
  22305. uniqueId: number;
  22306. /**
  22307. * The name of the material
  22308. */
  22309. name: string;
  22310. /**
  22311. * Gets or sets user defined metadata
  22312. */
  22313. metadata: any;
  22314. /**
  22315. * Specifies if the ready state should be checked on each call
  22316. */
  22317. checkReadyOnEveryCall: boolean;
  22318. /**
  22319. * Specifies if the ready state should be checked once
  22320. */
  22321. checkReadyOnlyOnce: boolean;
  22322. /**
  22323. * The state of the material
  22324. */
  22325. state: string;
  22326. /**
  22327. * The alpha value of the material
  22328. */
  22329. protected _alpha: number;
  22330. /**
  22331. * Sets the alpha value of the material
  22332. */
  22333. /**
  22334. * Gets the alpha value of the material
  22335. */
  22336. alpha: number;
  22337. /**
  22338. * Specifies if back face culling is enabled
  22339. */
  22340. protected _backFaceCulling: boolean;
  22341. /**
  22342. * Sets the back-face culling state
  22343. */
  22344. /**
  22345. * Gets the back-face culling state
  22346. */
  22347. backFaceCulling: boolean;
  22348. /**
  22349. * Stores the value for side orientation
  22350. */
  22351. sideOrientation: number;
  22352. /**
  22353. * Callback triggered when the material is compiled
  22354. */
  22355. onCompiled: (effect: Effect) => void;
  22356. /**
  22357. * Callback triggered when an error occurs
  22358. */
  22359. onError: (effect: Effect, errors: string) => void;
  22360. /**
  22361. * Callback triggered to get the render target textures
  22362. */
  22363. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22364. /**
  22365. * Gets a boolean indicating that current material needs to register RTT
  22366. */
  22367. readonly hasRenderTargetTextures: boolean;
  22368. /**
  22369. * Specifies if the material should be serialized
  22370. */
  22371. doNotSerialize: boolean;
  22372. /**
  22373. * @hidden
  22374. */
  22375. _storeEffectOnSubMeshes: boolean;
  22376. /**
  22377. * Stores the animations for the material
  22378. */
  22379. animations: Array<Animation>;
  22380. /**
  22381. * An event triggered when the material is disposed
  22382. */
  22383. onDisposeObservable: Observable<Material>;
  22384. /**
  22385. * An observer which watches for dispose events
  22386. */
  22387. private _onDisposeObserver;
  22388. private _onUnBindObservable;
  22389. /**
  22390. * Called during a dispose event
  22391. */
  22392. onDispose: () => void;
  22393. private _onBindObservable;
  22394. /**
  22395. * An event triggered when the material is bound
  22396. */
  22397. readonly onBindObservable: Observable<AbstractMesh>;
  22398. /**
  22399. * An observer which watches for bind events
  22400. */
  22401. private _onBindObserver;
  22402. /**
  22403. * Called during a bind event
  22404. */
  22405. onBind: (Mesh: AbstractMesh) => void;
  22406. /**
  22407. * An event triggered when the material is unbound
  22408. */
  22409. readonly onUnBindObservable: Observable<Material>;
  22410. /**
  22411. * Stores the value of the alpha mode
  22412. */
  22413. private _alphaMode;
  22414. /**
  22415. * Sets the value of the alpha mode.
  22416. *
  22417. * | Value | Type | Description |
  22418. * | --- | --- | --- |
  22419. * | 0 | ALPHA_DISABLE | |
  22420. * | 1 | ALPHA_ADD | |
  22421. * | 2 | ALPHA_COMBINE | |
  22422. * | 3 | ALPHA_SUBTRACT | |
  22423. * | 4 | ALPHA_MULTIPLY | |
  22424. * | 5 | ALPHA_MAXIMIZED | |
  22425. * | 6 | ALPHA_ONEONE | |
  22426. * | 7 | ALPHA_PREMULTIPLIED | |
  22427. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22428. * | 9 | ALPHA_INTERPOLATE | |
  22429. * | 10 | ALPHA_SCREENMODE | |
  22430. *
  22431. */
  22432. /**
  22433. * Gets the value of the alpha mode
  22434. */
  22435. alphaMode: number;
  22436. /**
  22437. * Stores the state of the need depth pre-pass value
  22438. */
  22439. private _needDepthPrePass;
  22440. /**
  22441. * Sets the need depth pre-pass value
  22442. */
  22443. /**
  22444. * Gets the depth pre-pass value
  22445. */
  22446. needDepthPrePass: boolean;
  22447. /**
  22448. * Specifies if depth writing should be disabled
  22449. */
  22450. disableDepthWrite: boolean;
  22451. /**
  22452. * Specifies if depth writing should be forced
  22453. */
  22454. forceDepthWrite: boolean;
  22455. /**
  22456. * Specifies if there should be a separate pass for culling
  22457. */
  22458. separateCullingPass: boolean;
  22459. /**
  22460. * Stores the state specifing if fog should be enabled
  22461. */
  22462. private _fogEnabled;
  22463. /**
  22464. * Sets the state for enabling fog
  22465. */
  22466. /**
  22467. * Gets the value of the fog enabled state
  22468. */
  22469. fogEnabled: boolean;
  22470. /**
  22471. * Stores the size of points
  22472. */
  22473. pointSize: number;
  22474. /**
  22475. * Stores the z offset value
  22476. */
  22477. zOffset: number;
  22478. /**
  22479. * Gets a value specifying if wireframe mode is enabled
  22480. */
  22481. /**
  22482. * Sets the state of wireframe mode
  22483. */
  22484. wireframe: boolean;
  22485. /**
  22486. * Gets the value specifying if point clouds are enabled
  22487. */
  22488. /**
  22489. * Sets the state of point cloud mode
  22490. */
  22491. pointsCloud: boolean;
  22492. /**
  22493. * Gets the material fill mode
  22494. */
  22495. /**
  22496. * Sets the material fill mode
  22497. */
  22498. fillMode: number;
  22499. /**
  22500. * @hidden
  22501. * Stores the effects for the material
  22502. */
  22503. _effect: Nullable<Effect>;
  22504. /**
  22505. * @hidden
  22506. * Specifies if the material was previously ready
  22507. */
  22508. _wasPreviouslyReady: boolean;
  22509. /**
  22510. * Specifies if uniform buffers should be used
  22511. */
  22512. private _useUBO;
  22513. /**
  22514. * Stores a reference to the scene
  22515. */
  22516. private _scene;
  22517. /**
  22518. * Stores the fill mode state
  22519. */
  22520. private _fillMode;
  22521. /**
  22522. * Specifies if the depth write state should be cached
  22523. */
  22524. private _cachedDepthWriteState;
  22525. /**
  22526. * Stores the uniform buffer
  22527. */
  22528. protected _uniformBuffer: UniformBuffer;
  22529. /** @hidden */
  22530. _indexInSceneMaterialArray: number;
  22531. /** @hidden */
  22532. meshMap: Nullable<{
  22533. [id: string]: AbstractMesh | undefined;
  22534. }>;
  22535. /**
  22536. * Creates a material instance
  22537. * @param name defines the name of the material
  22538. * @param scene defines the scene to reference
  22539. * @param doNotAdd specifies if the material should be added to the scene
  22540. */
  22541. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22542. /**
  22543. * Returns a string representation of the current material
  22544. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22545. * @returns a string with material information
  22546. */
  22547. toString(fullDetails?: boolean): string;
  22548. /**
  22549. * Gets the class name of the material
  22550. * @returns a string with the class name of the material
  22551. */
  22552. getClassName(): string;
  22553. /**
  22554. * Specifies if updates for the material been locked
  22555. */
  22556. readonly isFrozen: boolean;
  22557. /**
  22558. * Locks updates for the material
  22559. */
  22560. freeze(): void;
  22561. /**
  22562. * Unlocks updates for the material
  22563. */
  22564. unfreeze(): void;
  22565. /**
  22566. * Specifies if the material is ready to be used
  22567. * @param mesh defines the mesh to check
  22568. * @param useInstances specifies if instances should be used
  22569. * @returns a boolean indicating if the material is ready to be used
  22570. */
  22571. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22572. /**
  22573. * Specifies that the submesh is ready to be used
  22574. * @param mesh defines the mesh to check
  22575. * @param subMesh defines which submesh to check
  22576. * @param useInstances specifies that instances should be used
  22577. * @returns a boolean indicating that the submesh is ready or not
  22578. */
  22579. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22580. /**
  22581. * Returns the material effect
  22582. * @returns the effect associated with the material
  22583. */
  22584. getEffect(): Nullable<Effect>;
  22585. /**
  22586. * Returns the current scene
  22587. * @returns a Scene
  22588. */
  22589. getScene(): Scene;
  22590. /**
  22591. * Specifies if the material will require alpha blending
  22592. * @returns a boolean specifying if alpha blending is needed
  22593. */
  22594. needAlphaBlending(): boolean;
  22595. /**
  22596. * Specifies if the mesh will require alpha blending
  22597. * @param mesh defines the mesh to check
  22598. * @returns a boolean specifying if alpha blending is needed for the mesh
  22599. */
  22600. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22601. /**
  22602. * Specifies if this material should be rendered in alpha test mode
  22603. * @returns a boolean specifying if an alpha test is needed.
  22604. */
  22605. needAlphaTesting(): boolean;
  22606. /**
  22607. * Gets the texture used for the alpha test
  22608. * @returns the texture to use for alpha testing
  22609. */
  22610. getAlphaTestTexture(): Nullable<BaseTexture>;
  22611. /**
  22612. * Marks the material to indicate that it needs to be re-calculated
  22613. */
  22614. markDirty(): void;
  22615. /** @hidden */
  22616. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22617. /**
  22618. * Binds the material to the mesh
  22619. * @param world defines the world transformation matrix
  22620. * @param mesh defines the mesh to bind the material to
  22621. */
  22622. bind(world: Matrix, mesh?: Mesh): void;
  22623. /**
  22624. * Binds the submesh to the material
  22625. * @param world defines the world transformation matrix
  22626. * @param mesh defines the mesh containing the submesh
  22627. * @param subMesh defines the submesh to bind the material to
  22628. */
  22629. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22630. /**
  22631. * Binds the world matrix to the material
  22632. * @param world defines the world transformation matrix
  22633. */
  22634. bindOnlyWorldMatrix(world: Matrix): void;
  22635. /**
  22636. * Binds the scene's uniform buffer to the effect.
  22637. * @param effect defines the effect to bind to the scene uniform buffer
  22638. * @param sceneUbo defines the uniform buffer storing scene data
  22639. */
  22640. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22641. /**
  22642. * Binds the view matrix to the effect
  22643. * @param effect defines the effect to bind the view matrix to
  22644. */
  22645. bindView(effect: Effect): void;
  22646. /**
  22647. * Binds the view projection matrix to the effect
  22648. * @param effect defines the effect to bind the view projection matrix to
  22649. */
  22650. bindViewProjection(effect: Effect): void;
  22651. /**
  22652. * Specifies if material alpha testing should be turned on for the mesh
  22653. * @param mesh defines the mesh to check
  22654. */
  22655. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22656. /**
  22657. * Processes to execute after binding the material to a mesh
  22658. * @param mesh defines the rendered mesh
  22659. */
  22660. protected _afterBind(mesh?: Mesh): void;
  22661. /**
  22662. * Unbinds the material from the mesh
  22663. */
  22664. unbind(): void;
  22665. /**
  22666. * Gets the active textures from the material
  22667. * @returns an array of textures
  22668. */
  22669. getActiveTextures(): BaseTexture[];
  22670. /**
  22671. * Specifies if the material uses a texture
  22672. * @param texture defines the texture to check against the material
  22673. * @returns a boolean specifying if the material uses the texture
  22674. */
  22675. hasTexture(texture: BaseTexture): boolean;
  22676. /**
  22677. * Makes a duplicate of the material, and gives it a new name
  22678. * @param name defines the new name for the duplicated material
  22679. * @returns the cloned material
  22680. */
  22681. clone(name: string): Nullable<Material>;
  22682. /**
  22683. * Gets the meshes bound to the material
  22684. * @returns an array of meshes bound to the material
  22685. */
  22686. getBindedMeshes(): AbstractMesh[];
  22687. /**
  22688. * Force shader compilation
  22689. * @param mesh defines the mesh associated with this material
  22690. * @param onCompiled defines a function to execute once the material is compiled
  22691. * @param options defines the options to configure the compilation
  22692. */
  22693. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22694. clipPlane: boolean;
  22695. }>): void;
  22696. /**
  22697. * Force shader compilation
  22698. * @param mesh defines the mesh that will use this material
  22699. * @param options defines additional options for compiling the shaders
  22700. * @returns a promise that resolves when the compilation completes
  22701. */
  22702. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22703. clipPlane: boolean;
  22704. }>): Promise<void>;
  22705. private static readonly _ImageProcessingDirtyCallBack;
  22706. private static readonly _TextureDirtyCallBack;
  22707. private static readonly _FresnelDirtyCallBack;
  22708. private static readonly _MiscDirtyCallBack;
  22709. private static readonly _LightsDirtyCallBack;
  22710. private static readonly _AttributeDirtyCallBack;
  22711. private static _FresnelAndMiscDirtyCallBack;
  22712. private static _TextureAndMiscDirtyCallBack;
  22713. private static readonly _DirtyCallbackArray;
  22714. private static readonly _RunDirtyCallBacks;
  22715. /**
  22716. * Marks a define in the material to indicate that it needs to be re-computed
  22717. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22718. */
  22719. markAsDirty(flag: number): void;
  22720. /**
  22721. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22722. * @param func defines a function which checks material defines against the submeshes
  22723. */
  22724. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22725. /**
  22726. * Indicates that image processing needs to be re-calculated for all submeshes
  22727. */
  22728. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22729. /**
  22730. * Indicates that textures need to be re-calculated for all submeshes
  22731. */
  22732. protected _markAllSubMeshesAsTexturesDirty(): void;
  22733. /**
  22734. * Indicates that fresnel needs to be re-calculated for all submeshes
  22735. */
  22736. protected _markAllSubMeshesAsFresnelDirty(): void;
  22737. /**
  22738. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22739. */
  22740. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22741. /**
  22742. * Indicates that lights need to be re-calculated for all submeshes
  22743. */
  22744. protected _markAllSubMeshesAsLightsDirty(): void;
  22745. /**
  22746. * Indicates that attributes need to be re-calculated for all submeshes
  22747. */
  22748. protected _markAllSubMeshesAsAttributesDirty(): void;
  22749. /**
  22750. * Indicates that misc needs to be re-calculated for all submeshes
  22751. */
  22752. protected _markAllSubMeshesAsMiscDirty(): void;
  22753. /**
  22754. * Indicates that textures and misc need to be re-calculated for all submeshes
  22755. */
  22756. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22757. /**
  22758. * Disposes the material
  22759. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22760. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22761. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22762. */
  22763. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22764. /** @hidden */
  22765. private releaseVertexArrayObject;
  22766. /**
  22767. * Serializes this material
  22768. * @returns the serialized material object
  22769. */
  22770. serialize(): any;
  22771. /**
  22772. * Creates a MultiMaterial from parsed MultiMaterial data.
  22773. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22774. * @param scene defines the hosting scene
  22775. * @returns a new MultiMaterial
  22776. */
  22777. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22778. /**
  22779. * Creates a material from parsed material data
  22780. * @param parsedMaterial defines parsed material data
  22781. * @param scene defines the hosting scene
  22782. * @param rootUrl defines the root URL to use to load textures
  22783. * @returns a new material
  22784. */
  22785. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22786. }
  22787. }
  22788. declare module BABYLON {
  22789. /**
  22790. * "Static Class" containing the most commonly used helper while dealing with material for
  22791. * rendering purpose.
  22792. *
  22793. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  22794. *
  22795. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  22796. */
  22797. class MaterialHelper {
  22798. /**
  22799. * Bind the current view position to an effect.
  22800. * @param effect The effect to be bound
  22801. * @param scene The scene the eyes position is used from
  22802. */
  22803. static BindEyePosition(effect: Effect, scene: Scene): void;
  22804. /**
  22805. * Helps preparing the defines values about the UVs in used in the effect.
  22806. * UVs are shared as much as we can accross channels in the shaders.
  22807. * @param texture The texture we are preparing the UVs for
  22808. * @param defines The defines to update
  22809. * @param key The channel key "diffuse", "specular"... used in the shader
  22810. */
  22811. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  22812. /**
  22813. * Binds a texture matrix value to its corrsponding uniform
  22814. * @param texture The texture to bind the matrix for
  22815. * @param uniformBuffer The uniform buffer receivin the data
  22816. * @param key The channel key "diffuse", "specular"... used in the shader
  22817. */
  22818. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  22819. /**
  22820. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  22821. * @param mesh defines the current mesh
  22822. * @param scene defines the current scene
  22823. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  22824. * @param pointsCloud defines if point cloud rendering has to be turned on
  22825. * @param fogEnabled defines if fog has to be turned on
  22826. * @param alphaTest defines if alpha testing has to be turned on
  22827. * @param defines defines the current list of defines
  22828. */
  22829. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  22830. /**
  22831. * Helper used to prepare the list of defines associated with frame values for shader compilation
  22832. * @param scene defines the current scene
  22833. * @param engine defines the current engine
  22834. * @param defines specifies the list of active defines
  22835. * @param useInstances defines if instances have to be turned on
  22836. * @param useClipPlane defines if clip plane have to be turned on
  22837. */
  22838. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  22839. /**
  22840. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  22841. * @param mesh The mesh containing the geometry data we will draw
  22842. * @param defines The defines to update
  22843. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  22844. * @param useBones Precise whether bones should be used or not (override mesh info)
  22845. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  22846. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  22847. * @returns false if defines are considered not dirty and have not been checked
  22848. */
  22849. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  22850. /**
  22851. * Prepares the defines related to the light information passed in parameter
  22852. * @param scene The scene we are intending to draw
  22853. * @param mesh The mesh the effect is compiling for
  22854. * @param defines The defines to update
  22855. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  22856. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  22857. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  22858. * @returns true if normals will be required for the rest of the effect
  22859. */
  22860. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  22861. /**
  22862. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  22863. * that won t be acctive due to defines being turned off.
  22864. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  22865. * @param samplersList The samplers list
  22866. * @param defines The defines helping in the list generation
  22867. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  22868. */
  22869. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  22870. /**
  22871. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  22872. * @param defines The defines to update while falling back
  22873. * @param fallbacks The authorized effect fallbacks
  22874. * @param maxSimultaneousLights The maximum number of lights allowed
  22875. * @param rank the current rank of the Effect
  22876. * @returns The newly affected rank
  22877. */
  22878. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  22879. /**
  22880. * Prepares the list of attributes required for morph targets according to the effect defines.
  22881. * @param attribs The current list of supported attribs
  22882. * @param mesh The mesh to prepare the morph targets attributes for
  22883. * @param defines The current Defines of the effect
  22884. */
  22885. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  22886. /**
  22887. * Prepares the list of attributes required for bones according to the effect defines.
  22888. * @param attribs The current list of supported attribs
  22889. * @param mesh The mesh to prepare the bones attributes for
  22890. * @param defines The current Defines of the effect
  22891. * @param fallbacks The current efffect fallback strategy
  22892. */
  22893. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  22894. /**
  22895. * Prepares the list of attributes required for instances according to the effect defines.
  22896. * @param attribs The current list of supported attribs
  22897. * @param defines The current Defines of the effect
  22898. */
  22899. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  22900. /**
  22901. * Binds the light shadow information to the effect for the given mesh.
  22902. * @param light The light containing the generator
  22903. * @param scene The scene the lights belongs to
  22904. * @param mesh The mesh we are binding the information to render
  22905. * @param lightIndex The light index in the effect used to render the mesh
  22906. * @param effect The effect we are binding the data to
  22907. */
  22908. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  22909. /**
  22910. * Binds the light information to the effect.
  22911. * @param light The light containing the generator
  22912. * @param effect The effect we are binding the data to
  22913. * @param lightIndex The light index in the effect used to render
  22914. */
  22915. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  22916. /**
  22917. * Binds the lights information from the scene to the effect for the given mesh.
  22918. * @param scene The scene the lights belongs to
  22919. * @param mesh The mesh we are binding the information to render
  22920. * @param effect The effect we are binding the data to
  22921. * @param defines The generated defines for the effect
  22922. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  22923. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  22924. */
  22925. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  22926. private static _tempFogColor;
  22927. /**
  22928. * Binds the fog information from the scene to the effect for the given mesh.
  22929. * @param scene The scene the lights belongs to
  22930. * @param mesh The mesh we are binding the information to render
  22931. * @param effect The effect we are binding the data to
  22932. * @param linearSpace Defines if the fog effect is applied in linear space
  22933. */
  22934. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  22935. /**
  22936. * Binds the bones information from the mesh to the effect.
  22937. * @param mesh The mesh we are binding the information to render
  22938. * @param effect The effect we are binding the data to
  22939. */
  22940. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  22941. /**
  22942. * Binds the morph targets information from the mesh to the effect.
  22943. * @param abstractMesh The mesh we are binding the information to render
  22944. * @param effect The effect we are binding the data to
  22945. */
  22946. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  22947. /**
  22948. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  22949. * @param defines The generated defines used in the effect
  22950. * @param effect The effect we are binding the data to
  22951. * @param scene The scene we are willing to render with logarithmic scale for
  22952. */
  22953. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  22954. /**
  22955. * Binds the clip plane information from the scene to the effect.
  22956. * @param scene The scene the clip plane information are extracted from
  22957. * @param effect The effect we are binding the data to
  22958. */
  22959. static BindClipPlane(effect: Effect, scene: Scene): void;
  22960. }
  22961. }
  22962. declare module BABYLON {
  22963. /**
  22964. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22965. * separate meshes. This can be use to improve performances.
  22966. * @see http://doc.babylonjs.com/how_to/multi_materials
  22967. */
  22968. class MultiMaterial extends Material {
  22969. private _subMaterials;
  22970. /**
  22971. * Gets or Sets the list of Materials used within the multi material.
  22972. * They need to be ordered according to the submeshes order in the associated mesh
  22973. */
  22974. subMaterials: Nullable<Material>[];
  22975. /**
  22976. * Function used to align with Node.getChildren()
  22977. * @returns the list of Materials used within the multi material
  22978. */
  22979. getChildren(): Nullable<Material>[];
  22980. /**
  22981. * Instantiates a new Multi Material
  22982. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22983. * separate meshes. This can be use to improve performances.
  22984. * @see http://doc.babylonjs.com/how_to/multi_materials
  22985. * @param name Define the name in the scene
  22986. * @param scene Define the scene the material belongs to
  22987. */
  22988. constructor(name: string, scene: Scene);
  22989. private _hookArray;
  22990. /**
  22991. * Get one of the submaterial by its index in the submaterials array
  22992. * @param index The index to look the sub material at
  22993. * @returns The Material if the index has been defined
  22994. */
  22995. getSubMaterial(index: number): Nullable<Material>;
  22996. /**
  22997. * Get the list of active textures for the whole sub materials list.
  22998. * @returns All the textures that will be used during the rendering
  22999. */
  23000. getActiveTextures(): BaseTexture[];
  23001. /**
  23002. * Gets the current class name of the material e.g. "MultiMaterial"
  23003. * Mainly use in serialization.
  23004. * @returns the class name
  23005. */
  23006. getClassName(): string;
  23007. /**
  23008. * Checks if the material is ready to render the requested sub mesh
  23009. * @param mesh Define the mesh the submesh belongs to
  23010. * @param subMesh Define the sub mesh to look readyness for
  23011. * @param useInstances Define whether or not the material is used with instances
  23012. * @returns true if ready, otherwise false
  23013. */
  23014. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23015. /**
  23016. * Clones the current material and its related sub materials
  23017. * @param name Define the name of the newly cloned material
  23018. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  23019. * @returns the cloned material
  23020. */
  23021. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  23022. /**
  23023. * Serializes the materials into a JSON representation.
  23024. * @returns the JSON representation
  23025. */
  23026. serialize(): any;
  23027. /**
  23028. * Dispose the material and release its associated resources
  23029. * @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)
  23030. * @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)
  23031. */
  23032. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23033. }
  23034. }
  23035. declare module BABYLON {
  23036. /**
  23037. * Base class of materials working in push mode in babylon JS
  23038. * @hidden
  23039. */
  23040. class PushMaterial extends Material {
  23041. protected _activeEffect: Effect;
  23042. protected _normalMatrix: Matrix;
  23043. /**
  23044. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  23045. * This means that the material can keep using a previous shader while a new one is being compiled.
  23046. * This is mostly used when shader parallel compilation is supported (true by default)
  23047. */
  23048. allowShaderHotSwapping: boolean;
  23049. constructor(name: string, scene: Scene);
  23050. getEffect(): Effect;
  23051. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23052. /**
  23053. * Binds the given world matrix to the active effect
  23054. *
  23055. * @param world the matrix to bind
  23056. */
  23057. bindOnlyWorldMatrix(world: Matrix): void;
  23058. /**
  23059. * Binds the given normal matrix to the active effect
  23060. *
  23061. * @param normalMatrix the matrix to bind
  23062. */
  23063. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  23064. bind(world: Matrix, mesh?: Mesh): void;
  23065. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  23066. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  23067. }
  23068. }
  23069. declare module BABYLON {
  23070. /**
  23071. * Defines the options associated with the creation of a shader material.
  23072. */
  23073. interface IShaderMaterialOptions {
  23074. /**
  23075. * Does the material work in alpha blend mode
  23076. */
  23077. needAlphaBlending: boolean;
  23078. /**
  23079. * Does the material work in alpha test mode
  23080. */
  23081. needAlphaTesting: boolean;
  23082. /**
  23083. * The list of attribute names used in the shader
  23084. */
  23085. attributes: string[];
  23086. /**
  23087. * The list of unifrom names used in the shader
  23088. */
  23089. uniforms: string[];
  23090. /**
  23091. * The list of UBO names used in the shader
  23092. */
  23093. uniformBuffers: string[];
  23094. /**
  23095. * The list of sampler names used in the shader
  23096. */
  23097. samplers: string[];
  23098. /**
  23099. * The list of defines used in the shader
  23100. */
  23101. defines: string[];
  23102. }
  23103. /**
  23104. * 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.
  23105. *
  23106. * This returned material effects how the mesh will look based on the code in the shaders.
  23107. *
  23108. * @see http://doc.babylonjs.com/how_to/shader_material
  23109. */
  23110. class ShaderMaterial extends Material {
  23111. private _shaderPath;
  23112. private _options;
  23113. private _textures;
  23114. private _textureArrays;
  23115. private _floats;
  23116. private _ints;
  23117. private _floatsArrays;
  23118. private _colors3;
  23119. private _colors3Arrays;
  23120. private _colors4;
  23121. private _vectors2;
  23122. private _vectors3;
  23123. private _vectors4;
  23124. private _matrices;
  23125. private _matrices3x3;
  23126. private _matrices2x2;
  23127. private _vectors2Arrays;
  23128. private _vectors3Arrays;
  23129. private _cachedWorldViewMatrix;
  23130. private _renderId;
  23131. /**
  23132. * Instantiate a new shader material.
  23133. * 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.
  23134. * This returned material effects how the mesh will look based on the code in the shaders.
  23135. * @see http://doc.babylonjs.com/how_to/shader_material
  23136. * @param name Define the name of the material in the scene
  23137. * @param scene Define the scene the material belongs to
  23138. * @param shaderPath Defines the route to the shader code in one of three ways:
  23139. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  23140. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  23141. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  23142. * @param options Define the options used to create the shader
  23143. */
  23144. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  23145. /**
  23146. * Gets the current class name of the material e.g. "ShaderMaterial"
  23147. * Mainly use in serialization.
  23148. * @returns the class name
  23149. */
  23150. getClassName(): string;
  23151. /**
  23152. * Specifies if the material will require alpha blending
  23153. * @returns a boolean specifying if alpha blending is needed
  23154. */
  23155. needAlphaBlending(): boolean;
  23156. /**
  23157. * Specifies if this material should be rendered in alpha test mode
  23158. * @returns a boolean specifying if an alpha test is needed.
  23159. */
  23160. needAlphaTesting(): boolean;
  23161. private _checkUniform;
  23162. /**
  23163. * Set a texture in the shader.
  23164. * @param name Define the name of the uniform samplers as defined in the shader
  23165. * @param texture Define the texture to bind to this sampler
  23166. * @return the material itself allowing "fluent" like uniform updates
  23167. */
  23168. setTexture(name: string, texture: Texture): ShaderMaterial;
  23169. /**
  23170. * Set a texture array in the shader.
  23171. * @param name Define the name of the uniform sampler array as defined in the shader
  23172. * @param textures Define the list of textures to bind to this sampler
  23173. * @return the material itself allowing "fluent" like uniform updates
  23174. */
  23175. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  23176. /**
  23177. * Set a float in the shader.
  23178. * @param name Define the name of the uniform as defined in the shader
  23179. * @param value Define the value to give to the uniform
  23180. * @return the material itself allowing "fluent" like uniform updates
  23181. */
  23182. setFloat(name: string, value: number): ShaderMaterial;
  23183. /**
  23184. * Set a int in the shader.
  23185. * @param name Define the name of the uniform as defined in the shader
  23186. * @param value Define the value to give to the uniform
  23187. * @return the material itself allowing "fluent" like uniform updates
  23188. */
  23189. setInt(name: string, value: number): ShaderMaterial;
  23190. /**
  23191. * Set an array of floats in the shader.
  23192. * @param name Define the name of the uniform as defined in the shader
  23193. * @param value Define the value to give to the uniform
  23194. * @return the material itself allowing "fluent" like uniform updates
  23195. */
  23196. setFloats(name: string, value: number[]): ShaderMaterial;
  23197. /**
  23198. * Set a vec3 in the shader from a Color3.
  23199. * @param name Define the name of the uniform as defined in the shader
  23200. * @param value Define the value to give to the uniform
  23201. * @return the material itself allowing "fluent" like uniform updates
  23202. */
  23203. setColor3(name: string, value: Color3): ShaderMaterial;
  23204. /**
  23205. * Set a vec3 array in the shader from a Color3 array.
  23206. * @param name Define the name of the uniform as defined in the shader
  23207. * @param value Define the value to give to the uniform
  23208. * @return the material itself allowing "fluent" like uniform updates
  23209. */
  23210. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  23211. /**
  23212. * Set a vec4 in the shader from a Color4.
  23213. * @param name Define the name of the uniform as defined in the shader
  23214. * @param value Define the value to give to the uniform
  23215. * @return the material itself allowing "fluent" like uniform updates
  23216. */
  23217. setColor4(name: string, value: Color4): ShaderMaterial;
  23218. /**
  23219. * Set a vec2 in the shader from a Vector2.
  23220. * @param name Define the name of the uniform as defined in the shader
  23221. * @param value Define the value to give to the uniform
  23222. * @return the material itself allowing "fluent" like uniform updates
  23223. */
  23224. setVector2(name: string, value: Vector2): ShaderMaterial;
  23225. /**
  23226. * Set a vec3 in the shader from a Vector3.
  23227. * @param name Define the name of the uniform as defined in the shader
  23228. * @param value Define the value to give to the uniform
  23229. * @return the material itself allowing "fluent" like uniform updates
  23230. */
  23231. setVector3(name: string, value: Vector3): ShaderMaterial;
  23232. /**
  23233. * Set a vec4 in the shader from a Vector4.
  23234. * @param name Define the name of the uniform as defined in the shader
  23235. * @param value Define the value to give to the uniform
  23236. * @return the material itself allowing "fluent" like uniform updates
  23237. */
  23238. setVector4(name: string, value: Vector4): ShaderMaterial;
  23239. /**
  23240. * Set a mat4 in the shader from a Matrix.
  23241. * @param name Define the name of the uniform as defined in the shader
  23242. * @param value Define the value to give to the uniform
  23243. * @return the material itself allowing "fluent" like uniform updates
  23244. */
  23245. setMatrix(name: string, value: Matrix): ShaderMaterial;
  23246. /**
  23247. * Set a mat3 in the shader from a Float32Array.
  23248. * @param name Define the name of the uniform as defined in the shader
  23249. * @param value Define the value to give to the uniform
  23250. * @return the material itself allowing "fluent" like uniform updates
  23251. */
  23252. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  23253. /**
  23254. * Set a mat2 in the shader from a Float32Array.
  23255. * @param name Define the name of the uniform as defined in the shader
  23256. * @param value Define the value to give to the uniform
  23257. * @return the material itself allowing "fluent" like uniform updates
  23258. */
  23259. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  23260. /**
  23261. * Set a vec2 array in the shader from a number array.
  23262. * @param name Define the name of the uniform as defined in the shader
  23263. * @param value Define the value to give to the uniform
  23264. * @return the material itself allowing "fluent" like uniform updates
  23265. */
  23266. setArray2(name: string, value: number[]): ShaderMaterial;
  23267. /**
  23268. * Set a vec3 array in the shader from a number array.
  23269. * @param name Define the name of the uniform as defined in the shader
  23270. * @param value Define the value to give to the uniform
  23271. * @return the material itself allowing "fluent" like uniform updates
  23272. */
  23273. setArray3(name: string, value: number[]): ShaderMaterial;
  23274. private _checkCache;
  23275. /**
  23276. * Checks if the material is ready to render the requested mesh
  23277. * @param mesh Define the mesh to render
  23278. * @param useInstances Define whether or not the material is used with instances
  23279. * @returns true if ready, otherwise false
  23280. */
  23281. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23282. /**
  23283. * Binds the world matrix to the material
  23284. * @param world defines the world transformation matrix
  23285. */
  23286. bindOnlyWorldMatrix(world: Matrix): void;
  23287. /**
  23288. * Binds the material to the mesh
  23289. * @param world defines the world transformation matrix
  23290. * @param mesh defines the mesh to bind the material to
  23291. */
  23292. bind(world: Matrix, mesh?: Mesh): void;
  23293. /**
  23294. * Gets the active textures from the material
  23295. * @returns an array of textures
  23296. */
  23297. getActiveTextures(): BaseTexture[];
  23298. /**
  23299. * Specifies if the material uses a texture
  23300. * @param texture defines the texture to check against the material
  23301. * @returns a boolean specifying if the material uses the texture
  23302. */
  23303. hasTexture(texture: BaseTexture): boolean;
  23304. /**
  23305. * Makes a duplicate of the material, and gives it a new name
  23306. * @param name defines the new name for the duplicated material
  23307. * @returns the cloned material
  23308. */
  23309. clone(name: string): ShaderMaterial;
  23310. /**
  23311. * Disposes the material
  23312. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23313. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23314. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23315. */
  23316. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23317. /**
  23318. * Serializes this material in a JSON representation
  23319. * @returns the serialized material object
  23320. */
  23321. serialize(): any;
  23322. /**
  23323. * Creates a shader material from parsed shader material data
  23324. * @param source defines the JSON represnetation of the material
  23325. * @param scene defines the hosting scene
  23326. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23327. * @returns a new material
  23328. */
  23329. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  23330. }
  23331. }
  23332. declare module BABYLON {
  23333. /** @hidden */
  23334. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23335. MAINUV1: boolean;
  23336. MAINUV2: boolean;
  23337. DIFFUSE: boolean;
  23338. DIFFUSEDIRECTUV: number;
  23339. AMBIENT: boolean;
  23340. AMBIENTDIRECTUV: number;
  23341. OPACITY: boolean;
  23342. OPACITYDIRECTUV: number;
  23343. OPACITYRGB: boolean;
  23344. REFLECTION: boolean;
  23345. EMISSIVE: boolean;
  23346. EMISSIVEDIRECTUV: number;
  23347. SPECULAR: boolean;
  23348. SPECULARDIRECTUV: number;
  23349. BUMP: boolean;
  23350. BUMPDIRECTUV: number;
  23351. PARALLAX: boolean;
  23352. PARALLAXOCCLUSION: boolean;
  23353. SPECULAROVERALPHA: boolean;
  23354. CLIPPLANE: boolean;
  23355. CLIPPLANE2: boolean;
  23356. CLIPPLANE3: boolean;
  23357. CLIPPLANE4: boolean;
  23358. ALPHATEST: boolean;
  23359. DEPTHPREPASS: boolean;
  23360. ALPHAFROMDIFFUSE: boolean;
  23361. POINTSIZE: boolean;
  23362. FOG: boolean;
  23363. SPECULARTERM: boolean;
  23364. DIFFUSEFRESNEL: boolean;
  23365. OPACITYFRESNEL: boolean;
  23366. REFLECTIONFRESNEL: boolean;
  23367. REFRACTIONFRESNEL: boolean;
  23368. EMISSIVEFRESNEL: boolean;
  23369. FRESNEL: boolean;
  23370. NORMAL: boolean;
  23371. UV1: boolean;
  23372. UV2: boolean;
  23373. VERTEXCOLOR: boolean;
  23374. VERTEXALPHA: boolean;
  23375. NUM_BONE_INFLUENCERS: number;
  23376. BonesPerMesh: number;
  23377. BONETEXTURE: boolean;
  23378. INSTANCES: boolean;
  23379. GLOSSINESS: boolean;
  23380. ROUGHNESS: boolean;
  23381. EMISSIVEASILLUMINATION: boolean;
  23382. LINKEMISSIVEWITHDIFFUSE: boolean;
  23383. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23384. LIGHTMAP: boolean;
  23385. LIGHTMAPDIRECTUV: number;
  23386. OBJECTSPACE_NORMALMAP: boolean;
  23387. USELIGHTMAPASSHADOWMAP: boolean;
  23388. REFLECTIONMAP_3D: boolean;
  23389. REFLECTIONMAP_SPHERICAL: boolean;
  23390. REFLECTIONMAP_PLANAR: boolean;
  23391. REFLECTIONMAP_CUBIC: boolean;
  23392. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23393. REFLECTIONMAP_PROJECTION: boolean;
  23394. REFLECTIONMAP_SKYBOX: boolean;
  23395. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  23396. REFLECTIONMAP_EXPLICIT: boolean;
  23397. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23398. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23399. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23400. INVERTCUBICMAP: boolean;
  23401. LOGARITHMICDEPTH: boolean;
  23402. REFRACTION: boolean;
  23403. REFRACTIONMAP_3D: boolean;
  23404. REFLECTIONOVERALPHA: boolean;
  23405. TWOSIDEDLIGHTING: boolean;
  23406. SHADOWFLOAT: boolean;
  23407. MORPHTARGETS: boolean;
  23408. MORPHTARGETS_NORMAL: boolean;
  23409. MORPHTARGETS_TANGENT: boolean;
  23410. NUM_MORPH_INFLUENCERS: number;
  23411. NONUNIFORMSCALING: boolean;
  23412. PREMULTIPLYALPHA: boolean;
  23413. IMAGEPROCESSING: boolean;
  23414. VIGNETTE: boolean;
  23415. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23416. VIGNETTEBLENDMODEOPAQUE: boolean;
  23417. TONEMAPPING: boolean;
  23418. TONEMAPPING_ACES: boolean;
  23419. CONTRAST: boolean;
  23420. COLORCURVES: boolean;
  23421. COLORGRADING: boolean;
  23422. COLORGRADING3D: boolean;
  23423. SAMPLER3DGREENDEPTH: boolean;
  23424. SAMPLER3DBGRMAP: boolean;
  23425. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23426. /**
  23427. * If the reflection texture on this material is in linear color space
  23428. * @hidden
  23429. */
  23430. IS_REFLECTION_LINEAR: boolean;
  23431. /**
  23432. * If the refraction texture on this material is in linear color space
  23433. * @hidden
  23434. */
  23435. IS_REFRACTION_LINEAR: boolean;
  23436. EXPOSURE: boolean;
  23437. constructor();
  23438. setReflectionMode(modeToEnable: string): void;
  23439. }
  23440. /**
  23441. * This is the default material used in Babylon. It is the best trade off between quality
  23442. * and performances.
  23443. * @see http://doc.babylonjs.com/babylon101/materials
  23444. */
  23445. class StandardMaterial extends PushMaterial {
  23446. private _diffuseTexture;
  23447. /**
  23448. * The basic texture of the material as viewed under a light.
  23449. */
  23450. diffuseTexture: Nullable<BaseTexture>;
  23451. private _ambientTexture;
  23452. /**
  23453. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23454. */
  23455. ambientTexture: Nullable<BaseTexture>;
  23456. private _opacityTexture;
  23457. /**
  23458. * Define the transparency of the material from a texture.
  23459. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23460. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23461. */
  23462. opacityTexture: Nullable<BaseTexture>;
  23463. private _reflectionTexture;
  23464. /**
  23465. * Define the texture used to display the reflection.
  23466. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23467. */
  23468. reflectionTexture: Nullable<BaseTexture>;
  23469. private _emissiveTexture;
  23470. /**
  23471. * Define texture of the material as if self lit.
  23472. * This will be mixed in the final result even in the absence of light.
  23473. */
  23474. emissiveTexture: Nullable<BaseTexture>;
  23475. private _specularTexture;
  23476. /**
  23477. * Define how the color and intensity of the highlight given by the light in the material.
  23478. */
  23479. specularTexture: Nullable<BaseTexture>;
  23480. private _bumpTexture;
  23481. /**
  23482. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23483. * 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.
  23484. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  23485. */
  23486. bumpTexture: Nullable<BaseTexture>;
  23487. private _lightmapTexture;
  23488. /**
  23489. * Complex lighting can be computationally expensive to compute at runtime.
  23490. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23491. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  23492. */
  23493. lightmapTexture: Nullable<BaseTexture>;
  23494. private _refractionTexture;
  23495. /**
  23496. * Define the texture used to display the refraction.
  23497. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23498. */
  23499. refractionTexture: Nullable<BaseTexture>;
  23500. /**
  23501. * The color of the material lit by the environmental background lighting.
  23502. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  23503. */
  23504. ambientColor: Color3;
  23505. /**
  23506. * The basic color of the material as viewed under a light.
  23507. */
  23508. diffuseColor: Color3;
  23509. /**
  23510. * Define how the color and intensity of the highlight given by the light in the material.
  23511. */
  23512. specularColor: Color3;
  23513. /**
  23514. * Define the color of the material as if self lit.
  23515. * This will be mixed in the final result even in the absence of light.
  23516. */
  23517. emissiveColor: Color3;
  23518. /**
  23519. * Defines how sharp are the highlights in the material.
  23520. * The bigger the value the sharper giving a more glossy feeling to the result.
  23521. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  23522. */
  23523. specularPower: number;
  23524. private _useAlphaFromDiffuseTexture;
  23525. /**
  23526. * Does the transparency come from the diffuse texture alpha channel.
  23527. */
  23528. useAlphaFromDiffuseTexture: boolean;
  23529. private _useEmissiveAsIllumination;
  23530. /**
  23531. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  23532. */
  23533. useEmissiveAsIllumination: boolean;
  23534. private _linkEmissiveWithDiffuse;
  23535. /**
  23536. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  23537. * the emissive level when the final color is close to one.
  23538. */
  23539. linkEmissiveWithDiffuse: boolean;
  23540. private _useSpecularOverAlpha;
  23541. /**
  23542. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  23543. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  23544. */
  23545. useSpecularOverAlpha: boolean;
  23546. private _useReflectionOverAlpha;
  23547. /**
  23548. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  23549. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  23550. */
  23551. useReflectionOverAlpha: boolean;
  23552. private _disableLighting;
  23553. /**
  23554. * Does lights from the scene impacts this material.
  23555. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  23556. */
  23557. disableLighting: boolean;
  23558. private _useObjectSpaceNormalMap;
  23559. /**
  23560. * Allows using an object space normal map (instead of tangent space).
  23561. */
  23562. useObjectSpaceNormalMap: boolean;
  23563. private _useParallax;
  23564. /**
  23565. * Is parallax enabled or not.
  23566. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  23567. */
  23568. useParallax: boolean;
  23569. private _useParallaxOcclusion;
  23570. /**
  23571. * Is parallax occlusion enabled or not.
  23572. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  23573. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  23574. */
  23575. useParallaxOcclusion: boolean;
  23576. /**
  23577. * 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.
  23578. */
  23579. parallaxScaleBias: number;
  23580. private _roughness;
  23581. /**
  23582. * Helps to define how blurry the reflections should appears in the material.
  23583. */
  23584. roughness: number;
  23585. /**
  23586. * In case of refraction, define the value of the indice of refraction.
  23587. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23588. */
  23589. indexOfRefraction: number;
  23590. /**
  23591. * Invert the refraction texture alongside the y axis.
  23592. * It can be usefull with procedural textures or probe for instance.
  23593. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23594. */
  23595. invertRefractionY: boolean;
  23596. /**
  23597. * Defines the alpha limits in alpha test mode.
  23598. */
  23599. alphaCutOff: number;
  23600. private _useLightmapAsShadowmap;
  23601. /**
  23602. * In case of light mapping, define whether the map contains light or shadow informations.
  23603. */
  23604. useLightmapAsShadowmap: boolean;
  23605. private _diffuseFresnelParameters;
  23606. /**
  23607. * Define the diffuse fresnel parameters of the material.
  23608. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23609. */
  23610. diffuseFresnelParameters: FresnelParameters;
  23611. private _opacityFresnelParameters;
  23612. /**
  23613. * Define the opacity fresnel parameters of the material.
  23614. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23615. */
  23616. opacityFresnelParameters: FresnelParameters;
  23617. private _reflectionFresnelParameters;
  23618. /**
  23619. * Define the reflection fresnel parameters of the material.
  23620. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23621. */
  23622. reflectionFresnelParameters: FresnelParameters;
  23623. private _refractionFresnelParameters;
  23624. /**
  23625. * Define the refraction fresnel parameters of the material.
  23626. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23627. */
  23628. refractionFresnelParameters: FresnelParameters;
  23629. private _emissiveFresnelParameters;
  23630. /**
  23631. * Define the emissive fresnel parameters of the material.
  23632. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23633. */
  23634. emissiveFresnelParameters: FresnelParameters;
  23635. private _useReflectionFresnelFromSpecular;
  23636. /**
  23637. * If true automatically deducts the fresnels values from the material specularity.
  23638. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23639. */
  23640. useReflectionFresnelFromSpecular: boolean;
  23641. private _useGlossinessFromSpecularMapAlpha;
  23642. /**
  23643. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  23644. */
  23645. useGlossinessFromSpecularMapAlpha: boolean;
  23646. private _maxSimultaneousLights;
  23647. /**
  23648. * Defines the maximum number of lights that can be used in the material
  23649. */
  23650. maxSimultaneousLights: number;
  23651. private _invertNormalMapX;
  23652. /**
  23653. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23654. */
  23655. invertNormalMapX: boolean;
  23656. private _invertNormalMapY;
  23657. /**
  23658. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23659. */
  23660. invertNormalMapY: boolean;
  23661. private _twoSidedLighting;
  23662. /**
  23663. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23664. */
  23665. twoSidedLighting: boolean;
  23666. /**
  23667. * Default configuration related to image processing available in the standard Material.
  23668. */
  23669. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23670. /**
  23671. * Gets the image processing configuration used either in this material.
  23672. */
  23673. /**
  23674. * Sets the Default image processing configuration used either in the this material.
  23675. *
  23676. * If sets to null, the scene one is in use.
  23677. */
  23678. imageProcessingConfiguration: ImageProcessingConfiguration;
  23679. /**
  23680. * Keep track of the image processing observer to allow dispose and replace.
  23681. */
  23682. private _imageProcessingObserver;
  23683. /**
  23684. * Attaches a new image processing configuration to the Standard Material.
  23685. * @param configuration
  23686. */
  23687. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23688. /**
  23689. * Gets wether the color curves effect is enabled.
  23690. */
  23691. /**
  23692. * Sets wether the color curves effect is enabled.
  23693. */
  23694. cameraColorCurvesEnabled: boolean;
  23695. /**
  23696. * Gets wether the color grading effect is enabled.
  23697. */
  23698. /**
  23699. * Gets wether the color grading effect is enabled.
  23700. */
  23701. cameraColorGradingEnabled: boolean;
  23702. /**
  23703. * Gets wether tonemapping is enabled or not.
  23704. */
  23705. /**
  23706. * Sets wether tonemapping is enabled or not
  23707. */
  23708. cameraToneMappingEnabled: boolean;
  23709. /**
  23710. * The camera exposure used on this material.
  23711. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23712. * This corresponds to a photographic exposure.
  23713. */
  23714. /**
  23715. * The camera exposure used on this material.
  23716. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23717. * This corresponds to a photographic exposure.
  23718. */
  23719. cameraExposure: number;
  23720. /**
  23721. * Gets The camera contrast used on this material.
  23722. */
  23723. /**
  23724. * Sets The camera contrast used on this material.
  23725. */
  23726. cameraContrast: number;
  23727. /**
  23728. * Gets the Color Grading 2D Lookup Texture.
  23729. */
  23730. /**
  23731. * Sets the Color Grading 2D Lookup Texture.
  23732. */
  23733. cameraColorGradingTexture: Nullable<BaseTexture>;
  23734. /**
  23735. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23736. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23737. * 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;
  23738. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23739. */
  23740. /**
  23741. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23742. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23743. * 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;
  23744. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23745. */
  23746. cameraColorCurves: Nullable<ColorCurves>;
  23747. /**
  23748. * Custom callback helping to override the default shader used in the material.
  23749. */
  23750. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  23751. protected _renderTargets: SmartArray<RenderTargetTexture>;
  23752. protected _worldViewProjectionMatrix: Matrix;
  23753. protected _globalAmbientColor: Color3;
  23754. protected _useLogarithmicDepth: boolean;
  23755. /**
  23756. * Instantiates a new standard material.
  23757. * This is the default material used in Babylon. It is the best trade off between quality
  23758. * and performances.
  23759. * @see http://doc.babylonjs.com/babylon101/materials
  23760. * @param name Define the name of the material in the scene
  23761. * @param scene Define the scene the material belong to
  23762. */
  23763. constructor(name: string, scene: Scene);
  23764. /**
  23765. * Gets a boolean indicating that current material needs to register RTT
  23766. */
  23767. readonly hasRenderTargetTextures: boolean;
  23768. /**
  23769. * Gets the current class name of the material e.g. "StandardMaterial"
  23770. * Mainly use in serialization.
  23771. * @returns the class name
  23772. */
  23773. getClassName(): string;
  23774. /**
  23775. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  23776. * You can try switching to logarithmic depth.
  23777. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  23778. */
  23779. useLogarithmicDepth: boolean;
  23780. /**
  23781. * Specifies if the material will require alpha blending
  23782. * @returns a boolean specifying if alpha blending is needed
  23783. */
  23784. needAlphaBlending(): boolean;
  23785. /**
  23786. * Specifies if this material should be rendered in alpha test mode
  23787. * @returns a boolean specifying if an alpha test is needed.
  23788. */
  23789. needAlphaTesting(): boolean;
  23790. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  23791. /**
  23792. * Get the texture used for alpha test purpose.
  23793. * @returns the diffuse texture in case of the standard material.
  23794. */
  23795. getAlphaTestTexture(): Nullable<BaseTexture>;
  23796. /**
  23797. * Get if the submesh is ready to be used and all its information available.
  23798. * Child classes can use it to update shaders
  23799. * @param mesh defines the mesh to check
  23800. * @param subMesh defines which submesh to check
  23801. * @param useInstances specifies that instances should be used
  23802. * @returns a boolean indicating that the submesh is ready or not
  23803. */
  23804. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23805. /**
  23806. * Builds the material UBO layouts.
  23807. * Used internally during the effect preparation.
  23808. */
  23809. buildUniformLayout(): void;
  23810. /**
  23811. * Unbinds the material from the mesh
  23812. */
  23813. unbind(): void;
  23814. /**
  23815. * Binds the submesh to this material by preparing the effect and shader to draw
  23816. * @param world defines the world transformation matrix
  23817. * @param mesh defines the mesh containing the submesh
  23818. * @param subMesh defines the submesh to bind the material to
  23819. */
  23820. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23821. /**
  23822. * Get the list of animatables in the material.
  23823. * @returns the list of animatables object used in the material
  23824. */
  23825. getAnimatables(): IAnimatable[];
  23826. /**
  23827. * Gets the active textures from the material
  23828. * @returns an array of textures
  23829. */
  23830. getActiveTextures(): BaseTexture[];
  23831. /**
  23832. * Specifies if the material uses a texture
  23833. * @param texture defines the texture to check against the material
  23834. * @returns a boolean specifying if the material uses the texture
  23835. */
  23836. hasTexture(texture: BaseTexture): boolean;
  23837. /**
  23838. * Disposes the material
  23839. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23840. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23841. */
  23842. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23843. /**
  23844. * Makes a duplicate of the material, and gives it a new name
  23845. * @param name defines the new name for the duplicated material
  23846. * @returns the cloned material
  23847. */
  23848. clone(name: string): StandardMaterial;
  23849. /**
  23850. * Serializes this material in a JSON representation
  23851. * @returns the serialized material object
  23852. */
  23853. serialize(): any;
  23854. /**
  23855. * Creates a standard material from parsed material data
  23856. * @param source defines the JSON represnetation of the material
  23857. * @param scene defines the hosting scene
  23858. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23859. * @returns a new material
  23860. */
  23861. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  23862. private static _DiffuseTextureEnabled;
  23863. /**
  23864. * Are diffuse textures enabled in the application.
  23865. */
  23866. static DiffuseTextureEnabled: boolean;
  23867. private static _AmbientTextureEnabled;
  23868. /**
  23869. * Are ambient textures enabled in the application.
  23870. */
  23871. static AmbientTextureEnabled: boolean;
  23872. private static _OpacityTextureEnabled;
  23873. /**
  23874. * Are opacity textures enabled in the application.
  23875. */
  23876. static OpacityTextureEnabled: boolean;
  23877. private static _ReflectionTextureEnabled;
  23878. /**
  23879. * Are reflection textures enabled in the application.
  23880. */
  23881. static ReflectionTextureEnabled: boolean;
  23882. private static _EmissiveTextureEnabled;
  23883. /**
  23884. * Are emissive textures enabled in the application.
  23885. */
  23886. static EmissiveTextureEnabled: boolean;
  23887. private static _SpecularTextureEnabled;
  23888. /**
  23889. * Are specular textures enabled in the application.
  23890. */
  23891. static SpecularTextureEnabled: boolean;
  23892. private static _BumpTextureEnabled;
  23893. /**
  23894. * Are bump textures enabled in the application.
  23895. */
  23896. static BumpTextureEnabled: boolean;
  23897. private static _LightmapTextureEnabled;
  23898. /**
  23899. * Are lightmap textures enabled in the application.
  23900. */
  23901. static LightmapTextureEnabled: boolean;
  23902. private static _RefractionTextureEnabled;
  23903. /**
  23904. * Are refraction textures enabled in the application.
  23905. */
  23906. static RefractionTextureEnabled: boolean;
  23907. private static _ColorGradingTextureEnabled;
  23908. /**
  23909. * Are color grading textures enabled in the application.
  23910. */
  23911. static ColorGradingTextureEnabled: boolean;
  23912. private static _FresnelEnabled;
  23913. /**
  23914. * Are fresnels enabled in the application.
  23915. */
  23916. static FresnelEnabled: boolean;
  23917. }
  23918. }
  23919. declare module BABYLON {
  23920. /**
  23921. * Uniform buffer objects.
  23922. *
  23923. * Handles blocks of uniform on the GPU.
  23924. *
  23925. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  23926. *
  23927. * For more information, please refer to :
  23928. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  23929. */
  23930. class UniformBuffer {
  23931. private _engine;
  23932. private _buffer;
  23933. private _data;
  23934. private _bufferData;
  23935. private _dynamic?;
  23936. private _uniformLocations;
  23937. private _uniformSizes;
  23938. private _uniformLocationPointer;
  23939. private _needSync;
  23940. private _noUBO;
  23941. private _currentEffect;
  23942. private static _MAX_UNIFORM_SIZE;
  23943. private static _tempBuffer;
  23944. /**
  23945. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  23946. * This is dynamic to allow compat with webgl 1 and 2.
  23947. * You will need to pass the name of the uniform as well as the value.
  23948. */
  23949. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  23950. /**
  23951. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  23952. * This is dynamic to allow compat with webgl 1 and 2.
  23953. * You will need to pass the name of the uniform as well as the value.
  23954. */
  23955. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  23956. /**
  23957. * Lambda to Update a single float in a uniform buffer.
  23958. * This is dynamic to allow compat with webgl 1 and 2.
  23959. * You will need to pass the name of the uniform as well as the value.
  23960. */
  23961. updateFloat: (name: string, x: number) => void;
  23962. /**
  23963. * Lambda to Update a vec2 of float in a uniform buffer.
  23964. * This is dynamic to allow compat with webgl 1 and 2.
  23965. * You will need to pass the name of the uniform as well as the value.
  23966. */
  23967. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  23968. /**
  23969. * Lambda to Update a vec3 of float in a uniform buffer.
  23970. * This is dynamic to allow compat with webgl 1 and 2.
  23971. * You will need to pass the name of the uniform as well as the value.
  23972. */
  23973. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  23974. /**
  23975. * Lambda to Update a vec4 of float in a uniform buffer.
  23976. * This is dynamic to allow compat with webgl 1 and 2.
  23977. * You will need to pass the name of the uniform as well as the value.
  23978. */
  23979. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  23980. /**
  23981. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  23982. * This is dynamic to allow compat with webgl 1 and 2.
  23983. * You will need to pass the name of the uniform as well as the value.
  23984. */
  23985. updateMatrix: (name: string, mat: Matrix) => void;
  23986. /**
  23987. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  23988. * This is dynamic to allow compat with webgl 1 and 2.
  23989. * You will need to pass the name of the uniform as well as the value.
  23990. */
  23991. updateVector3: (name: string, vector: Vector3) => void;
  23992. /**
  23993. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  23994. * This is dynamic to allow compat with webgl 1 and 2.
  23995. * You will need to pass the name of the uniform as well as the value.
  23996. */
  23997. updateVector4: (name: string, vector: Vector4) => void;
  23998. /**
  23999. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  24000. * This is dynamic to allow compat with webgl 1 and 2.
  24001. * You will need to pass the name of the uniform as well as the value.
  24002. */
  24003. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  24004. /**
  24005. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  24006. * This is dynamic to allow compat with webgl 1 and 2.
  24007. * You will need to pass the name of the uniform as well as the value.
  24008. */
  24009. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  24010. /**
  24011. * Instantiates a new Uniform buffer objects.
  24012. *
  24013. * Handles blocks of uniform on the GPU.
  24014. *
  24015. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24016. *
  24017. * For more information, please refer to :
  24018. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24019. * @param engine Define the engine the buffer is associated with
  24020. * @param data Define the data contained in the buffer
  24021. * @param dynamic Define if the buffer is updatable
  24022. */
  24023. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  24024. /**
  24025. * Indicates if the buffer is using the WebGL2 UBO implementation,
  24026. * or just falling back on setUniformXXX calls.
  24027. */
  24028. readonly useUbo: boolean;
  24029. /**
  24030. * Indicates if the WebGL underlying uniform buffer is in sync
  24031. * with the javascript cache data.
  24032. */
  24033. readonly isSync: boolean;
  24034. /**
  24035. * Indicates if the WebGL underlying uniform buffer is dynamic.
  24036. * Also, a dynamic UniformBuffer will disable cache verification and always
  24037. * update the underlying WebGL uniform buffer to the GPU.
  24038. * @returns if Dynamic, otherwise false
  24039. */
  24040. isDynamic(): boolean;
  24041. /**
  24042. * The data cache on JS side.
  24043. * @returns the underlying data as a float array
  24044. */
  24045. getData(): Float32Array;
  24046. /**
  24047. * The underlying WebGL Uniform buffer.
  24048. * @returns the webgl buffer
  24049. */
  24050. getBuffer(): Nullable<WebGLBuffer>;
  24051. /**
  24052. * std140 layout specifies how to align data within an UBO structure.
  24053. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  24054. * for specs.
  24055. */
  24056. private _fillAlignment;
  24057. /**
  24058. * Adds an uniform in the buffer.
  24059. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  24060. * for the layout to be correct !
  24061. * @param name Name of the uniform, as used in the uniform block in the shader.
  24062. * @param size Data size, or data directly.
  24063. */
  24064. addUniform(name: string, size: number | number[]): void;
  24065. /**
  24066. * Adds a Matrix 4x4 to the uniform buffer.
  24067. * @param name Name of the uniform, as used in the uniform block in the shader.
  24068. * @param mat A 4x4 matrix.
  24069. */
  24070. addMatrix(name: string, mat: Matrix): void;
  24071. /**
  24072. * Adds a vec2 to the uniform buffer.
  24073. * @param name Name of the uniform, as used in the uniform block in the shader.
  24074. * @param x Define the x component value of the vec2
  24075. * @param y Define the y component value of the vec2
  24076. */
  24077. addFloat2(name: string, x: number, y: number): void;
  24078. /**
  24079. * Adds a vec3 to the uniform buffer.
  24080. * @param name Name of the uniform, as used in the uniform block in the shader.
  24081. * @param x Define the x component value of the vec3
  24082. * @param y Define the y component value of the vec3
  24083. * @param z Define the z component value of the vec3
  24084. */
  24085. addFloat3(name: string, x: number, y: number, z: number): void;
  24086. /**
  24087. * Adds a vec3 to the uniform buffer.
  24088. * @param name Name of the uniform, as used in the uniform block in the shader.
  24089. * @param color Define the vec3 from a Color
  24090. */
  24091. addColor3(name: string, color: Color3): void;
  24092. /**
  24093. * Adds a vec4 to the uniform buffer.
  24094. * @param name Name of the uniform, as used in the uniform block in the shader.
  24095. * @param color Define the rgb components from a Color
  24096. * @param alpha Define the a component of the vec4
  24097. */
  24098. addColor4(name: string, color: Color3, alpha: number): void;
  24099. /**
  24100. * Adds a vec3 to the uniform buffer.
  24101. * @param name Name of the uniform, as used in the uniform block in the shader.
  24102. * @param vector Define the vec3 components from a Vector
  24103. */
  24104. addVector3(name: string, vector: Vector3): void;
  24105. /**
  24106. * Adds a Matrix 3x3 to the uniform buffer.
  24107. * @param name Name of the uniform, as used in the uniform block in the shader.
  24108. */
  24109. addMatrix3x3(name: string): void;
  24110. /**
  24111. * Adds a Matrix 2x2 to the uniform buffer.
  24112. * @param name Name of the uniform, as used in the uniform block in the shader.
  24113. */
  24114. addMatrix2x2(name: string): void;
  24115. /**
  24116. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  24117. */
  24118. create(): void;
  24119. /** @hidden */
  24120. _rebuild(): void;
  24121. /**
  24122. * Updates the WebGL Uniform Buffer on the GPU.
  24123. * If the `dynamic` flag is set to true, no cache comparison is done.
  24124. * Otherwise, the buffer will be updated only if the cache differs.
  24125. */
  24126. update(): void;
  24127. /**
  24128. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  24129. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24130. * @param data Define the flattened data
  24131. * @param size Define the size of the data.
  24132. */
  24133. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  24134. private _updateMatrix3x3ForUniform;
  24135. private _updateMatrix3x3ForEffect;
  24136. private _updateMatrix2x2ForEffect;
  24137. private _updateMatrix2x2ForUniform;
  24138. private _updateFloatForEffect;
  24139. private _updateFloatForUniform;
  24140. private _updateFloat2ForEffect;
  24141. private _updateFloat2ForUniform;
  24142. private _updateFloat3ForEffect;
  24143. private _updateFloat3ForUniform;
  24144. private _updateFloat4ForEffect;
  24145. private _updateFloat4ForUniform;
  24146. private _updateMatrixForEffect;
  24147. private _updateMatrixForUniform;
  24148. private _updateVector3ForEffect;
  24149. private _updateVector3ForUniform;
  24150. private _updateVector4ForEffect;
  24151. private _updateVector4ForUniform;
  24152. private _updateColor3ForEffect;
  24153. private _updateColor3ForUniform;
  24154. private _updateColor4ForEffect;
  24155. private _updateColor4ForUniform;
  24156. /**
  24157. * Sets a sampler uniform on the effect.
  24158. * @param name Define the name of the sampler.
  24159. * @param texture Define the texture to set in the sampler
  24160. */
  24161. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  24162. /**
  24163. * Directly updates the value of the uniform in the cache AND on the GPU.
  24164. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24165. * @param data Define the flattened data
  24166. */
  24167. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  24168. /**
  24169. * Binds this uniform buffer to an effect.
  24170. * @param effect Define the effect to bind the buffer to
  24171. * @param name Name of the uniform block in the shader.
  24172. */
  24173. bindToEffect(effect: Effect, name: string): void;
  24174. /**
  24175. * Disposes the uniform buffer.
  24176. */
  24177. dispose(): void;
  24178. }
  24179. }
  24180. declare module BABYLON {
  24181. /**
  24182. * Defines a target to use with MorphTargetManager
  24183. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24184. */
  24185. class MorphTarget implements IAnimatable {
  24186. /** defines the name of the target */
  24187. name: string;
  24188. /**
  24189. * Gets or sets the list of animations
  24190. */
  24191. animations: Animation[];
  24192. private _scene;
  24193. private _positions;
  24194. private _normals;
  24195. private _tangents;
  24196. private _influence;
  24197. /**
  24198. * Observable raised when the influence changes
  24199. */
  24200. onInfluenceChanged: Observable<boolean>;
  24201. /** @hidden */
  24202. _onDataLayoutChanged: Observable<void>;
  24203. /**
  24204. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24205. */
  24206. influence: number;
  24207. /**
  24208. * Gets or sets the id of the morph Target
  24209. */
  24210. id: string;
  24211. private _animationPropertiesOverride;
  24212. /**
  24213. * Gets or sets the animation properties override
  24214. */
  24215. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24216. /**
  24217. * Creates a new MorphTarget
  24218. * @param name defines the name of the target
  24219. * @param influence defines the influence to use
  24220. */
  24221. constructor(
  24222. /** defines the name of the target */
  24223. name: string, influence?: number, scene?: Nullable<Scene>);
  24224. /**
  24225. * Gets a boolean defining if the target contains position data
  24226. */
  24227. readonly hasPositions: boolean;
  24228. /**
  24229. * Gets a boolean defining if the target contains normal data
  24230. */
  24231. readonly hasNormals: boolean;
  24232. /**
  24233. * Gets a boolean defining if the target contains tangent data
  24234. */
  24235. readonly hasTangents: boolean;
  24236. /**
  24237. * Affects position data to this target
  24238. * @param data defines the position data to use
  24239. */
  24240. setPositions(data: Nullable<FloatArray>): void;
  24241. /**
  24242. * Gets the position data stored in this target
  24243. * @returns a FloatArray containing the position data (or null if not present)
  24244. */
  24245. getPositions(): Nullable<FloatArray>;
  24246. /**
  24247. * Affects normal data to this target
  24248. * @param data defines the normal data to use
  24249. */
  24250. setNormals(data: Nullable<FloatArray>): void;
  24251. /**
  24252. * Gets the normal data stored in this target
  24253. * @returns a FloatArray containing the normal data (or null if not present)
  24254. */
  24255. getNormals(): Nullable<FloatArray>;
  24256. /**
  24257. * Affects tangent data to this target
  24258. * @param data defines the tangent data to use
  24259. */
  24260. setTangents(data: Nullable<FloatArray>): void;
  24261. /**
  24262. * Gets the tangent data stored in this target
  24263. * @returns a FloatArray containing the tangent data (or null if not present)
  24264. */
  24265. getTangents(): Nullable<FloatArray>;
  24266. /**
  24267. * Serializes the current target into a Serialization object
  24268. * @returns the serialized object
  24269. */
  24270. serialize(): any;
  24271. /**
  24272. * Returns the string "MorphTarget"
  24273. * @returns "MorphTarget"
  24274. */
  24275. getClassName(): string;
  24276. /**
  24277. * Creates a new target from serialized data
  24278. * @param serializationObject defines the serialized data to use
  24279. * @returns a new MorphTarget
  24280. */
  24281. static Parse(serializationObject: any): MorphTarget;
  24282. /**
  24283. * Creates a MorphTarget from mesh data
  24284. * @param mesh defines the source mesh
  24285. * @param name defines the name to use for the new target
  24286. * @param influence defines the influence to attach to the target
  24287. * @returns a new MorphTarget
  24288. */
  24289. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24290. }
  24291. }
  24292. declare module BABYLON {
  24293. /**
  24294. * This class is used to deform meshes using morphing between different targets
  24295. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24296. */
  24297. class MorphTargetManager {
  24298. private _targets;
  24299. private _targetInfluenceChangedObservers;
  24300. private _targetDataLayoutChangedObservers;
  24301. private _activeTargets;
  24302. private _scene;
  24303. private _influences;
  24304. private _supportsNormals;
  24305. private _supportsTangents;
  24306. private _vertexCount;
  24307. private _uniqueId;
  24308. private _tempInfluences;
  24309. /**
  24310. * Creates a new MorphTargetManager
  24311. * @param scene defines the current scene
  24312. */
  24313. constructor(scene?: Nullable<Scene>);
  24314. /**
  24315. * Gets the unique ID of this manager
  24316. */
  24317. readonly uniqueId: number;
  24318. /**
  24319. * Gets the number of vertices handled by this manager
  24320. */
  24321. readonly vertexCount: number;
  24322. /**
  24323. * Gets a boolean indicating if this manager supports morphing of normals
  24324. */
  24325. readonly supportsNormals: boolean;
  24326. /**
  24327. * Gets a boolean indicating if this manager supports morphing of tangents
  24328. */
  24329. readonly supportsTangents: boolean;
  24330. /**
  24331. * Gets the number of targets stored in this manager
  24332. */
  24333. readonly numTargets: number;
  24334. /**
  24335. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24336. */
  24337. readonly numInfluencers: number;
  24338. /**
  24339. * Gets the list of influences (one per target)
  24340. */
  24341. readonly influences: Float32Array;
  24342. /**
  24343. * Gets the active target at specified index. An active target is a target with an influence > 0
  24344. * @param index defines the index to check
  24345. * @returns the requested target
  24346. */
  24347. getActiveTarget(index: number): MorphTarget;
  24348. /**
  24349. * Gets the target at specified index
  24350. * @param index defines the index to check
  24351. * @returns the requested target
  24352. */
  24353. getTarget(index: number): MorphTarget;
  24354. /**
  24355. * Add a new target to this manager
  24356. * @param target defines the target to add
  24357. */
  24358. addTarget(target: MorphTarget): void;
  24359. /**
  24360. * Removes a target from the manager
  24361. * @param target defines the target to remove
  24362. */
  24363. removeTarget(target: MorphTarget): void;
  24364. /**
  24365. * Serializes the current manager into a Serialization object
  24366. * @returns the serialized object
  24367. */
  24368. serialize(): any;
  24369. private _syncActiveTargets;
  24370. /**
  24371. * Syncrhonize the targets with all the meshes using this morph target manager
  24372. */
  24373. synchronize(): void;
  24374. /**
  24375. * Creates a new MorphTargetManager from serialized data
  24376. * @param serializationObject defines the serialized data
  24377. * @param scene defines the hosting scene
  24378. * @returns the new MorphTargetManager
  24379. */
  24380. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24381. }
  24382. }
  24383. declare module BABYLON {
  24384. /**
  24385. * Class used to store all common mesh properties
  24386. */
  24387. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24388. /** No occlusion */
  24389. static OCCLUSION_TYPE_NONE: number;
  24390. /** Occlusion set to optimisitic */
  24391. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24392. /** Occlusion set to strict */
  24393. static OCCLUSION_TYPE_STRICT: number;
  24394. /** Use an accurante occlusion algorithm */
  24395. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24396. /** Use a conservative occlusion algorithm */
  24397. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24398. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24399. static readonly CULLINGSTRATEGY_STANDARD: number;
  24400. /** Culling strategy with bounding sphere only and then frustum culling */
  24401. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24402. /**
  24403. * No billboard
  24404. */
  24405. static readonly BILLBOARDMODE_NONE: number;
  24406. /** Billboard on X axis */
  24407. static readonly BILLBOARDMODE_X: number;
  24408. /** Billboard on Y axis */
  24409. static readonly BILLBOARDMODE_Y: number;
  24410. /** Billboard on Z axis */
  24411. static readonly BILLBOARDMODE_Z: number;
  24412. /** Billboard on all axes */
  24413. static readonly BILLBOARDMODE_ALL: number;
  24414. private _facetData;
  24415. /** Gets ot sets the culling strategy to use to find visible meshes */
  24416. cullingStrategy: number;
  24417. /**
  24418. * Gets the number of facets in the mesh
  24419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24420. */
  24421. readonly facetNb: number;
  24422. /**
  24423. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24425. */
  24426. partitioningSubdivisions: number;
  24427. /**
  24428. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24429. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24430. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24431. */
  24432. partitioningBBoxRatio: number;
  24433. /**
  24434. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24435. * Works only for updatable meshes.
  24436. * Doesn't work with multi-materials
  24437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24438. */
  24439. mustDepthSortFacets: boolean;
  24440. /**
  24441. * The location (Vector3) where the facet depth sort must be computed from.
  24442. * By default, the active camera position.
  24443. * Used only when facet depth sort is enabled
  24444. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24445. */
  24446. facetDepthSortFrom: Vector3;
  24447. /**
  24448. * gets a boolean indicating if facetData is enabled
  24449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24450. */
  24451. readonly isFacetDataEnabled: boolean;
  24452. /** @hidden */
  24453. _updateNonUniformScalingState(value: boolean): boolean;
  24454. /**
  24455. * An event triggered when this mesh collides with another one
  24456. */
  24457. onCollideObservable: Observable<AbstractMesh>;
  24458. private _onCollideObserver;
  24459. /** Set a function to call when this mesh collides with another one */
  24460. onCollide: () => void;
  24461. /**
  24462. * An event triggered when the collision's position changes
  24463. */
  24464. onCollisionPositionChangeObservable: Observable<Vector3>;
  24465. private _onCollisionPositionChangeObserver;
  24466. /** Set a function to call when the collision's position changes */
  24467. onCollisionPositionChange: () => void;
  24468. /**
  24469. * An event triggered when material is changed
  24470. */
  24471. onMaterialChangedObservable: Observable<AbstractMesh>;
  24472. /**
  24473. * Gets or sets the orientation for POV movement & rotation
  24474. */
  24475. definedFacingForward: boolean;
  24476. /** @hidden */
  24477. _occlusionQuery: Nullable<WebGLQuery>;
  24478. private _visibility;
  24479. /**
  24480. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24481. */
  24482. /**
  24483. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24484. */
  24485. visibility: number;
  24486. /** Gets or sets the alpha index used to sort transparent meshes
  24487. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24488. */
  24489. alphaIndex: number;
  24490. /**
  24491. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24492. */
  24493. isVisible: boolean;
  24494. /**
  24495. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24496. */
  24497. isPickable: boolean;
  24498. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24499. showSubMeshesBoundingBox: boolean;
  24500. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24501. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24502. */
  24503. isBlocker: boolean;
  24504. /**
  24505. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24506. */
  24507. enablePointerMoveEvents: boolean;
  24508. /**
  24509. * Specifies the rendering group id for this mesh (0 by default)
  24510. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24511. */
  24512. renderingGroupId: number;
  24513. private _material;
  24514. /** Gets or sets current material */
  24515. material: Nullable<Material>;
  24516. private _receiveShadows;
  24517. /**
  24518. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24519. * @see http://doc.babylonjs.com/babylon101/shadows
  24520. */
  24521. receiveShadows: boolean;
  24522. /** Defines color to use when rendering outline */
  24523. outlineColor: Color3;
  24524. /** Define width to use when rendering outline */
  24525. outlineWidth: number;
  24526. /** Defines color to use when rendering overlay */
  24527. overlayColor: Color3;
  24528. /** Defines alpha to use when rendering overlay */
  24529. overlayAlpha: number;
  24530. private _hasVertexAlpha;
  24531. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24532. hasVertexAlpha: boolean;
  24533. private _useVertexColors;
  24534. /** 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) */
  24535. useVertexColors: boolean;
  24536. private _computeBonesUsingShaders;
  24537. /**
  24538. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24539. */
  24540. computeBonesUsingShaders: boolean;
  24541. private _numBoneInfluencers;
  24542. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24543. numBoneInfluencers: number;
  24544. private _applyFog;
  24545. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24546. applyFog: boolean;
  24547. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24548. useOctreeForRenderingSelection: boolean;
  24549. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24550. useOctreeForPicking: boolean;
  24551. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24552. useOctreeForCollisions: boolean;
  24553. private _layerMask;
  24554. /**
  24555. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24556. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24557. */
  24558. layerMask: number;
  24559. /**
  24560. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24561. */
  24562. alwaysSelectAsActiveMesh: boolean;
  24563. /**
  24564. * Gets or sets the current action manager
  24565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24566. */
  24567. actionManager: Nullable<ActionManager>;
  24568. private _checkCollisions;
  24569. private _collisionMask;
  24570. private _collisionGroup;
  24571. /**
  24572. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24573. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24574. */
  24575. ellipsoid: Vector3;
  24576. /**
  24577. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24578. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24579. */
  24580. ellipsoidOffset: Vector3;
  24581. private _collider;
  24582. private _oldPositionForCollisions;
  24583. private _diffPositionForCollisions;
  24584. /**
  24585. * Gets or sets a collision mask used to mask collisions (default is -1).
  24586. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24587. */
  24588. collisionMask: number;
  24589. /**
  24590. * Gets or sets the current collision group mask (-1 by default).
  24591. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24592. */
  24593. collisionGroup: number;
  24594. /**
  24595. * Defines edge width used when edgesRenderer is enabled
  24596. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24597. */
  24598. edgesWidth: number;
  24599. /**
  24600. * Defines edge color used when edgesRenderer is enabled
  24601. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24602. */
  24603. edgesColor: Color4;
  24604. /** @hidden */
  24605. _edgesRenderer: Nullable<IEdgesRenderer>;
  24606. /** @hidden */
  24607. _masterMesh: Nullable<AbstractMesh>;
  24608. /** @hidden */
  24609. _boundingInfo: Nullable<BoundingInfo>;
  24610. /** @hidden */
  24611. _renderId: number;
  24612. /**
  24613. * Gets or sets the list of subMeshes
  24614. * @see http://doc.babylonjs.com/how_to/multi_materials
  24615. */
  24616. subMeshes: SubMesh[];
  24617. /** @hidden */
  24618. _intersectionsInProgress: AbstractMesh[];
  24619. /** @hidden */
  24620. _unIndexed: boolean;
  24621. /** @hidden */
  24622. _lightSources: Light[];
  24623. /** @hidden */
  24624. readonly _positions: Nullable<Vector3[]>;
  24625. /** @hidden */
  24626. _waitingActions: any;
  24627. /** @hidden */
  24628. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24629. private _skeleton;
  24630. /** @hidden */
  24631. _bonesTransformMatrices: Nullable<Float32Array>;
  24632. /**
  24633. * Gets or sets a skeleton to apply skining transformations
  24634. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24635. */
  24636. skeleton: Nullable<Skeleton>;
  24637. /**
  24638. * An event triggered when the mesh is rebuilt.
  24639. */
  24640. onRebuildObservable: Observable<AbstractMesh>;
  24641. /**
  24642. * Creates a new AbstractMesh
  24643. * @param name defines the name of the mesh
  24644. * @param scene defines the hosting scene
  24645. */
  24646. constructor(name: string, scene?: Nullable<Scene>);
  24647. /**
  24648. * Returns the string "AbstractMesh"
  24649. * @returns "AbstractMesh"
  24650. */
  24651. getClassName(): string;
  24652. /**
  24653. * Gets a string representation of the current mesh
  24654. * @param fullDetails defines a boolean indicating if full details must be included
  24655. * @returns a string representation of the current mesh
  24656. */
  24657. toString(fullDetails?: boolean): string;
  24658. /** @hidden */
  24659. _rebuild(): void;
  24660. /** @hidden */
  24661. _resyncLightSources(): void;
  24662. /** @hidden */
  24663. _resyncLighSource(light: Light): void;
  24664. /** @hidden */
  24665. _unBindEffect(): void;
  24666. /** @hidden */
  24667. _removeLightSource(light: Light): void;
  24668. private _markSubMeshesAsDirty;
  24669. /** @hidden */
  24670. _markSubMeshesAsLightDirty(): void;
  24671. /** @hidden */
  24672. _markSubMeshesAsAttributesDirty(): void;
  24673. /** @hidden */
  24674. _markSubMeshesAsMiscDirty(): void;
  24675. /**
  24676. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24677. */
  24678. scaling: Vector3;
  24679. /**
  24680. * Returns true if the mesh is blocked. Implemented by child classes
  24681. */
  24682. readonly isBlocked: boolean;
  24683. /**
  24684. * Returns the mesh itself by default. Implemented by child classes
  24685. * @param camera defines the camera to use to pick the right LOD level
  24686. * @returns the currentAbstractMesh
  24687. */
  24688. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24689. /**
  24690. * Returns 0 by default. Implemented by child classes
  24691. * @returns an integer
  24692. */
  24693. getTotalVertices(): number;
  24694. /**
  24695. * Returns null by default. Implemented by child classes
  24696. * @returns null
  24697. */
  24698. getIndices(): Nullable<IndicesArray>;
  24699. /**
  24700. * Returns the array of the requested vertex data kind. Implemented by child classes
  24701. * @param kind defines the vertex data kind to use
  24702. * @returns null
  24703. */
  24704. getVerticesData(kind: string): Nullable<FloatArray>;
  24705. /**
  24706. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24707. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24708. * Note that a new underlying VertexBuffer object is created each call.
  24709. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24710. * @param kind defines vertex data kind:
  24711. * * BABYLON.VertexBuffer.PositionKind
  24712. * * BABYLON.VertexBuffer.UVKind
  24713. * * BABYLON.VertexBuffer.UV2Kind
  24714. * * BABYLON.VertexBuffer.UV3Kind
  24715. * * BABYLON.VertexBuffer.UV4Kind
  24716. * * BABYLON.VertexBuffer.UV5Kind
  24717. * * BABYLON.VertexBuffer.UV6Kind
  24718. * * BABYLON.VertexBuffer.ColorKind
  24719. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24720. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24721. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24722. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24723. * @param data defines the data source
  24724. * @param updatable defines if the data must be flagged as updatable (or static)
  24725. * @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
  24726. * @returns the current mesh
  24727. */
  24728. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24729. /**
  24730. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24731. * If the mesh has no geometry, it is simply returned as it is.
  24732. * @param kind defines vertex data kind:
  24733. * * BABYLON.VertexBuffer.PositionKind
  24734. * * BABYLON.VertexBuffer.UVKind
  24735. * * BABYLON.VertexBuffer.UV2Kind
  24736. * * BABYLON.VertexBuffer.UV3Kind
  24737. * * BABYLON.VertexBuffer.UV4Kind
  24738. * * BABYLON.VertexBuffer.UV5Kind
  24739. * * BABYLON.VertexBuffer.UV6Kind
  24740. * * BABYLON.VertexBuffer.ColorKind
  24741. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24742. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24743. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24744. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24745. * @param data defines the data source
  24746. * @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
  24747. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24748. * @returns the current mesh
  24749. */
  24750. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24751. /**
  24752. * Sets the mesh indices,
  24753. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24754. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24755. * @param totalVertices Defines the total number of vertices
  24756. * @returns the current mesh
  24757. */
  24758. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24759. /**
  24760. * Gets a boolean indicating if specific vertex data is present
  24761. * @param kind defines the vertex data kind to use
  24762. * @returns true is data kind is present
  24763. */
  24764. isVerticesDataPresent(kind: string): boolean;
  24765. /**
  24766. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24767. * @returns a BoundingInfo
  24768. */
  24769. getBoundingInfo(): BoundingInfo;
  24770. /**
  24771. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24772. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24773. * @returns the current mesh
  24774. */
  24775. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24776. /**
  24777. * Overwrite the current bounding info
  24778. * @param boundingInfo defines the new bounding info
  24779. * @returns the current mesh
  24780. */
  24781. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24782. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24783. readonly useBones: boolean;
  24784. /** @hidden */
  24785. _preActivate(): void;
  24786. /** @hidden */
  24787. _preActivateForIntermediateRendering(renderId: number): void;
  24788. /** @hidden */
  24789. _activate(renderId: number): void;
  24790. /**
  24791. * Gets the current world matrix
  24792. * @returns a Matrix
  24793. */
  24794. getWorldMatrix(): Matrix;
  24795. /** @hidden */
  24796. _getWorldMatrixDeterminant(): number;
  24797. /**
  24798. * Perform relative position change from the point of view of behind the front of the mesh.
  24799. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24800. * Supports definition of mesh facing forward or backward
  24801. * @param amountRight defines the distance on the right axis
  24802. * @param amountUp defines the distance on the up axis
  24803. * @param amountForward defines the distance on the forward axis
  24804. * @returns the current mesh
  24805. */
  24806. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24807. /**
  24808. * Calculate relative position change from the point of view of behind the front of the mesh.
  24809. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24810. * Supports definition of mesh facing forward or backward
  24811. * @param amountRight defines the distance on the right axis
  24812. * @param amountUp defines the distance on the up axis
  24813. * @param amountForward defines the distance on the forward axis
  24814. * @returns the new displacement vector
  24815. */
  24816. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24817. /**
  24818. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24819. * Supports definition of mesh facing forward or backward
  24820. * @param flipBack defines the flip
  24821. * @param twirlClockwise defines the twirl
  24822. * @param tiltRight defines the tilt
  24823. * @returns the current mesh
  24824. */
  24825. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24826. /**
  24827. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24828. * Supports definition of mesh facing forward or backward.
  24829. * @param flipBack defines the flip
  24830. * @param twirlClockwise defines the twirl
  24831. * @param tiltRight defines the tilt
  24832. * @returns the new rotation vector
  24833. */
  24834. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24835. /**
  24836. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24837. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24838. * @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
  24839. * @returns the new bounding vectors
  24840. */
  24841. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24842. min: Vector3;
  24843. max: Vector3;
  24844. };
  24845. /**
  24846. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24847. * This means the mesh underlying bounding box and sphere are recomputed.
  24848. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24849. * @returns the current mesh
  24850. */
  24851. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24852. /** @hidden */
  24853. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24854. /** @hidden */
  24855. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24856. /** @hidden */
  24857. _updateBoundingInfo(): AbstractMesh;
  24858. /** @hidden */
  24859. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24860. /** @hidden */
  24861. protected _afterComputeWorldMatrix(): void;
  24862. /**
  24863. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24864. * A mesh is in the frustum if its bounding box intersects the frustum
  24865. * @param frustumPlanes defines the frustum to test
  24866. * @returns true if the mesh is in the frustum planes
  24867. */
  24868. isInFrustum(frustumPlanes: Plane[]): boolean;
  24869. /**
  24870. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24871. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24872. * @param frustumPlanes defines the frustum to test
  24873. * @returns true if the mesh is completely in the frustum planes
  24874. */
  24875. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24876. /**
  24877. * True if the mesh intersects another mesh or a SolidParticle object
  24878. * @param mesh defines a target mesh or SolidParticle to test
  24879. * @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)
  24880. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24881. * @returns true if there is an intersection
  24882. */
  24883. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24884. /**
  24885. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24886. * @param point defines the point to test
  24887. * @returns true if there is an intersection
  24888. */
  24889. intersectsPoint(point: Vector3): boolean;
  24890. /**
  24891. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24892. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24893. */
  24894. checkCollisions: boolean;
  24895. /**
  24896. * Gets Collider object used to compute collisions (not physics)
  24897. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24898. */
  24899. readonly collider: Collider;
  24900. /**
  24901. * Move the mesh using collision engine
  24902. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24903. * @param displacement defines the requested displacement vector
  24904. * @returns the current mesh
  24905. */
  24906. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24907. private _onCollisionPositionChange;
  24908. /** @hidden */
  24909. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24910. /** @hidden */
  24911. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24912. /** @hidden */
  24913. _checkCollision(collider: Collider): AbstractMesh;
  24914. /** @hidden */
  24915. _generatePointsArray(): boolean;
  24916. /**
  24917. * Checks if the passed Ray intersects with the mesh
  24918. * @param ray defines the ray to use
  24919. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24920. * @returns the picking info
  24921. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24922. */
  24923. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24924. /**
  24925. * Clones the current mesh
  24926. * @param name defines the mesh name
  24927. * @param newParent defines the new mesh parent
  24928. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24929. * @returns the new mesh
  24930. */
  24931. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24932. /**
  24933. * Disposes all the submeshes of the current meshnp
  24934. * @returns the current mesh
  24935. */
  24936. releaseSubMeshes(): AbstractMesh;
  24937. /**
  24938. * Releases resources associated with this abstract mesh.
  24939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24941. */
  24942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24943. /**
  24944. * Adds the passed mesh as a child to the current mesh
  24945. * @param mesh defines the child mesh
  24946. * @returns the current mesh
  24947. */
  24948. addChild(mesh: AbstractMesh): AbstractMesh;
  24949. /**
  24950. * Removes the passed mesh from the current mesh children list
  24951. * @param mesh defines the child mesh
  24952. * @returns the current mesh
  24953. */
  24954. removeChild(mesh: AbstractMesh): AbstractMesh;
  24955. /** @hidden */
  24956. private _initFacetData;
  24957. /**
  24958. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24959. * This method can be called within the render loop.
  24960. * 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
  24961. * @returns the current mesh
  24962. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24963. */
  24964. updateFacetData(): AbstractMesh;
  24965. /**
  24966. * Returns the facetLocalNormals array.
  24967. * The normals are expressed in the mesh local spac
  24968. * @returns an array of Vector3
  24969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24970. */
  24971. getFacetLocalNormals(): Vector3[];
  24972. /**
  24973. * Returns the facetLocalPositions array.
  24974. * The facet positions are expressed in the mesh local space
  24975. * @returns an array of Vector3
  24976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24977. */
  24978. getFacetLocalPositions(): Vector3[];
  24979. /**
  24980. * Returns the facetLocalPartioning array
  24981. * @returns an array of array of numbers
  24982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24983. */
  24984. getFacetLocalPartitioning(): number[][];
  24985. /**
  24986. * Returns the i-th facet position in the world system.
  24987. * This method allocates a new Vector3 per call
  24988. * @param i defines the facet index
  24989. * @returns a new Vector3
  24990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24991. */
  24992. getFacetPosition(i: number): Vector3;
  24993. /**
  24994. * Sets the reference Vector3 with the i-th facet position in the world system
  24995. * @param i defines the facet index
  24996. * @param ref defines the target vector
  24997. * @returns the current mesh
  24998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24999. */
  25000. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25001. /**
  25002. * Returns the i-th facet normal in the world system.
  25003. * This method allocates a new Vector3 per call
  25004. * @param i defines the facet index
  25005. * @returns a new Vector3
  25006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25007. */
  25008. getFacetNormal(i: number): Vector3;
  25009. /**
  25010. * Sets the reference Vector3 with the i-th facet normal in the world system
  25011. * @param i defines the facet index
  25012. * @param ref defines the target vector
  25013. * @returns the current mesh
  25014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25015. */
  25016. getFacetNormalToRef(i: number, ref: Vector3): this;
  25017. /**
  25018. * 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)
  25019. * @param x defines x coordinate
  25020. * @param y defines y coordinate
  25021. * @param z defines z coordinate
  25022. * @returns the array of facet indexes
  25023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25024. */
  25025. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25026. /**
  25027. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25028. * @param projected sets as the (x,y,z) world projection on the facet
  25029. * @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
  25030. * @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
  25031. * @param x defines x coordinate
  25032. * @param y defines y coordinate
  25033. * @param z defines z coordinate
  25034. * @returns the face index if found (or null instead)
  25035. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25036. */
  25037. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25038. /**
  25039. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25040. * @param projected sets as the (x,y,z) local projection on the facet
  25041. * @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
  25042. * @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
  25043. * @param x defines x coordinate
  25044. * @param y defines y coordinate
  25045. * @param z defines z coordinate
  25046. * @returns the face index if found (or null instead)
  25047. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25048. */
  25049. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25050. /**
  25051. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25052. * @returns the parameters
  25053. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25054. */
  25055. getFacetDataParameters(): any;
  25056. /**
  25057. * Disables the feature FacetData and frees the related memory
  25058. * @returns the current mesh
  25059. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25060. */
  25061. disableFacetData(): AbstractMesh;
  25062. /**
  25063. * Updates the AbstractMesh indices array
  25064. * @param indices defines the data source
  25065. * @returns the current mesh
  25066. */
  25067. updateIndices(indices: IndicesArray): AbstractMesh;
  25068. /**
  25069. * Creates new normals data for the mesh
  25070. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25071. * @returns the current mesh
  25072. */
  25073. createNormals(updatable: boolean): AbstractMesh;
  25074. /**
  25075. * Align the mesh with a normal
  25076. * @param normal defines the normal to use
  25077. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25078. * @returns the current mesh
  25079. */
  25080. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25081. /** @hidden */
  25082. _checkOcclusionQuery(): boolean;
  25083. }
  25084. }
  25085. declare module BABYLON {
  25086. /**
  25087. * Class used to store data that will be store in GPU memory
  25088. */
  25089. class Buffer {
  25090. private _engine;
  25091. private _buffer;
  25092. /** @hidden */
  25093. _data: Nullable<DataArray>;
  25094. private _updatable;
  25095. private _instanced;
  25096. /**
  25097. * Gets the byte stride.
  25098. */
  25099. readonly byteStride: number;
  25100. /**
  25101. * Constructor
  25102. * @param engine the engine
  25103. * @param data the data to use for this buffer
  25104. * @param updatable whether the data is updatable
  25105. * @param stride the stride (optional)
  25106. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25107. * @param instanced whether the buffer is instanced (optional)
  25108. * @param useBytes set to true if the stride in in bytes (optional)
  25109. */
  25110. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25111. /**
  25112. * Create a new VertexBuffer based on the current buffer
  25113. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25114. * @param offset defines offset in the buffer (0 by default)
  25115. * @param size defines the size in floats of attributes (position is 3 for instance)
  25116. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25117. * @param instanced defines if the vertex buffer contains indexed data
  25118. * @param useBytes defines if the offset and stride are in bytes
  25119. * @returns the new vertex buffer
  25120. */
  25121. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25122. /**
  25123. * Gets a boolean indicating if the Buffer is updatable?
  25124. * @returns true if the buffer is updatable
  25125. */
  25126. isUpdatable(): boolean;
  25127. /**
  25128. * Gets current buffer's data
  25129. * @returns a DataArray or null
  25130. */
  25131. getData(): Nullable<DataArray>;
  25132. /**
  25133. * Gets underlying native buffer
  25134. * @returns underlying native buffer
  25135. */
  25136. getBuffer(): Nullable<WebGLBuffer>;
  25137. /**
  25138. * Gets the stride in float32 units (i.e. byte stride / 4).
  25139. * May not be an integer if the byte stride is not divisible by 4.
  25140. * DEPRECATED. Use byteStride instead.
  25141. * @returns the stride in float32 units
  25142. */
  25143. getStrideSize(): number;
  25144. /**
  25145. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25146. * @param data defines the data to store
  25147. */
  25148. create(data?: Nullable<DataArray>): void;
  25149. /** @hidden */
  25150. _rebuild(): void;
  25151. /**
  25152. * Update current buffer data
  25153. * @param data defines the data to store
  25154. */
  25155. update(data: DataArray): void;
  25156. /**
  25157. * Updates the data directly.
  25158. * @param data the new data
  25159. * @param offset the new offset
  25160. * @param vertexCount the vertex count (optional)
  25161. * @param useBytes set to true if the offset is in bytes
  25162. */
  25163. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25164. /**
  25165. * Release all resources
  25166. */
  25167. dispose(): void;
  25168. }
  25169. }
  25170. declare module BABYLON {
  25171. /**
  25172. * Class for building Constructive Solid Geometry
  25173. */
  25174. class CSG {
  25175. private polygons;
  25176. /**
  25177. * The world matrix
  25178. */
  25179. matrix: Matrix;
  25180. /**
  25181. * Stores the position
  25182. */
  25183. position: Vector3;
  25184. /**
  25185. * Stores the rotation
  25186. */
  25187. rotation: Vector3;
  25188. /**
  25189. * Stores the rotation quaternion
  25190. */
  25191. rotationQuaternion: Nullable<Quaternion>;
  25192. /**
  25193. * Stores the scaling vector
  25194. */
  25195. scaling: Vector3;
  25196. /**
  25197. * Convert the BABYLON.Mesh to BABYLON.CSG
  25198. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25199. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25200. */
  25201. static FromMesh(mesh: Mesh): CSG;
  25202. /**
  25203. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25204. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25205. */
  25206. private static FromPolygons;
  25207. /**
  25208. * Clones, or makes a deep copy, of the BABYLON.CSG
  25209. * @returns A new BABYLON.CSG
  25210. */
  25211. clone(): CSG;
  25212. /**
  25213. * Unions this CSG with another CSG
  25214. * @param csg The CSG to union against this CSG
  25215. * @returns The unioned CSG
  25216. */
  25217. union(csg: CSG): CSG;
  25218. /**
  25219. * Unions this CSG with another CSG in place
  25220. * @param csg The CSG to union against this CSG
  25221. */
  25222. unionInPlace(csg: CSG): void;
  25223. /**
  25224. * Subtracts this CSG with another CSG
  25225. * @param csg The CSG to subtract against this CSG
  25226. * @returns A new BABYLON.CSG
  25227. */
  25228. subtract(csg: CSG): CSG;
  25229. /**
  25230. * Subtracts this CSG with another CSG in place
  25231. * @param csg The CSG to subtact against this CSG
  25232. */
  25233. subtractInPlace(csg: CSG): void;
  25234. /**
  25235. * Intersect this CSG with another CSG
  25236. * @param csg The CSG to intersect against this CSG
  25237. * @returns A new BABYLON.CSG
  25238. */
  25239. intersect(csg: CSG): CSG;
  25240. /**
  25241. * Intersects this CSG with another CSG in place
  25242. * @param csg The CSG to intersect against this CSG
  25243. */
  25244. intersectInPlace(csg: CSG): void;
  25245. /**
  25246. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25247. * not modified.
  25248. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25249. */
  25250. inverse(): CSG;
  25251. /**
  25252. * Inverses the BABYLON.CSG in place
  25253. */
  25254. inverseInPlace(): void;
  25255. /**
  25256. * This is used to keep meshes transformations so they can be restored
  25257. * when we build back a Babylon Mesh
  25258. * NB : All CSG operations are performed in world coordinates
  25259. * @param csg The BABYLON.CSG to copy the transform attributes from
  25260. * @returns This BABYLON.CSG
  25261. */
  25262. copyTransformAttributes(csg: CSG): CSG;
  25263. /**
  25264. * Build Raw mesh from CSG
  25265. * Coordinates here are in world space
  25266. * @param name The name of the mesh geometry
  25267. * @param scene The BABYLON.Scene
  25268. * @param keepSubMeshes Specifies if the submeshes should be kept
  25269. * @returns A new BABYLON.Mesh
  25270. */
  25271. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25272. /**
  25273. * Build Mesh from CSG taking material and transforms into account
  25274. * @param name The name of the BABYLON.Mesh
  25275. * @param material The material of the BABYLON.Mesh
  25276. * @param scene The BABYLON.Scene
  25277. * @param keepSubMeshes Specifies if submeshes should be kept
  25278. * @returns The new BABYLON.Mesh
  25279. */
  25280. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25281. }
  25282. }
  25283. declare module BABYLON {
  25284. /**
  25285. * Class used to store geometry data (vertex buffers + index buffer)
  25286. */
  25287. class Geometry implements IGetSetVerticesData {
  25288. /**
  25289. * Gets or sets the unique ID of the geometry
  25290. */
  25291. id: string;
  25292. /**
  25293. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25294. */
  25295. delayLoadState: number;
  25296. /**
  25297. * Gets the file containing the data to load when running in delay load state
  25298. */
  25299. delayLoadingFile: Nullable<string>;
  25300. /**
  25301. * Callback called when the geometry is updated
  25302. */
  25303. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25304. private _scene;
  25305. private _engine;
  25306. private _meshes;
  25307. private _totalVertices;
  25308. /** @hidden */
  25309. _indices: IndicesArray;
  25310. /** @hidden */
  25311. _vertexBuffers: {
  25312. [key: string]: VertexBuffer;
  25313. };
  25314. private _isDisposed;
  25315. private _extend;
  25316. private _boundingBias;
  25317. /** @hidden */
  25318. _delayInfo: Array<string>;
  25319. private _indexBuffer;
  25320. private _indexBufferIsUpdatable;
  25321. /** @hidden */
  25322. _boundingInfo: Nullable<BoundingInfo>;
  25323. /** @hidden */
  25324. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25325. /** @hidden */
  25326. _softwareSkinningFrameId: number;
  25327. private _vertexArrayObjects;
  25328. private _updatable;
  25329. /** @hidden */
  25330. _positions: Nullable<Vector3[]>;
  25331. /**
  25332. * 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
  25333. */
  25334. /**
  25335. * 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
  25336. */
  25337. boundingBias: Vector2;
  25338. /**
  25339. * Static function used to attach a new empty geometry to a mesh
  25340. * @param mesh defines the mesh to attach the geometry to
  25341. * @returns the new Geometry
  25342. */
  25343. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25344. /**
  25345. * Creates a new geometry
  25346. * @param id defines the unique ID
  25347. * @param scene defines the hosting scene
  25348. * @param vertexData defines the VertexData used to get geometry data
  25349. * @param updatable defines if geometry must be updatable (false by default)
  25350. * @param mesh defines the mesh that will be associated with the geometry
  25351. */
  25352. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25353. /**
  25354. * Gets the current extend of the geometry
  25355. */
  25356. readonly extend: {
  25357. minimum: Vector3;
  25358. maximum: Vector3;
  25359. };
  25360. /**
  25361. * Gets the hosting scene
  25362. * @returns the hosting Scene
  25363. */
  25364. getScene(): Scene;
  25365. /**
  25366. * Gets the hosting engine
  25367. * @returns the hosting Engine
  25368. */
  25369. getEngine(): Engine;
  25370. /**
  25371. * Defines if the geometry is ready to use
  25372. * @returns true if the geometry is ready to be used
  25373. */
  25374. isReady(): boolean;
  25375. /**
  25376. * Gets a value indicating that the geometry should not be serialized
  25377. */
  25378. readonly doNotSerialize: boolean;
  25379. /** @hidden */
  25380. _rebuild(): void;
  25381. /**
  25382. * Affects all geometry data in one call
  25383. * @param vertexData defines the geometry data
  25384. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25385. */
  25386. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25387. /**
  25388. * Set specific vertex data
  25389. * @param kind defines the data kind (Position, normal, etc...)
  25390. * @param data defines the vertex data to use
  25391. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25392. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25393. */
  25394. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25395. /**
  25396. * Removes a specific vertex data
  25397. * @param kind defines the data kind (Position, normal, etc...)
  25398. */
  25399. removeVerticesData(kind: string): void;
  25400. /**
  25401. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25402. * @param buffer defines the vertex buffer to use
  25403. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25404. */
  25405. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25406. /**
  25407. * Update a specific vertex buffer
  25408. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25409. * It will do nothing if the buffer is not updatable
  25410. * @param kind defines the data kind (Position, normal, etc...)
  25411. * @param data defines the data to use
  25412. * @param offset defines the offset in the target buffer where to store the data
  25413. * @param useBytes set to true if the offset is in bytes
  25414. */
  25415. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25416. /**
  25417. * Update a specific vertex buffer
  25418. * This function will create a new buffer if the current one is not updatable
  25419. * @param kind defines the data kind (Position, normal, etc...)
  25420. * @param data defines the data to use
  25421. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25422. */
  25423. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25424. private _updateBoundingInfo;
  25425. /** @hidden */
  25426. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25427. /**
  25428. * Gets total number of vertices
  25429. * @returns the total number of vertices
  25430. */
  25431. getTotalVertices(): number;
  25432. /**
  25433. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25434. * @param kind defines the data kind (Position, normal, etc...)
  25435. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25436. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25437. * @returns a float array containing vertex data
  25438. */
  25439. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25440. /**
  25441. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25442. * @param kind defines the data kind (Position, normal, etc...)
  25443. * @returns true if the vertex buffer with the specified kind is updatable
  25444. */
  25445. isVertexBufferUpdatable(kind: string): boolean;
  25446. /**
  25447. * Gets a specific vertex buffer
  25448. * @param kind defines the data kind (Position, normal, etc...)
  25449. * @returns a VertexBuffer
  25450. */
  25451. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25452. /**
  25453. * Returns all vertex buffers
  25454. * @return an object holding all vertex buffers indexed by kind
  25455. */
  25456. getVertexBuffers(): Nullable<{
  25457. [key: string]: VertexBuffer;
  25458. }>;
  25459. /**
  25460. * Gets a boolean indicating if specific vertex buffer is present
  25461. * @param kind defines the data kind (Position, normal, etc...)
  25462. * @returns true if data is present
  25463. */
  25464. isVerticesDataPresent(kind: string): boolean;
  25465. /**
  25466. * Gets a list of all attached data kinds (Position, normal, etc...)
  25467. * @returns a list of string containing all kinds
  25468. */
  25469. getVerticesDataKinds(): string[];
  25470. /**
  25471. * Update index buffer
  25472. * @param indices defines the indices to store in the index buffer
  25473. * @param offset defines the offset in the target buffer where to store the data
  25474. */
  25475. updateIndices(indices: IndicesArray, offset?: number): void;
  25476. /**
  25477. * Creates a new index buffer
  25478. * @param indices defines the indices to store in the index buffer
  25479. * @param totalVertices defines the total number of vertices (could be null)
  25480. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25481. */
  25482. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25483. /**
  25484. * Return the total number of indices
  25485. * @returns the total number of indices
  25486. */
  25487. getTotalIndices(): number;
  25488. /**
  25489. * Gets the index buffer array
  25490. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25491. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25492. * @returns the index buffer array
  25493. */
  25494. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25495. /**
  25496. * Gets the index buffer
  25497. * @return the index buffer
  25498. */
  25499. getIndexBuffer(): Nullable<WebGLBuffer>;
  25500. /** @hidden */
  25501. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25502. /**
  25503. * Release the associated resources for a specific mesh
  25504. * @param mesh defines the source mesh
  25505. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25506. */
  25507. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25508. /**
  25509. * Apply current geometry to a given mesh
  25510. * @param mesh defines the mesh to apply geometry to
  25511. */
  25512. applyToMesh(mesh: Mesh): void;
  25513. private _updateExtend;
  25514. private _applyToMesh;
  25515. private notifyUpdate;
  25516. /**
  25517. * Load the geometry if it was flagged as delay loaded
  25518. * @param scene defines the hosting scene
  25519. * @param onLoaded defines a callback called when the geometry is loaded
  25520. */
  25521. load(scene: Scene, onLoaded?: () => void): void;
  25522. private _queueLoad;
  25523. /**
  25524. * Invert the geometry to move from a right handed system to a left handed one.
  25525. */
  25526. toLeftHanded(): void;
  25527. /** @hidden */
  25528. _resetPointsArrayCache(): void;
  25529. /** @hidden */
  25530. _generatePointsArray(): boolean;
  25531. /**
  25532. * Gets a value indicating if the geometry is disposed
  25533. * @returns true if the geometry was disposed
  25534. */
  25535. isDisposed(): boolean;
  25536. private _disposeVertexArrayObjects;
  25537. /**
  25538. * Free all associated resources
  25539. */
  25540. dispose(): void;
  25541. /**
  25542. * Clone the current geometry into a new geometry
  25543. * @param id defines the unique ID of the new geometry
  25544. * @returns a new geometry object
  25545. */
  25546. copy(id: string): Geometry;
  25547. /**
  25548. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25549. * @return a JSON representation of the current geometry data (without the vertices data)
  25550. */
  25551. serialize(): any;
  25552. private toNumberArray;
  25553. /**
  25554. * Serialize all vertices data into a JSON oject
  25555. * @returns a JSON representation of the current geometry data
  25556. */
  25557. serializeVerticeData(): any;
  25558. /**
  25559. * Extracts a clone of a mesh geometry
  25560. * @param mesh defines the source mesh
  25561. * @param id defines the unique ID of the new geometry object
  25562. * @returns the new geometry object
  25563. */
  25564. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25565. /**
  25566. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25567. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25568. * Be aware Math.random() could cause collisions, but:
  25569. * "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"
  25570. * @returns a string containing a new GUID
  25571. */
  25572. static RandomId(): string;
  25573. /** @hidden */
  25574. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25575. private static _CleanMatricesWeights;
  25576. /**
  25577. * Create a new geometry from persisted data (Using .babylon file format)
  25578. * @param parsedVertexData defines the persisted data
  25579. * @param scene defines the hosting scene
  25580. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25581. * @returns the new geometry object
  25582. */
  25583. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25584. }
  25585. /**
  25586. * Abstract class used to provide common services for all typed geometries
  25587. * @hidden
  25588. */
  25589. class _PrimitiveGeometry extends Geometry {
  25590. private _canBeRegenerated;
  25591. private _beingRegenerated;
  25592. /**
  25593. * Creates a new typed geometry
  25594. * @param id defines the unique ID of the geometry
  25595. * @param scene defines the hosting scene
  25596. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25597. * @param mesh defines the hosting mesh (can be null)
  25598. */
  25599. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25600. /**
  25601. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25602. * @returns true if the geometry can be regenerated
  25603. */
  25604. canBeRegenerated(): boolean;
  25605. /**
  25606. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25607. */
  25608. regenerate(): void;
  25609. /**
  25610. * Clone the geometry
  25611. * @param id defines the unique ID of the new geometry
  25612. * @returns the new geometry
  25613. */
  25614. asNewGeometry(id: string): Geometry;
  25615. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25616. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25617. /** @hidden */
  25618. _regenerateVertexData(): VertexData;
  25619. copy(id: string): Geometry;
  25620. serialize(): any;
  25621. }
  25622. /**
  25623. * Creates a ribbon geometry
  25624. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25625. */
  25626. class RibbonGeometry extends _PrimitiveGeometry {
  25627. /**
  25628. * Defines the array of paths to use
  25629. */
  25630. pathArray: Vector3[][];
  25631. /**
  25632. * Defines if the last and first points of each path in your pathArray must be joined
  25633. */
  25634. closeArray: boolean;
  25635. /**
  25636. * Defines if the last and first points of each path in your pathArray must be joined
  25637. */
  25638. closePath: boolean;
  25639. /**
  25640. * Defines the offset between points
  25641. */
  25642. offset: number;
  25643. /**
  25644. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25645. */
  25646. side: number;
  25647. /**
  25648. * Creates a ribbon geometry
  25649. * @param id defines the unique ID of the geometry
  25650. * @param scene defines the hosting scene
  25651. * @param pathArray defines the array of paths to use
  25652. * @param closeArray defines if the last path and the first path must be joined
  25653. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25654. * @param offset defines the offset between points
  25655. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25656. * @param mesh defines the hosting mesh (can be null)
  25657. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25658. */
  25659. constructor(id: string, scene: Scene,
  25660. /**
  25661. * Defines the array of paths to use
  25662. */
  25663. pathArray: Vector3[][],
  25664. /**
  25665. * Defines if the last and first points of each path in your pathArray must be joined
  25666. */
  25667. closeArray: boolean,
  25668. /**
  25669. * Defines if the last and first points of each path in your pathArray must be joined
  25670. */
  25671. closePath: boolean,
  25672. /**
  25673. * Defines the offset between points
  25674. */
  25675. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25676. /**
  25677. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25678. */
  25679. side?: number);
  25680. /** @hidden */
  25681. _regenerateVertexData(): VertexData;
  25682. copy(id: string): Geometry;
  25683. }
  25684. /**
  25685. * Creates a box geometry
  25686. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25687. */
  25688. class BoxGeometry extends _PrimitiveGeometry {
  25689. /**
  25690. * Defines the zise of the box (width, height and depth are the same)
  25691. */
  25692. size: number;
  25693. /**
  25694. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25695. */
  25696. side: number;
  25697. /**
  25698. * Creates a box geometry
  25699. * @param id defines the unique ID of the geometry
  25700. * @param scene defines the hosting scene
  25701. * @param size defines the zise of the box (width, height and depth are the same)
  25702. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25703. * @param mesh defines the hosting mesh (can be null)
  25704. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25705. */
  25706. constructor(id: string, scene: Scene,
  25707. /**
  25708. * Defines the zise of the box (width, height and depth are the same)
  25709. */
  25710. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25711. /**
  25712. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25713. */
  25714. side?: number);
  25715. /** @hidden */
  25716. _regenerateVertexData(): VertexData;
  25717. copy(id: string): Geometry;
  25718. serialize(): any;
  25719. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25720. }
  25721. /**
  25722. * Creates a sphere geometry
  25723. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25724. */
  25725. class SphereGeometry extends _PrimitiveGeometry {
  25726. /**
  25727. * Defines the number of segments to use to create the sphere
  25728. */
  25729. segments: number;
  25730. /**
  25731. * Defines the diameter of the sphere
  25732. */
  25733. diameter: number;
  25734. /**
  25735. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25736. */
  25737. side: number;
  25738. /**
  25739. * Create a new sphere geometry
  25740. * @param id defines the unique ID of the geometry
  25741. * @param scene defines the hosting scene
  25742. * @param segments defines the number of segments to use to create the sphere
  25743. * @param diameter defines the diameter of the sphere
  25744. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25745. * @param mesh defines the hosting mesh (can be null)
  25746. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25747. */
  25748. constructor(id: string, scene: Scene,
  25749. /**
  25750. * Defines the number of segments to use to create the sphere
  25751. */
  25752. segments: number,
  25753. /**
  25754. * Defines the diameter of the sphere
  25755. */
  25756. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25757. /**
  25758. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25759. */
  25760. side?: number);
  25761. /** @hidden */
  25762. _regenerateVertexData(): VertexData;
  25763. copy(id: string): Geometry;
  25764. serialize(): any;
  25765. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25766. }
  25767. /**
  25768. * Creates a disc geometry
  25769. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25770. */
  25771. class DiscGeometry extends _PrimitiveGeometry {
  25772. /**
  25773. * Defines the radius of the disc
  25774. */
  25775. radius: number;
  25776. /**
  25777. * Defines the tesselation factor to apply to the disc
  25778. */
  25779. tessellation: number;
  25780. /**
  25781. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25782. */
  25783. side: number;
  25784. /**
  25785. * Creates a new disc geometry
  25786. * @param id defines the unique ID of the geometry
  25787. * @param scene defines the hosting scene
  25788. * @param radius defines the radius of the disc
  25789. * @param tessellation defines the tesselation factor to apply to the disc
  25790. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25791. * @param mesh defines the hosting mesh (can be null)
  25792. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25793. */
  25794. constructor(id: string, scene: Scene,
  25795. /**
  25796. * Defines the radius of the disc
  25797. */
  25798. radius: number,
  25799. /**
  25800. * Defines the tesselation factor to apply to the disc
  25801. */
  25802. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25803. /**
  25804. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25805. */
  25806. side?: number);
  25807. /** @hidden */
  25808. _regenerateVertexData(): VertexData;
  25809. copy(id: string): Geometry;
  25810. }
  25811. /**
  25812. * Creates a new cylinder geometry
  25813. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25814. */
  25815. class CylinderGeometry extends _PrimitiveGeometry {
  25816. /**
  25817. * Defines the height of the cylinder
  25818. */
  25819. height: number;
  25820. /**
  25821. * Defines the diameter of the cylinder's top cap
  25822. */
  25823. diameterTop: number;
  25824. /**
  25825. * Defines the diameter of the cylinder's bottom cap
  25826. */
  25827. diameterBottom: number;
  25828. /**
  25829. * Defines the tessellation factor to apply to the cylinder
  25830. */
  25831. tessellation: number;
  25832. /**
  25833. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25834. */
  25835. subdivisions: number;
  25836. /**
  25837. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25838. */
  25839. side: number;
  25840. /**
  25841. * Creates a new cylinder geometry
  25842. * @param id defines the unique ID of the geometry
  25843. * @param scene defines the hosting scene
  25844. * @param height defines the height of the cylinder
  25845. * @param diameterTop defines the diameter of the cylinder's top cap
  25846. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25847. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25848. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25849. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25850. * @param mesh defines the hosting mesh (can be null)
  25851. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25852. */
  25853. constructor(id: string, scene: Scene,
  25854. /**
  25855. * Defines the height of the cylinder
  25856. */
  25857. height: number,
  25858. /**
  25859. * Defines the diameter of the cylinder's top cap
  25860. */
  25861. diameterTop: number,
  25862. /**
  25863. * Defines the diameter of the cylinder's bottom cap
  25864. */
  25865. diameterBottom: number,
  25866. /**
  25867. * Defines the tessellation factor to apply to the cylinder
  25868. */
  25869. tessellation: number,
  25870. /**
  25871. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25872. */
  25873. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25874. /**
  25875. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25876. */
  25877. side?: number);
  25878. /** @hidden */
  25879. _regenerateVertexData(): VertexData;
  25880. copy(id: string): Geometry;
  25881. serialize(): any;
  25882. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25883. }
  25884. /**
  25885. * Creates a new torus geometry
  25886. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25887. */
  25888. class TorusGeometry extends _PrimitiveGeometry {
  25889. /**
  25890. * Defines the diameter of the torus
  25891. */
  25892. diameter: number;
  25893. /**
  25894. * Defines the thickness of the torus (ie. internal diameter)
  25895. */
  25896. thickness: number;
  25897. /**
  25898. * Defines the tesselation factor to apply to the torus
  25899. */
  25900. tessellation: number;
  25901. /**
  25902. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25903. */
  25904. side: number;
  25905. /**
  25906. * Creates a new torus geometry
  25907. * @param id defines the unique ID of the geometry
  25908. * @param scene defines the hosting scene
  25909. * @param diameter defines the diameter of the torus
  25910. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25911. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25912. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25913. * @param mesh defines the hosting mesh (can be null)
  25914. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25915. */
  25916. constructor(id: string, scene: Scene,
  25917. /**
  25918. * Defines the diameter of the torus
  25919. */
  25920. diameter: number,
  25921. /**
  25922. * Defines the thickness of the torus (ie. internal diameter)
  25923. */
  25924. thickness: number,
  25925. /**
  25926. * Defines the tesselation factor to apply to the torus
  25927. */
  25928. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25929. /**
  25930. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25931. */
  25932. side?: number);
  25933. /** @hidden */
  25934. _regenerateVertexData(): VertexData;
  25935. copy(id: string): Geometry;
  25936. serialize(): any;
  25937. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25938. }
  25939. /**
  25940. * Creates a new ground geometry
  25941. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25942. */
  25943. class GroundGeometry extends _PrimitiveGeometry {
  25944. /**
  25945. * Defines the width of the ground
  25946. */
  25947. width: number;
  25948. /**
  25949. * Defines the height of the ground
  25950. */
  25951. height: number;
  25952. /**
  25953. * Defines the subdivisions to apply to the ground
  25954. */
  25955. subdivisions: number;
  25956. /**
  25957. * Creates a new ground geometry
  25958. * @param id defines the unique ID of the geometry
  25959. * @param scene defines the hosting scene
  25960. * @param width defines the width of the ground
  25961. * @param height defines the height of the ground
  25962. * @param subdivisions defines the subdivisions to apply to the ground
  25963. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25964. * @param mesh defines the hosting mesh (can be null)
  25965. */
  25966. constructor(id: string, scene: Scene,
  25967. /**
  25968. * Defines the width of the ground
  25969. */
  25970. width: number,
  25971. /**
  25972. * Defines the height of the ground
  25973. */
  25974. height: number,
  25975. /**
  25976. * Defines the subdivisions to apply to the ground
  25977. */
  25978. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25979. /** @hidden */
  25980. _regenerateVertexData(): VertexData;
  25981. copy(id: string): Geometry;
  25982. serialize(): any;
  25983. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25984. }
  25985. /**
  25986. * Creates a tiled ground geometry
  25987. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25988. */
  25989. class TiledGroundGeometry extends _PrimitiveGeometry {
  25990. /**
  25991. * Defines the minimum value on X axis
  25992. */
  25993. xmin: number;
  25994. /**
  25995. * Defines the minimum value on Z axis
  25996. */
  25997. zmin: number;
  25998. /**
  25999. * Defines the maximum value on X axis
  26000. */
  26001. xmax: number;
  26002. /**
  26003. * Defines the maximum value on Z axis
  26004. */
  26005. zmax: number;
  26006. /**
  26007. * Defines the subdivisions to apply to the ground
  26008. */
  26009. subdivisions: {
  26010. w: number;
  26011. h: number;
  26012. };
  26013. /**
  26014. * Defines the precision to use when computing the tiles
  26015. */
  26016. precision: {
  26017. w: number;
  26018. h: number;
  26019. };
  26020. /**
  26021. * Creates a tiled ground geometry
  26022. * @param id defines the unique ID of the geometry
  26023. * @param scene defines the hosting scene
  26024. * @param xmin defines the minimum value on X axis
  26025. * @param zmin defines the minimum value on Z axis
  26026. * @param xmax defines the maximum value on X axis
  26027. * @param zmax defines the maximum value on Z axis
  26028. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  26029. * @param precision defines the precision to use when computing the tiles
  26030. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26031. * @param mesh defines the hosting mesh (can be null)
  26032. */
  26033. constructor(id: string, scene: Scene,
  26034. /**
  26035. * Defines the minimum value on X axis
  26036. */
  26037. xmin: number,
  26038. /**
  26039. * Defines the minimum value on Z axis
  26040. */
  26041. zmin: number,
  26042. /**
  26043. * Defines the maximum value on X axis
  26044. */
  26045. xmax: number,
  26046. /**
  26047. * Defines the maximum value on Z axis
  26048. */
  26049. zmax: number,
  26050. /**
  26051. * Defines the subdivisions to apply to the ground
  26052. */
  26053. subdivisions: {
  26054. w: number;
  26055. h: number;
  26056. },
  26057. /**
  26058. * Defines the precision to use when computing the tiles
  26059. */
  26060. precision: {
  26061. w: number;
  26062. h: number;
  26063. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26064. /** @hidden */
  26065. _regenerateVertexData(): VertexData;
  26066. copy(id: string): Geometry;
  26067. }
  26068. /**
  26069. * Creates a plane geometry
  26070. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  26071. */
  26072. class PlaneGeometry extends _PrimitiveGeometry {
  26073. /**
  26074. * Defines the size of the plane (width === height)
  26075. */
  26076. size: number;
  26077. /**
  26078. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26079. */
  26080. side: number;
  26081. /**
  26082. * Creates a plane geometry
  26083. * @param id defines the unique ID of the geometry
  26084. * @param scene defines the hosting scene
  26085. * @param size defines the size of the plane (width === height)
  26086. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26087. * @param mesh defines the hosting mesh (can be null)
  26088. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26089. */
  26090. constructor(id: string, scene: Scene,
  26091. /**
  26092. * Defines the size of the plane (width === height)
  26093. */
  26094. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26095. /**
  26096. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26097. */
  26098. side?: number);
  26099. /** @hidden */
  26100. _regenerateVertexData(): VertexData;
  26101. copy(id: string): Geometry;
  26102. serialize(): any;
  26103. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26104. }
  26105. /**
  26106. * Creates a torus knot geometry
  26107. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26108. */
  26109. class TorusKnotGeometry extends _PrimitiveGeometry {
  26110. /**
  26111. * Defines the radius of the torus knot
  26112. */
  26113. radius: number;
  26114. /**
  26115. * Defines the thickness of the torus knot tube
  26116. */
  26117. tube: number;
  26118. /**
  26119. * Defines the number of radial segments
  26120. */
  26121. radialSegments: number;
  26122. /**
  26123. * Defines the number of tubular segments
  26124. */
  26125. tubularSegments: number;
  26126. /**
  26127. * Defines the first number of windings
  26128. */
  26129. p: number;
  26130. /**
  26131. * Defines the second number of windings
  26132. */
  26133. q: number;
  26134. /**
  26135. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26136. */
  26137. side: number;
  26138. /**
  26139. * Creates a torus knot geometry
  26140. * @param id defines the unique ID of the geometry
  26141. * @param scene defines the hosting scene
  26142. * @param radius defines the radius of the torus knot
  26143. * @param tube defines the thickness of the torus knot tube
  26144. * @param radialSegments defines the number of radial segments
  26145. * @param tubularSegments defines the number of tubular segments
  26146. * @param p defines the first number of windings
  26147. * @param q defines the second number of windings
  26148. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26149. * @param mesh defines the hosting mesh (can be null)
  26150. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26151. */
  26152. constructor(id: string, scene: Scene,
  26153. /**
  26154. * Defines the radius of the torus knot
  26155. */
  26156. radius: number,
  26157. /**
  26158. * Defines the thickness of the torus knot tube
  26159. */
  26160. tube: number,
  26161. /**
  26162. * Defines the number of radial segments
  26163. */
  26164. radialSegments: number,
  26165. /**
  26166. * Defines the number of tubular segments
  26167. */
  26168. tubularSegments: number,
  26169. /**
  26170. * Defines the first number of windings
  26171. */
  26172. p: number,
  26173. /**
  26174. * Defines the second number of windings
  26175. */
  26176. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26177. /**
  26178. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26179. */
  26180. side?: number);
  26181. /** @hidden */
  26182. _regenerateVertexData(): VertexData;
  26183. copy(id: string): Geometry;
  26184. serialize(): any;
  26185. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26186. }
  26187. }
  26188. declare module BABYLON {
  26189. /**
  26190. * Mesh representing the gorund
  26191. */
  26192. class GroundMesh extends Mesh {
  26193. /** If octree should be generated */
  26194. generateOctree: boolean;
  26195. private _heightQuads;
  26196. /** @hidden */
  26197. _subdivisionsX: number;
  26198. /** @hidden */
  26199. _subdivisionsY: number;
  26200. /** @hidden */
  26201. _width: number;
  26202. /** @hidden */
  26203. _height: number;
  26204. /** @hidden */
  26205. _minX: number;
  26206. /** @hidden */
  26207. _maxX: number;
  26208. /** @hidden */
  26209. _minZ: number;
  26210. /** @hidden */
  26211. _maxZ: number;
  26212. constructor(name: string, scene: Scene);
  26213. /**
  26214. * "GroundMesh"
  26215. * @returns "GroundMesh"
  26216. */
  26217. getClassName(): string;
  26218. /**
  26219. * The minimum of x and y subdivisions
  26220. */
  26221. readonly subdivisions: number;
  26222. /**
  26223. * X subdivisions
  26224. */
  26225. readonly subdivisionsX: number;
  26226. /**
  26227. * Y subdivisions
  26228. */
  26229. readonly subdivisionsY: number;
  26230. /**
  26231. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26232. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26233. * @param chunksCount the number of subdivisions for x and y
  26234. * @param octreeBlocksSize (Default: 32)
  26235. */
  26236. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26237. /**
  26238. * Returns a height (y) value in the Worl system :
  26239. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26240. * @param x x coordinate
  26241. * @param z z coordinate
  26242. * @returns the ground y position if (x, z) are outside the ground surface.
  26243. */
  26244. getHeightAtCoordinates(x: number, z: number): number;
  26245. /**
  26246. * Returns a normalized vector (Vector3) orthogonal to the ground
  26247. * at the ground coordinates (x, z) expressed in the World system.
  26248. * @param x x coordinate
  26249. * @param z z coordinate
  26250. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26251. */
  26252. getNormalAtCoordinates(x: number, z: number): Vector3;
  26253. /**
  26254. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26255. * at the ground coordinates (x, z) expressed in the World system.
  26256. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26257. * @param x x coordinate
  26258. * @param z z coordinate
  26259. * @param ref vector to store the result
  26260. * @returns the GroundMesh.
  26261. */
  26262. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26263. /**
  26264. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26265. * if the ground has been updated.
  26266. * This can be used in the render loop.
  26267. * @returns the GroundMesh.
  26268. */
  26269. updateCoordinateHeights(): GroundMesh;
  26270. private _getFacetAt;
  26271. private _initHeightQuads;
  26272. private _computeHeightQuads;
  26273. /**
  26274. * Serializes this ground mesh
  26275. * @param serializationObject object to write serialization to
  26276. */
  26277. serialize(serializationObject: any): void;
  26278. /**
  26279. * Parses a serialized ground mesh
  26280. * @param parsedMesh the serialized mesh
  26281. * @param scene the scene to create the ground mesh in
  26282. * @returns the created ground mesh
  26283. */
  26284. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26285. }
  26286. }
  26287. declare module BABYLON {
  26288. /**
  26289. * Creates an instance based on a source mesh.
  26290. */
  26291. class InstancedMesh extends AbstractMesh {
  26292. private _sourceMesh;
  26293. private _currentLOD;
  26294. /** @hidden */
  26295. _indexInSourceMeshInstanceArray: number;
  26296. constructor(name: string, source: Mesh);
  26297. /**
  26298. * Returns the string "InstancedMesh".
  26299. */
  26300. getClassName(): string;
  26301. /**
  26302. * If the source mesh receives shadows
  26303. */
  26304. readonly receiveShadows: boolean;
  26305. /**
  26306. * The material of the source mesh
  26307. */
  26308. readonly material: Nullable<Material>;
  26309. /**
  26310. * Visibility of the source mesh
  26311. */
  26312. readonly visibility: number;
  26313. /**
  26314. * Skeleton of the source mesh
  26315. */
  26316. readonly skeleton: Nullable<Skeleton>;
  26317. /**
  26318. * Rendering ground id of the source mesh
  26319. */
  26320. renderingGroupId: number;
  26321. /**
  26322. * Returns the total number of vertices (integer).
  26323. */
  26324. getTotalVertices(): number;
  26325. /**
  26326. * The source mesh of the instance
  26327. */
  26328. readonly sourceMesh: Mesh;
  26329. /**
  26330. * Is this node ready to be used/rendered
  26331. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26332. * @return {boolean} is it ready
  26333. */
  26334. isReady(completeCheck?: boolean): boolean;
  26335. /**
  26336. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26337. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26338. * @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.
  26339. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26340. */
  26341. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26342. /**
  26343. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26344. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26345. * The `data` are either a numeric array either a Float32Array.
  26346. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26347. * 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).
  26348. * Note that a new underlying VertexBuffer object is created each call.
  26349. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26350. *
  26351. * Possible `kind` values :
  26352. * - BABYLON.VertexBuffer.PositionKind
  26353. * - BABYLON.VertexBuffer.UVKind
  26354. * - BABYLON.VertexBuffer.UV2Kind
  26355. * - BABYLON.VertexBuffer.UV3Kind
  26356. * - BABYLON.VertexBuffer.UV4Kind
  26357. * - BABYLON.VertexBuffer.UV5Kind
  26358. * - BABYLON.VertexBuffer.UV6Kind
  26359. * - BABYLON.VertexBuffer.ColorKind
  26360. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26361. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26362. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26363. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26364. *
  26365. * Returns the Mesh.
  26366. */
  26367. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26368. /**
  26369. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26370. * If the mesh has no geometry, it is simply returned as it is.
  26371. * The `data` are either a numeric array either a Float32Array.
  26372. * No new underlying VertexBuffer object is created.
  26373. * 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.
  26374. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26375. *
  26376. * Possible `kind` values :
  26377. * - BABYLON.VertexBuffer.PositionKind
  26378. * - BABYLON.VertexBuffer.UVKind
  26379. * - BABYLON.VertexBuffer.UV2Kind
  26380. * - BABYLON.VertexBuffer.UV3Kind
  26381. * - BABYLON.VertexBuffer.UV4Kind
  26382. * - BABYLON.VertexBuffer.UV5Kind
  26383. * - BABYLON.VertexBuffer.UV6Kind
  26384. * - BABYLON.VertexBuffer.ColorKind
  26385. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26386. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26387. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26388. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26389. *
  26390. * Returns the Mesh.
  26391. */
  26392. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26393. /**
  26394. * Sets the mesh indices.
  26395. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26396. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26397. * This method creates a new index buffer each call.
  26398. * Returns the Mesh.
  26399. */
  26400. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26401. /**
  26402. * Boolean : True if the mesh owns the requested kind of data.
  26403. */
  26404. isVerticesDataPresent(kind: string): boolean;
  26405. /**
  26406. * Returns an array of indices (IndicesArray).
  26407. */
  26408. getIndices(): Nullable<IndicesArray>;
  26409. readonly _positions: Nullable<Vector3[]>;
  26410. /**
  26411. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26412. * This means the mesh underlying bounding box and sphere are recomputed.
  26413. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26414. * @returns the current mesh
  26415. */
  26416. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26417. /** @hidden */
  26418. _preActivate(): InstancedMesh;
  26419. /** @hidden */
  26420. _activate(renderId: number): InstancedMesh;
  26421. /**
  26422. * Returns the current associated LOD AbstractMesh.
  26423. */
  26424. getLOD(camera: Camera): AbstractMesh;
  26425. /** @hidden */
  26426. _syncSubMeshes(): InstancedMesh;
  26427. /** @hidden */
  26428. _generatePointsArray(): boolean;
  26429. /**
  26430. * Creates a new InstancedMesh from the current mesh.
  26431. * - name (string) : the cloned mesh name
  26432. * - newParent (optional Node) : the optional Node to parent the clone to.
  26433. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26434. *
  26435. * Returns the clone.
  26436. */
  26437. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26438. /**
  26439. * Disposes the InstancedMesh.
  26440. * Returns nothing.
  26441. */
  26442. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26443. }
  26444. }
  26445. declare module BABYLON {
  26446. /**
  26447. * Line mesh
  26448. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26449. */
  26450. class LinesMesh extends Mesh {
  26451. /**
  26452. * If vertex color should be applied to the mesh
  26453. */
  26454. useVertexColor?: boolean | undefined;
  26455. /**
  26456. * If vertex alpha should be applied to the mesh
  26457. */
  26458. useVertexAlpha?: boolean | undefined;
  26459. /**
  26460. * Color of the line (Default: White)
  26461. */
  26462. color: Color3;
  26463. /**
  26464. * Alpha of the line (Default: 1)
  26465. */
  26466. alpha: number;
  26467. /**
  26468. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26469. * This margin is expressed in world space coordinates, so its value may vary.
  26470. * Default value is 0.1
  26471. */
  26472. intersectionThreshold: number;
  26473. private _colorShader;
  26474. /**
  26475. * Creates a new LinesMesh
  26476. * @param name defines the name
  26477. * @param scene defines the hosting scene
  26478. * @param parent defines the parent mesh if any
  26479. * @param source defines the optional source LinesMesh used to clone data from
  26480. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26481. * When false, achieved by calling a clone(), also passing False.
  26482. * This will make creation of children, recursive.
  26483. * @param useVertexColor defines if this LinesMesh supports vertex color
  26484. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26485. */
  26486. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26487. /**
  26488. * If vertex color should be applied to the mesh
  26489. */
  26490. useVertexColor?: boolean | undefined,
  26491. /**
  26492. * If vertex alpha should be applied to the mesh
  26493. */
  26494. useVertexAlpha?: boolean | undefined);
  26495. /**
  26496. * Returns the string "LineMesh"
  26497. */
  26498. getClassName(): string;
  26499. /**
  26500. * @hidden
  26501. */
  26502. /**
  26503. * @hidden
  26504. */
  26505. material: Material;
  26506. /**
  26507. * @hidden
  26508. */
  26509. readonly checkCollisions: boolean;
  26510. /** @hidden */
  26511. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26512. /** @hidden */
  26513. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26514. /**
  26515. * Disposes of the line mesh
  26516. * @param doNotRecurse If children should be disposed
  26517. */
  26518. dispose(doNotRecurse?: boolean): void;
  26519. /**
  26520. * Returns a new LineMesh object cloned from the current one.
  26521. */
  26522. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26523. /**
  26524. * Creates a new InstancedLinesMesh object from the mesh model.
  26525. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26526. * @param name defines the name of the new instance
  26527. * @returns a new InstancedLinesMesh
  26528. */
  26529. createInstance(name: string): InstancedLinesMesh;
  26530. }
  26531. /**
  26532. * Creates an instance based on a source LinesMesh
  26533. */
  26534. class InstancedLinesMesh extends InstancedMesh {
  26535. /**
  26536. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26537. * This margin is expressed in world space coordinates, so its value may vary.
  26538. * Initilized with the intersectionThreshold value of the source LinesMesh
  26539. */
  26540. intersectionThreshold: number;
  26541. constructor(name: string, source: LinesMesh);
  26542. /**
  26543. * Returns the string "InstancedLinesMesh".
  26544. */
  26545. getClassName(): string;
  26546. }
  26547. }
  26548. declare module BABYLON {
  26549. /**
  26550. * @hidden
  26551. **/
  26552. class _CreationDataStorage {
  26553. closePath?: boolean;
  26554. closeArray?: boolean;
  26555. idx: number[];
  26556. dashSize: number;
  26557. gapSize: number;
  26558. path3D: Path3D;
  26559. pathArray: Vector3[][];
  26560. arc: number;
  26561. radius: number;
  26562. cap: number;
  26563. tessellation: number;
  26564. }
  26565. /**
  26566. * @hidden
  26567. **/
  26568. class _InstanceDataStorage {
  26569. visibleInstances: any;
  26570. renderIdForInstances: number[];
  26571. batchCache: _InstancesBatch;
  26572. instancesBufferSize: number;
  26573. instancesBuffer: Nullable<Buffer>;
  26574. instancesData: Float32Array;
  26575. overridenInstanceCount: number;
  26576. }
  26577. /**
  26578. * @hidden
  26579. **/
  26580. class _InstancesBatch {
  26581. mustReturn: boolean;
  26582. visibleInstances: Nullable<InstancedMesh[]>[];
  26583. renderSelf: boolean[];
  26584. }
  26585. /**
  26586. * Class used to represent renderable models
  26587. */
  26588. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26589. /**
  26590. * Mesh side orientation : usually the external or front surface
  26591. */
  26592. static readonly FRONTSIDE: number;
  26593. /**
  26594. * Mesh side orientation : usually the internal or back surface
  26595. */
  26596. static readonly BACKSIDE: number;
  26597. /**
  26598. * Mesh side orientation : both internal and external or front and back surfaces
  26599. */
  26600. static readonly DOUBLESIDE: number;
  26601. /**
  26602. * Mesh side orientation : by default, `FRONTSIDE`
  26603. */
  26604. static readonly DEFAULTSIDE: number;
  26605. /**
  26606. * Mesh cap setting : no cap
  26607. */
  26608. static readonly NO_CAP: number;
  26609. /**
  26610. * Mesh cap setting : one cap at the beginning of the mesh
  26611. */
  26612. static readonly CAP_START: number;
  26613. /**
  26614. * Mesh cap setting : one cap at the end of the mesh
  26615. */
  26616. static readonly CAP_END: number;
  26617. /**
  26618. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26619. */
  26620. static readonly CAP_ALL: number;
  26621. private _onBeforeRenderObservable;
  26622. private _onAfterRenderObservable;
  26623. private _onBeforeDrawObservable;
  26624. /**
  26625. * An event triggered before rendering the mesh
  26626. */
  26627. readonly onBeforeRenderObservable: Observable<Mesh>;
  26628. /**
  26629. * An event triggered after rendering the mesh
  26630. */
  26631. readonly onAfterRenderObservable: Observable<Mesh>;
  26632. /**
  26633. * An event triggered before drawing the mesh
  26634. */
  26635. readonly onBeforeDrawObservable: Observable<Mesh>;
  26636. private _onBeforeDrawObserver;
  26637. /**
  26638. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26639. */
  26640. onBeforeDraw: () => void;
  26641. /**
  26642. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26643. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26644. */
  26645. delayLoadState: number;
  26646. /**
  26647. * Gets the list of instances created from this mesh
  26648. * it is not supposed to be modified manually.
  26649. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26650. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26651. */
  26652. instances: InstancedMesh[];
  26653. /**
  26654. * Gets the file containing delay loading data for this mesh
  26655. */
  26656. delayLoadingFile: string;
  26657. /** @hidden */
  26658. _binaryInfo: any;
  26659. private _LODLevels;
  26660. /**
  26661. * User defined function used to change how LOD level selection is done
  26662. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26663. */
  26664. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26665. private _morphTargetManager;
  26666. /**
  26667. * Gets or sets the morph target manager
  26668. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26669. */
  26670. morphTargetManager: Nullable<MorphTargetManager>;
  26671. /** @hidden */
  26672. _creationDataStorage: Nullable<_CreationDataStorage>;
  26673. /** @hidden */
  26674. _geometry: Nullable<Geometry>;
  26675. /** @hidden */
  26676. _delayInfo: Array<string>;
  26677. /** @hidden */
  26678. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26679. /** @hidden */
  26680. _instanceDataStorage: _InstanceDataStorage;
  26681. private _effectiveMaterial;
  26682. /** @hidden */
  26683. _shouldGenerateFlatShading: boolean;
  26684. private _preActivateId;
  26685. /** @hidden */
  26686. _originalBuilderSideOrientation: number;
  26687. /**
  26688. * Use this property to change the original side orientation defined at construction time
  26689. */
  26690. overrideMaterialSideOrientation: Nullable<number>;
  26691. private _areNormalsFrozen;
  26692. private _sourcePositions;
  26693. private _sourceNormals;
  26694. private _source;
  26695. private meshMap;
  26696. /**
  26697. * Gets the source mesh (the one used to clone this one from)
  26698. */
  26699. readonly source: Nullable<Mesh>;
  26700. /**
  26701. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26702. */
  26703. isUnIndexed: boolean;
  26704. /**
  26705. * @constructor
  26706. * @param name The value used by scene.getMeshByName() to do a lookup.
  26707. * @param scene The scene to add this mesh to.
  26708. * @param parent The parent of this mesh, if it has one
  26709. * @param source An optional Mesh from which geometry is shared, cloned.
  26710. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26711. * When false, achieved by calling a clone(), also passing False.
  26712. * This will make creation of children, recursive.
  26713. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26714. */
  26715. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26716. /**
  26717. * Gets the class name
  26718. * @returns the string "Mesh".
  26719. */
  26720. getClassName(): string;
  26721. /**
  26722. * Returns a description of this mesh
  26723. * @param fullDetails define if full details about this mesh must be used
  26724. * @returns a descriptive string representing this mesh
  26725. */
  26726. toString(fullDetails?: boolean): string;
  26727. /** @hidden */
  26728. _unBindEffect(): void;
  26729. /**
  26730. * Gets a boolean indicating if this mesh has LOD
  26731. */
  26732. readonly hasLODLevels: boolean;
  26733. /**
  26734. * Gets the list of MeshLODLevel associated with the current mesh
  26735. * @returns an array of MeshLODLevel
  26736. */
  26737. getLODLevels(): MeshLODLevel[];
  26738. private _sortLODLevels;
  26739. /**
  26740. * Add a mesh as LOD level triggered at the given distance.
  26741. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26742. * @param distance The distance from the center of the object to show this level
  26743. * @param mesh The mesh to be added as LOD level (can be null)
  26744. * @return This mesh (for chaining)
  26745. */
  26746. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26747. /**
  26748. * Returns the LOD level mesh at the passed distance or null if not found.
  26749. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26750. * @param distance The distance from the center of the object to show this level
  26751. * @returns a Mesh or `null`
  26752. */
  26753. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26754. /**
  26755. * Remove a mesh from the LOD array
  26756. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26757. * @param mesh defines the mesh to be removed
  26758. * @return This mesh (for chaining)
  26759. */
  26760. removeLODLevel(mesh: Mesh): Mesh;
  26761. /**
  26762. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26763. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26764. * @param camera defines the camera to use to compute distance
  26765. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26766. * @return This mesh (for chaining)
  26767. */
  26768. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26769. /**
  26770. * Gets the mesh internal Geometry object
  26771. */
  26772. readonly geometry: Nullable<Geometry>;
  26773. /**
  26774. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26775. * @returns the total number of vertices
  26776. */
  26777. getTotalVertices(): number;
  26778. /**
  26779. * Returns the content of an associated vertex buffer
  26780. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26781. * - BABYLON.VertexBuffer.PositionKind
  26782. * - BABYLON.VertexBuffer.UVKind
  26783. * - BABYLON.VertexBuffer.UV2Kind
  26784. * - BABYLON.VertexBuffer.UV3Kind
  26785. * - BABYLON.VertexBuffer.UV4Kind
  26786. * - BABYLON.VertexBuffer.UV5Kind
  26787. * - BABYLON.VertexBuffer.UV6Kind
  26788. * - BABYLON.VertexBuffer.ColorKind
  26789. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26790. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26791. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26792. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26793. * @param 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
  26794. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26795. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26796. */
  26797. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26798. /**
  26799. * Returns the mesh VertexBuffer object from the requested `kind`
  26800. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26801. * - BABYLON.VertexBuffer.PositionKind
  26802. * - BABYLON.VertexBuffer.UVKind
  26803. * - BABYLON.VertexBuffer.UV2Kind
  26804. * - BABYLON.VertexBuffer.UV3Kind
  26805. * - BABYLON.VertexBuffer.UV4Kind
  26806. * - BABYLON.VertexBuffer.UV5Kind
  26807. * - BABYLON.VertexBuffer.UV6Kind
  26808. * - BABYLON.VertexBuffer.ColorKind
  26809. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26810. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26811. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26812. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26813. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26814. */
  26815. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26816. /**
  26817. * Tests if a specific vertex buffer is associated with this mesh
  26818. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26819. * - BABYLON.VertexBuffer.PositionKind
  26820. * - BABYLON.VertexBuffer.UVKind
  26821. * - BABYLON.VertexBuffer.UV2Kind
  26822. * - BABYLON.VertexBuffer.UV3Kind
  26823. * - BABYLON.VertexBuffer.UV4Kind
  26824. * - BABYLON.VertexBuffer.UV5Kind
  26825. * - BABYLON.VertexBuffer.UV6Kind
  26826. * - BABYLON.VertexBuffer.ColorKind
  26827. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26828. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26829. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26830. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26831. * @returns a boolean
  26832. */
  26833. isVerticesDataPresent(kind: string): boolean;
  26834. /**
  26835. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26836. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26837. * - BABYLON.VertexBuffer.PositionKind
  26838. * - BABYLON.VertexBuffer.UVKind
  26839. * - BABYLON.VertexBuffer.UV2Kind
  26840. * - BABYLON.VertexBuffer.UV3Kind
  26841. * - BABYLON.VertexBuffer.UV4Kind
  26842. * - BABYLON.VertexBuffer.UV5Kind
  26843. * - BABYLON.VertexBuffer.UV6Kind
  26844. * - BABYLON.VertexBuffer.ColorKind
  26845. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26846. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26847. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26848. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26849. * @returns a boolean
  26850. */
  26851. isVertexBufferUpdatable(kind: string): boolean;
  26852. /**
  26853. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26854. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26855. * - BABYLON.VertexBuffer.PositionKind
  26856. * - BABYLON.VertexBuffer.UVKind
  26857. * - BABYLON.VertexBuffer.UV2Kind
  26858. * - BABYLON.VertexBuffer.UV3Kind
  26859. * - BABYLON.VertexBuffer.UV4Kind
  26860. * - BABYLON.VertexBuffer.UV5Kind
  26861. * - BABYLON.VertexBuffer.UV6Kind
  26862. * - BABYLON.VertexBuffer.ColorKind
  26863. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26864. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26865. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26866. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26867. * @returns an array of strings
  26868. */
  26869. getVerticesDataKinds(): string[];
  26870. /**
  26871. * Returns a positive integer : the total number of indices in this mesh geometry.
  26872. * @returns the numner of indices or zero if the mesh has no geometry.
  26873. */
  26874. getTotalIndices(): number;
  26875. /**
  26876. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26877. * @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.
  26878. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26879. * @returns the indices array or an empty array if the mesh has no geometry
  26880. */
  26881. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26882. readonly isBlocked: boolean;
  26883. /**
  26884. * Determine if the current mesh is ready to be rendered
  26885. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26886. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26887. * @returns true if all associated assets are ready (material, textures, shaders)
  26888. */
  26889. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26890. /**
  26891. * 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.
  26892. */
  26893. readonly areNormalsFrozen: boolean;
  26894. /**
  26895. * 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.
  26896. * @returns the current mesh
  26897. */
  26898. freezeNormals(): Mesh;
  26899. /**
  26900. * 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
  26901. * @returns the current mesh
  26902. */
  26903. unfreezeNormals(): Mesh;
  26904. /**
  26905. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26906. */
  26907. overridenInstanceCount: number;
  26908. /** @hidden */
  26909. _preActivate(): Mesh;
  26910. /** @hidden */
  26911. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26912. /** @hidden */
  26913. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26914. /**
  26915. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26916. * This means the mesh underlying bounding box and sphere are recomputed.
  26917. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26918. * @returns the current mesh
  26919. */
  26920. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26921. /** @hidden */
  26922. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26923. /**
  26924. * This function will subdivide the mesh into multiple submeshes
  26925. * @param count defines the expected number of submeshes
  26926. */
  26927. subdivide(count: number): void;
  26928. /**
  26929. * Copy a FloatArray into a specific associated vertex buffer
  26930. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26931. * - BABYLON.VertexBuffer.PositionKind
  26932. * - BABYLON.VertexBuffer.UVKind
  26933. * - BABYLON.VertexBuffer.UV2Kind
  26934. * - BABYLON.VertexBuffer.UV3Kind
  26935. * - BABYLON.VertexBuffer.UV4Kind
  26936. * - BABYLON.VertexBuffer.UV5Kind
  26937. * - BABYLON.VertexBuffer.UV6Kind
  26938. * - BABYLON.VertexBuffer.ColorKind
  26939. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26940. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26941. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26942. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26943. * @param data defines the data source
  26944. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26945. * @param stride defines the data stride size (can be null)
  26946. * @returns the current mesh
  26947. */
  26948. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26949. /**
  26950. * Flags an associated vertex buffer as updatable
  26951. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26952. * - BABYLON.VertexBuffer.PositionKind
  26953. * - BABYLON.VertexBuffer.UVKind
  26954. * - BABYLON.VertexBuffer.UV2Kind
  26955. * - BABYLON.VertexBuffer.UV3Kind
  26956. * - BABYLON.VertexBuffer.UV4Kind
  26957. * - BABYLON.VertexBuffer.UV5Kind
  26958. * - BABYLON.VertexBuffer.UV6Kind
  26959. * - BABYLON.VertexBuffer.ColorKind
  26960. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26961. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26962. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26963. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26964. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26965. */
  26966. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26967. /**
  26968. * Sets the mesh global Vertex Buffer
  26969. * @param buffer defines the buffer to use
  26970. * @returns the current mesh
  26971. */
  26972. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26973. /**
  26974. * Update a specific associated vertex buffer
  26975. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26976. * - BABYLON.VertexBuffer.PositionKind
  26977. * - BABYLON.VertexBuffer.UVKind
  26978. * - BABYLON.VertexBuffer.UV2Kind
  26979. * - BABYLON.VertexBuffer.UV3Kind
  26980. * - BABYLON.VertexBuffer.UV4Kind
  26981. * - BABYLON.VertexBuffer.UV5Kind
  26982. * - BABYLON.VertexBuffer.UV6Kind
  26983. * - BABYLON.VertexBuffer.ColorKind
  26984. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26985. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26986. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26987. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26988. * @param data defines the data source
  26989. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26990. * @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)
  26991. * @returns the current mesh
  26992. */
  26993. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26994. /**
  26995. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26996. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26997. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26998. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26999. * @returns the current mesh
  27000. */
  27001. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27002. /**
  27003. * Creates a un-shared specific occurence of the geometry for the mesh.
  27004. * @returns the current mesh
  27005. */
  27006. makeGeometryUnique(): Mesh;
  27007. /**
  27008. * Set the index buffer of this mesh
  27009. * @param indices defines the source data
  27010. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27011. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27012. * @returns the current mesh
  27013. */
  27014. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  27015. /**
  27016. * Update the current index buffer
  27017. * @param indices defines the source data
  27018. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27019. * @returns the current mesh
  27020. */
  27021. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  27022. /**
  27023. * Invert the geometry to move from a right handed system to a left handed one.
  27024. * @returns the current mesh
  27025. */
  27026. toLeftHanded(): Mesh;
  27027. /** @hidden */
  27028. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27029. /** @hidden */
  27030. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  27031. /**
  27032. * Registers for this mesh a javascript function called just before the rendering process
  27033. * @param func defines the function to call before rendering this mesh
  27034. * @returns the current mesh
  27035. */
  27036. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27037. /**
  27038. * Disposes a previously registered javascript function called before the rendering
  27039. * @param func defines the function to remove
  27040. * @returns the current mesh
  27041. */
  27042. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27043. /**
  27044. * Registers for this mesh a javascript function called just after the rendering is complete
  27045. * @param func defines the function to call after rendering this mesh
  27046. * @returns the current mesh
  27047. */
  27048. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27049. /**
  27050. * Disposes a previously registered javascript function called after the rendering.
  27051. * @param func defines the function to remove
  27052. * @returns the current mesh
  27053. */
  27054. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27055. /** @hidden */
  27056. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  27057. /** @hidden */
  27058. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27059. /** @hidden */
  27060. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27061. /**
  27062. * 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
  27063. * @param subMesh defines the subMesh to render
  27064. * @param enableAlphaMode defines if alpha mode can be changed
  27065. * @returns the current mesh
  27066. */
  27067. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27068. private _onBeforeDraw;
  27069. /**
  27070. * Renormalize the mesh and patch it up if there are no weights
  27071. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27072. * However in the case of zero weights then we set just a single influence to 1.
  27073. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27074. */
  27075. cleanMatrixWeights(): void;
  27076. private normalizeSkinFourWeights;
  27077. private normalizeSkinWeightsAndExtra;
  27078. /**
  27079. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27080. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27081. * the user know there was an issue with importing the mesh
  27082. * @returns a validation object with skinned, valid and report string
  27083. */
  27084. validateSkinning(): {
  27085. skinned: boolean;
  27086. valid: boolean;
  27087. report: string;
  27088. };
  27089. /** @hidden */
  27090. _checkDelayState(): Mesh;
  27091. private _queueLoad;
  27092. /**
  27093. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27094. * A mesh is in the frustum if its bounding box intersects the frustum
  27095. * @param frustumPlanes defines the frustum to test
  27096. * @returns true if the mesh is in the frustum planes
  27097. */
  27098. isInFrustum(frustumPlanes: Plane[]): boolean;
  27099. /**
  27100. * Sets the mesh material by the material or multiMaterial `id` property
  27101. * @param id is a string identifying the material or the multiMaterial
  27102. * @returns the current mesh
  27103. */
  27104. setMaterialByID(id: string): Mesh;
  27105. /**
  27106. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27107. * @returns an array of IAnimatable
  27108. */
  27109. getAnimatables(): IAnimatable[];
  27110. /**
  27111. * Modifies the mesh geometry according to the passed transformation matrix.
  27112. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27113. * The mesh normals are modified using the same transformation.
  27114. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27115. * @param transform defines the transform matrix to use
  27116. * @see http://doc.babylonjs.com/resources/baking_transformations
  27117. * @returns the current mesh
  27118. */
  27119. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27120. /**
  27121. * Modifies the mesh geometry according to its own current World Matrix.
  27122. * The mesh World Matrix is then reset.
  27123. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27124. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27125. * @see http://doc.babylonjs.com/resources/baking_transformations
  27126. * @returns the current mesh
  27127. */
  27128. bakeCurrentTransformIntoVertices(): Mesh;
  27129. /** @hidden */
  27130. readonly _positions: Nullable<Vector3[]>;
  27131. /** @hidden */
  27132. _resetPointsArrayCache(): Mesh;
  27133. /** @hidden */
  27134. _generatePointsArray(): boolean;
  27135. /**
  27136. * Returns a new Mesh object generated from the current mesh properties.
  27137. * This method must not get confused with createInstance()
  27138. * @param name is a string, the name given to the new mesh
  27139. * @param newParent can be any Node object (default `null`)
  27140. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27141. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27142. * @returns a new mesh
  27143. */
  27144. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27145. /**
  27146. * Releases resources associated with this mesh.
  27147. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27148. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27149. */
  27150. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27151. /**
  27152. * Modifies the mesh geometry according to a displacement map.
  27153. * 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.
  27154. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27155. * @param url is a string, the URL from the image file is to be downloaded.
  27156. * @param minHeight is the lower limit of the displacement.
  27157. * @param maxHeight is the upper limit of the displacement.
  27158. * @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.
  27159. * @param uvOffset is an optional vector2 used to offset UV.
  27160. * @param uvScale is an optional vector2 used to scale UV.
  27161. * @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.
  27162. * @returns the Mesh.
  27163. */
  27164. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27165. /**
  27166. * Modifies the mesh geometry according to a displacementMap buffer.
  27167. * 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.
  27168. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27169. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27170. * @param heightMapWidth is the width of the buffer image.
  27171. * @param heightMapHeight is the height of the buffer image.
  27172. * @param minHeight is the lower limit of the displacement.
  27173. * @param maxHeight is the upper limit of the displacement.
  27174. * @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.
  27175. * @param uvOffset is an optional vector2 used to offset UV.
  27176. * @param uvScale is an optional vector2 used to scale UV.
  27177. * @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.
  27178. * @returns the Mesh.
  27179. */
  27180. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27181. /**
  27182. * Modify the mesh to get a flat shading rendering.
  27183. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27184. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27185. * @returns current mesh
  27186. */
  27187. convertToFlatShadedMesh(): Mesh;
  27188. /**
  27189. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27190. * In other words, more vertices, no more indices and a single bigger VBO.
  27191. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27192. * @returns current mesh
  27193. */
  27194. convertToUnIndexedMesh(): Mesh;
  27195. /**
  27196. * Inverses facet orientations.
  27197. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27198. * @param flipNormals will also inverts the normals
  27199. * @returns current mesh
  27200. */
  27201. flipFaces(flipNormals?: boolean): Mesh;
  27202. /**
  27203. * Creates a new InstancedMesh object from the mesh model.
  27204. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27205. * @param name defines the name of the new instance
  27206. * @returns a new InstancedMesh
  27207. */
  27208. createInstance(name: string): InstancedMesh;
  27209. /**
  27210. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27211. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27212. * @returns the current mesh
  27213. */
  27214. synchronizeInstances(): Mesh;
  27215. /**
  27216. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27217. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27218. * This should be used together with the simplification to avoid disappearing triangles.
  27219. * @param successCallback an optional success callback to be called after the optimization finished.
  27220. * @returns the current mesh
  27221. */
  27222. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27223. /**
  27224. * Serialize current mesh
  27225. * @param serializationObject defines the object which will receive the serialization data
  27226. */
  27227. serialize(serializationObject: any): void;
  27228. /** @hidden */
  27229. _syncGeometryWithMorphTargetManager(): void;
  27230. /**
  27231. * Returns a new Mesh object parsed from the source provided.
  27232. * @param parsedMesh is the source
  27233. * @param scene defines the hosting scene
  27234. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27235. * @returns a new Mesh
  27236. */
  27237. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27238. /**
  27239. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27240. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27241. * @param name defines the name of the mesh to create
  27242. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27243. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27244. * @param closePath creates a seam between the first and the last points of each path of the path array
  27245. * @param offset is taken in account only if the `pathArray` is containing a single path
  27246. * @param scene defines the hosting scene
  27247. * @param updatable defines if the mesh must be flagged as updatable
  27248. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27249. * @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)
  27250. * @returns a new Mesh
  27251. */
  27252. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27253. /**
  27254. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27255. * @param name defines the name of the mesh to create
  27256. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27257. * @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
  27258. * @param scene defines the hosting scene
  27259. * @param updatable defines if the mesh must be flagged as updatable
  27260. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27261. * @returns a new Mesh
  27262. */
  27263. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27264. /**
  27265. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27266. * @param name defines the name of the mesh to create
  27267. * @param size sets the size (float) of each box side (default 1)
  27268. * @param scene defines the hosting scene
  27269. * @param updatable defines if the mesh must be flagged as updatable
  27270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27271. * @returns a new Mesh
  27272. */
  27273. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27274. /**
  27275. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27276. * @param name defines the name of the mesh to create
  27277. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27278. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27279. * @param scene defines the hosting scene
  27280. * @param updatable defines if the mesh must be flagged as updatable
  27281. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27282. * @returns a new Mesh
  27283. */
  27284. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27285. /**
  27286. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27287. * @param name defines the name of the mesh to create
  27288. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27289. * @param diameterTop set the top cap diameter (floats, default 1)
  27290. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27291. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27292. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27293. * @param scene defines the hosting scene
  27294. * @param updatable defines if the mesh must be flagged as updatable
  27295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27296. * @returns a new Mesh
  27297. */
  27298. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27299. /**
  27300. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27301. * @param name defines the name of the mesh to create
  27302. * @param diameter sets the diameter size (float) of the torus (default 1)
  27303. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27304. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27305. * @param scene defines the hosting scene
  27306. * @param updatable defines if the mesh must be flagged as updatable
  27307. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27308. * @returns a new Mesh
  27309. */
  27310. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27311. /**
  27312. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27313. * @param name defines the name of the mesh to create
  27314. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27315. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27316. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27317. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27318. * @param p the number of windings on X axis (positive integers, default 2)
  27319. * @param q the number of windings on Y axis (positive integers, default 3)
  27320. * @param scene defines the hosting scene
  27321. * @param updatable defines if the mesh must be flagged as updatable
  27322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27323. * @returns a new Mesh
  27324. */
  27325. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27326. /**
  27327. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27328. * @param name defines the name of the mesh to create
  27329. * @param points is an array successive Vector3
  27330. * @param scene defines the hosting scene
  27331. * @param updatable defines if the mesh must be flagged as updatable
  27332. * @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).
  27333. * @returns a new Mesh
  27334. */
  27335. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27336. /**
  27337. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27338. * @param name defines the name of the mesh to create
  27339. * @param points is an array successive Vector3
  27340. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27341. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27342. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27343. * @param scene defines the hosting scene
  27344. * @param updatable defines if the mesh must be flagged as updatable
  27345. * @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)
  27346. * @returns a new Mesh
  27347. */
  27348. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27349. /**
  27350. * Creates a polygon mesh.
  27351. * Please consider using the same method from the MeshBuilder class instead.
  27352. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27353. * 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.
  27354. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27355. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27356. * Remember you can only change the shape positions, not their number when updating a polygon.
  27357. */
  27358. /**
  27359. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27360. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27361. * @param name defines the name of the mesh to create
  27362. * @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
  27363. * @param scene defines the hosting scene
  27364. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27365. * @param updatable defines if the mesh must be flagged as updatable
  27366. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27367. * @returns a new Mesh
  27368. */
  27369. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27370. /**
  27371. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27372. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27373. * @param name defines the name of the mesh to create
  27374. * @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
  27375. * @param depth defines the height of extrusion
  27376. * @param scene defines the hosting scene
  27377. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27378. * @param updatable defines if the mesh must be flagged as updatable
  27379. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27380. * @returns a new Mesh
  27381. */
  27382. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27383. /**
  27384. * Creates an extruded shape mesh.
  27385. * 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
  27386. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27387. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27388. * @param name defines the name of the mesh to create
  27389. * @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
  27390. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27391. * @param scale is the value to scale the shape
  27392. * @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
  27393. * @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
  27394. * @param scene defines the hosting scene
  27395. * @param updatable defines if the mesh must be flagged as updatable
  27396. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27397. * @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)
  27398. * @returns a new Mesh
  27399. */
  27400. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27401. /**
  27402. * Creates an custom extruded shape mesh.
  27403. * The custom extrusion is a parametric shape.
  27404. * It has no predefined shape. Its final shape will depend on the input parameters.
  27405. * Please consider using the same method from the MeshBuilder class instead
  27406. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27407. * @param name defines the name of the mesh to create
  27408. * @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
  27409. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27410. * @param scaleFunction is a custom Javascript function called on each path point
  27411. * @param rotationFunction is a custom Javascript function called on each path point
  27412. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27413. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27414. * @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
  27415. * @param scene defines the hosting scene
  27416. * @param updatable defines if the mesh must be flagged as updatable
  27417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27418. * @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)
  27419. * @returns a new Mesh
  27420. */
  27421. 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;
  27422. /**
  27423. * Creates lathe mesh.
  27424. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27425. * Please consider using the same method from the MeshBuilder class instead
  27426. * @param name defines the name of the mesh to create
  27427. * @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
  27428. * @param radius is the radius value of the lathe
  27429. * @param tessellation is the side number of the lathe.
  27430. * @param scene defines the hosting scene
  27431. * @param updatable defines if the mesh must be flagged as updatable
  27432. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27433. * @returns a new Mesh
  27434. */
  27435. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27436. /**
  27437. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27438. * @param name defines the name of the mesh to create
  27439. * @param size sets the size (float) of both sides of the plane at once (default 1)
  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. * @returns a new Mesh
  27444. */
  27445. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27446. /**
  27447. * Creates a ground mesh.
  27448. * Please consider using the same method from the MeshBuilder class instead
  27449. * @param name defines the name of the mesh to create
  27450. * @param width set the width of the ground
  27451. * @param height set the height of the ground
  27452. * @param subdivisions sets the number of subdivisions per side
  27453. * @param scene defines the hosting scene
  27454. * @param updatable defines if the mesh must be flagged as updatable
  27455. * @returns a new Mesh
  27456. */
  27457. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27458. /**
  27459. * Creates a tiled ground mesh.
  27460. * Please consider using the same method from the MeshBuilder class instead
  27461. * @param name defines the name of the mesh to create
  27462. * @param xmin set the ground minimum X coordinate
  27463. * @param zmin set the ground minimum Y coordinate
  27464. * @param xmax set the ground maximum X coordinate
  27465. * @param zmax set the ground maximum Z coordinate
  27466. * @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
  27467. * @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
  27468. * @param scene defines the hosting scene
  27469. * @param updatable defines if the mesh must be flagged as updatable
  27470. * @returns a new Mesh
  27471. */
  27472. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27473. w: number;
  27474. h: number;
  27475. }, precision: {
  27476. w: number;
  27477. h: number;
  27478. }, scene: Scene, updatable?: boolean): Mesh;
  27479. /**
  27480. * Creates a ground mesh from a height map.
  27481. * Please consider using the same method from the MeshBuilder class instead
  27482. * @see http://doc.babylonjs.com/babylon101/height_map
  27483. * @param name defines the name of the mesh to create
  27484. * @param url sets the URL of the height map image resource
  27485. * @param width set the ground width size
  27486. * @param height set the ground height size
  27487. * @param subdivisions sets the number of subdivision per side
  27488. * @param minHeight is the minimum altitude on the ground
  27489. * @param maxHeight is the maximum altitude on the ground
  27490. * @param scene defines the hosting scene
  27491. * @param updatable defines if the mesh must be flagged as updatable
  27492. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27493. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27494. * @returns a new Mesh
  27495. */
  27496. 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;
  27497. /**
  27498. * Creates a tube mesh.
  27499. * The tube is a parametric shape.
  27500. * It has no predefined shape. Its final shape will depend on the input parameters.
  27501. * Please consider using the same method from the MeshBuilder class instead
  27502. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27503. * @param name defines the name of the mesh to create
  27504. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27505. * @param radius sets the tube radius size
  27506. * @param tessellation is the number of sides on the tubular surface
  27507. * @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
  27508. * @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
  27509. * @param scene defines the hosting scene
  27510. * @param updatable defines if the mesh must be flagged as updatable
  27511. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27512. * @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)
  27513. * @returns a new Mesh
  27514. */
  27515. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27516. (i: number, distance: number): number;
  27517. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27518. /**
  27519. * Creates a polyhedron mesh.
  27520. * Please consider using the same method from the MeshBuilder class instead.
  27521. * * 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
  27522. * * The parameter `size` (positive float, default 1) sets the polygon size
  27523. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27524. * * 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`
  27525. * * 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
  27526. * * 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)`)
  27527. * * 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
  27528. * * 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
  27529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27530. * * 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
  27531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27532. * @param name defines the name of the mesh to create
  27533. * @param options defines the options used to create the mesh
  27534. * @param scene defines the hosting scene
  27535. * @returns a new Mesh
  27536. */
  27537. static CreatePolyhedron(name: string, options: {
  27538. type?: number;
  27539. size?: number;
  27540. sizeX?: number;
  27541. sizeY?: number;
  27542. sizeZ?: number;
  27543. custom?: any;
  27544. faceUV?: Vector4[];
  27545. faceColors?: Color4[];
  27546. updatable?: boolean;
  27547. sideOrientation?: number;
  27548. }, scene: Scene): Mesh;
  27549. /**
  27550. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27551. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27552. * * 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`)
  27553. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27554. * * 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
  27555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27556. * * 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
  27557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27558. * @param name defines the name of the mesh
  27559. * @param options defines the options used to create the mesh
  27560. * @param scene defines the hosting scene
  27561. * @returns a new Mesh
  27562. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27563. */
  27564. static CreateIcoSphere(name: string, options: {
  27565. radius?: number;
  27566. flat?: boolean;
  27567. subdivisions?: number;
  27568. sideOrientation?: number;
  27569. updatable?: boolean;
  27570. }, scene: Scene): Mesh;
  27571. /**
  27572. * Creates a decal mesh.
  27573. * Please consider using the same method from the MeshBuilder class instead.
  27574. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27575. * @param name defines the name of the mesh
  27576. * @param sourceMesh defines the mesh receiving the decal
  27577. * @param position sets the position of the decal in world coordinates
  27578. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27579. * @param size sets the decal scaling
  27580. * @param angle sets the angle to rotate the decal
  27581. * @returns a new Mesh
  27582. */
  27583. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27584. /**
  27585. * Prepare internal position array for software CPU skinning
  27586. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27587. */
  27588. setPositionsForCPUSkinning(): Float32Array;
  27589. /**
  27590. * Prepare internal normal array for software CPU skinning
  27591. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27592. */
  27593. setNormalsForCPUSkinning(): Float32Array;
  27594. /**
  27595. * Updates the vertex buffer by applying transformation from the bones
  27596. * @param skeleton defines the skeleton to apply to current mesh
  27597. * @returns the current mesh
  27598. */
  27599. applySkeleton(skeleton: Skeleton): Mesh;
  27600. /**
  27601. * 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
  27602. * @param meshes defines the list of meshes to scan
  27603. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27604. */
  27605. static MinMax(meshes: AbstractMesh[]): {
  27606. min: Vector3;
  27607. max: Vector3;
  27608. };
  27609. /**
  27610. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27611. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27612. * @returns a vector3
  27613. */
  27614. static Center(meshesOrMinMaxVector: {
  27615. min: Vector3;
  27616. max: Vector3;
  27617. } | AbstractMesh[]): Vector3;
  27618. /**
  27619. * Merge the array of meshes into a single mesh for performance reasons.
  27620. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27621. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27622. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27623. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27624. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27625. * @returns a new mesh
  27626. */
  27627. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27628. /** @hidden */
  27629. addInstance(instance: InstancedMesh): void;
  27630. /** @hidden */
  27631. removeInstance(instance: InstancedMesh): void;
  27632. }
  27633. }
  27634. declare module BABYLON {
  27635. /**
  27636. * Define an interface for all classes that will get and set the data on vertices
  27637. */
  27638. interface IGetSetVerticesData {
  27639. /**
  27640. * Gets a boolean indicating if specific vertex data is present
  27641. * @param kind defines the vertex data kind to use
  27642. * @returns true is data kind is present
  27643. */
  27644. isVerticesDataPresent(kind: string): boolean;
  27645. /**
  27646. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27647. * @param kind defines the data kind (Position, normal, etc...)
  27648. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27649. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27650. * @returns a float array containing vertex data
  27651. */
  27652. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27653. /**
  27654. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27655. * @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.
  27656. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27657. * @returns the indices array or an empty array if the mesh has no geometry
  27658. */
  27659. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27660. /**
  27661. * Set specific vertex data
  27662. * @param kind defines the data kind (Position, normal, etc...)
  27663. * @param data defines the vertex data to use
  27664. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27665. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27666. */
  27667. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27668. /**
  27669. * Update a specific associated vertex buffer
  27670. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27671. * - BABYLON.VertexBuffer.PositionKind
  27672. * - BABYLON.VertexBuffer.UVKind
  27673. * - BABYLON.VertexBuffer.UV2Kind
  27674. * - BABYLON.VertexBuffer.UV3Kind
  27675. * - BABYLON.VertexBuffer.UV4Kind
  27676. * - BABYLON.VertexBuffer.UV5Kind
  27677. * - BABYLON.VertexBuffer.UV6Kind
  27678. * - BABYLON.VertexBuffer.ColorKind
  27679. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27680. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27681. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27682. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27683. * @param data defines the data source
  27684. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27685. * @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)
  27686. */
  27687. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27688. /**
  27689. * Creates a new index buffer
  27690. * @param indices defines the indices to store in the index buffer
  27691. * @param totalVertices defines the total number of vertices (could be null)
  27692. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27693. */
  27694. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27695. }
  27696. /**
  27697. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27698. */
  27699. class VertexData {
  27700. /**
  27701. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27702. */
  27703. positions: Nullable<FloatArray>;
  27704. /**
  27705. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27706. */
  27707. normals: Nullable<FloatArray>;
  27708. /**
  27709. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27710. */
  27711. tangents: Nullable<FloatArray>;
  27712. /**
  27713. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27714. */
  27715. uvs: Nullable<FloatArray>;
  27716. /**
  27717. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27718. */
  27719. uvs2: Nullable<FloatArray>;
  27720. /**
  27721. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27722. */
  27723. uvs3: Nullable<FloatArray>;
  27724. /**
  27725. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27726. */
  27727. uvs4: Nullable<FloatArray>;
  27728. /**
  27729. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27730. */
  27731. uvs5: Nullable<FloatArray>;
  27732. /**
  27733. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27734. */
  27735. uvs6: Nullable<FloatArray>;
  27736. /**
  27737. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27738. */
  27739. colors: Nullable<FloatArray>;
  27740. /**
  27741. * 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).
  27742. */
  27743. matricesIndices: Nullable<FloatArray>;
  27744. /**
  27745. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27746. */
  27747. matricesWeights: Nullable<FloatArray>;
  27748. /**
  27749. * An array extending the number of possible indices
  27750. */
  27751. matricesIndicesExtra: Nullable<FloatArray>;
  27752. /**
  27753. * An array extending the number of possible weights when the number of indices is extended
  27754. */
  27755. matricesWeightsExtra: Nullable<FloatArray>;
  27756. /**
  27757. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27758. */
  27759. indices: Nullable<IndicesArray>;
  27760. /**
  27761. * Uses the passed data array to set the set the values for the specified kind of data
  27762. * @param data a linear array of floating numbers
  27763. * @param kind the type of data that is being set, eg positions, colors etc
  27764. */
  27765. set(data: FloatArray, kind: string): void;
  27766. /**
  27767. * Associates the vertexData to the passed Mesh.
  27768. * Sets it as updatable or not (default `false`)
  27769. * @param mesh the mesh the vertexData is applied to
  27770. * @param updatable when used and having the value true allows new data to update the vertexData
  27771. * @returns the VertexData
  27772. */
  27773. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27774. /**
  27775. * Associates the vertexData to the passed Geometry.
  27776. * Sets it as updatable or not (default `false`)
  27777. * @param geometry the geometry the vertexData is applied to
  27778. * @param updatable when used and having the value true allows new data to update the vertexData
  27779. * @returns VertexData
  27780. */
  27781. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27782. /**
  27783. * Updates the associated mesh
  27784. * @param mesh the mesh to be updated
  27785. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27786. * @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
  27787. * @returns VertexData
  27788. */
  27789. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27790. /**
  27791. * Updates the associated geometry
  27792. * @param geometry the geometry to be updated
  27793. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27794. * @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
  27795. * @returns VertexData.
  27796. */
  27797. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27798. private _applyTo;
  27799. private _update;
  27800. /**
  27801. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27802. * @param matrix the transforming matrix
  27803. * @returns the VertexData
  27804. */
  27805. transform(matrix: Matrix): VertexData;
  27806. /**
  27807. * Merges the passed VertexData into the current one
  27808. * @param other the VertexData to be merged into the current one
  27809. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27810. * @returns the modified VertexData
  27811. */
  27812. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27813. private _mergeElement;
  27814. private _validate;
  27815. /**
  27816. * Serializes the VertexData
  27817. * @returns a serialized object
  27818. */
  27819. serialize(): any;
  27820. /**
  27821. * Extracts the vertexData from a mesh
  27822. * @param mesh the mesh from which to extract the VertexData
  27823. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27824. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27825. * @returns the object VertexData associated to the passed mesh
  27826. */
  27827. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27828. /**
  27829. * Extracts the vertexData from the geometry
  27830. * @param geometry the geometry from which to extract the VertexData
  27831. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27832. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27833. * @returns the object VertexData associated to the passed mesh
  27834. */
  27835. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27836. private static _ExtractFrom;
  27837. /**
  27838. * Creates the VertexData for a Ribbon
  27839. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27840. * * pathArray array of paths, each of which an array of successive Vector3
  27841. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27842. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27843. * * 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
  27844. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27845. * * 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)
  27846. * * 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)
  27847. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27848. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27849. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27850. * @returns the VertexData of the ribbon
  27851. */
  27852. static CreateRibbon(options: {
  27853. pathArray: Vector3[][];
  27854. closeArray?: boolean;
  27855. closePath?: boolean;
  27856. offset?: number;
  27857. sideOrientation?: number;
  27858. frontUVs?: Vector4;
  27859. backUVs?: Vector4;
  27860. invertUV?: boolean;
  27861. uvs?: Vector2[];
  27862. colors?: Color4[];
  27863. }): VertexData;
  27864. /**
  27865. * Creates the VertexData for a box
  27866. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27867. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27868. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27869. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27870. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27871. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27872. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27873. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27874. * * 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)
  27875. * * 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)
  27876. * @returns the VertexData of the box
  27877. */
  27878. static CreateBox(options: {
  27879. size?: number;
  27880. width?: number;
  27881. height?: number;
  27882. depth?: number;
  27883. faceUV?: Vector4[];
  27884. faceColors?: Color4[];
  27885. sideOrientation?: number;
  27886. frontUVs?: Vector4;
  27887. backUVs?: Vector4;
  27888. }): VertexData;
  27889. /**
  27890. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27891. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27892. * * segments sets the number of horizontal strips optional, default 32
  27893. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27894. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27895. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27896. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27897. * * 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
  27898. * * 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
  27899. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27900. * * 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)
  27901. * * 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)
  27902. * @returns the VertexData of the ellipsoid
  27903. */
  27904. static CreateSphere(options: {
  27905. segments?: number;
  27906. diameter?: number;
  27907. diameterX?: number;
  27908. diameterY?: number;
  27909. diameterZ?: number;
  27910. arc?: number;
  27911. slice?: number;
  27912. sideOrientation?: number;
  27913. frontUVs?: Vector4;
  27914. backUVs?: Vector4;
  27915. }): VertexData;
  27916. /**
  27917. * Creates the VertexData for a cylinder, cone or prism
  27918. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27919. * * height sets the height (y direction) of the cylinder, optional, default 2
  27920. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27921. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27922. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27923. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27924. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27925. * * 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
  27926. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27927. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27928. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27929. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27930. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27931. * * 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)
  27932. * * 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)
  27933. * @returns the VertexData of the cylinder, cone or prism
  27934. */
  27935. static CreateCylinder(options: {
  27936. height?: number;
  27937. diameterTop?: number;
  27938. diameterBottom?: number;
  27939. diameter?: number;
  27940. tessellation?: number;
  27941. subdivisions?: number;
  27942. arc?: number;
  27943. faceColors?: Color4[];
  27944. faceUV?: Vector4[];
  27945. hasRings?: boolean;
  27946. enclose?: boolean;
  27947. sideOrientation?: number;
  27948. frontUVs?: Vector4;
  27949. backUVs?: Vector4;
  27950. }): VertexData;
  27951. /**
  27952. * Creates the VertexData for a torus
  27953. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27954. * * diameter the diameter of the torus, optional default 1
  27955. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27956. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27957. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27958. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27959. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27960. * @returns the VertexData of the torus
  27961. */
  27962. static CreateTorus(options: {
  27963. diameter?: number;
  27964. thickness?: number;
  27965. tessellation?: number;
  27966. sideOrientation?: number;
  27967. frontUVs?: Vector4;
  27968. backUVs?: Vector4;
  27969. }): VertexData;
  27970. /**
  27971. * Creates the VertexData of the LineSystem
  27972. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27973. * - lines an array of lines, each line being an array of successive Vector3
  27974. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27975. * @returns the VertexData of the LineSystem
  27976. */
  27977. static CreateLineSystem(options: {
  27978. lines: Vector3[][];
  27979. colors?: Nullable<Color4[][]>;
  27980. }): VertexData;
  27981. /**
  27982. * Create the VertexData for a DashedLines
  27983. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27984. * - points an array successive Vector3
  27985. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27986. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27987. * - dashNb the intended total number of dashes, optional, default 200
  27988. * @returns the VertexData for the DashedLines
  27989. */
  27990. static CreateDashedLines(options: {
  27991. points: Vector3[];
  27992. dashSize?: number;
  27993. gapSize?: number;
  27994. dashNb?: number;
  27995. }): VertexData;
  27996. /**
  27997. * Creates the VertexData for a Ground
  27998. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27999. * - width the width (x direction) of the ground, optional, default 1
  28000. * - height the height (z direction) of the ground, optional, default 1
  28001. * - subdivisions the number of subdivisions per side, optional, default 1
  28002. * @returns the VertexData of the Ground
  28003. */
  28004. static CreateGround(options: {
  28005. width?: number;
  28006. height?: number;
  28007. subdivisions?: number;
  28008. subdivisionsX?: number;
  28009. subdivisionsY?: number;
  28010. }): VertexData;
  28011. /**
  28012. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  28013. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28014. * * xmin the ground minimum X coordinate, optional, default -1
  28015. * * zmin the ground minimum Z coordinate, optional, default -1
  28016. * * xmax the ground maximum X coordinate, optional, default 1
  28017. * * zmax the ground maximum Z coordinate, optional, default 1
  28018. * * 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}
  28019. * * 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}
  28020. * @returns the VertexData of the TiledGround
  28021. */
  28022. static CreateTiledGround(options: {
  28023. xmin: number;
  28024. zmin: number;
  28025. xmax: number;
  28026. zmax: number;
  28027. subdivisions?: {
  28028. w: number;
  28029. h: number;
  28030. };
  28031. precision?: {
  28032. w: number;
  28033. h: number;
  28034. };
  28035. }): VertexData;
  28036. /**
  28037. * Creates the VertexData of the Ground designed from a heightmap
  28038. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  28039. * * width the width (x direction) of the ground
  28040. * * height the height (z direction) of the ground
  28041. * * subdivisions the number of subdivisions per side
  28042. * * minHeight the minimum altitude on the ground, optional, default 0
  28043. * * maxHeight the maximum altitude on the ground, optional default 1
  28044. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  28045. * * buffer the array holding the image color data
  28046. * * bufferWidth the width of image
  28047. * * bufferHeight the height of image
  28048. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  28049. * @returns the VertexData of the Ground designed from a heightmap
  28050. */
  28051. static CreateGroundFromHeightMap(options: {
  28052. width: number;
  28053. height: number;
  28054. subdivisions: number;
  28055. minHeight: number;
  28056. maxHeight: number;
  28057. colorFilter: Color3;
  28058. buffer: Uint8Array;
  28059. bufferWidth: number;
  28060. bufferHeight: number;
  28061. alphaFilter: number;
  28062. }): VertexData;
  28063. /**
  28064. * Creates the VertexData for a Plane
  28065. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  28066. * * size sets the width and height of the plane to the value of size, optional default 1
  28067. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28068. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28069. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28070. * * 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)
  28071. * * 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)
  28072. * @returns the VertexData of the box
  28073. */
  28074. static CreatePlane(options: {
  28075. size?: number;
  28076. width?: number;
  28077. height?: number;
  28078. sideOrientation?: number;
  28079. frontUVs?: Vector4;
  28080. backUVs?: Vector4;
  28081. }): VertexData;
  28082. /**
  28083. * Creates the VertexData of the Disc or regular Polygon
  28084. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28085. * * radius the radius of the disc, optional default 0.5
  28086. * * tessellation the number of polygon sides, optional, default 64
  28087. * * 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
  28088. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28089. * * 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)
  28090. * * 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)
  28091. * @returns the VertexData of the box
  28092. */
  28093. static CreateDisc(options: {
  28094. radius?: number;
  28095. tessellation?: number;
  28096. arc?: number;
  28097. sideOrientation?: number;
  28098. frontUVs?: Vector4;
  28099. backUVs?: Vector4;
  28100. }): VertexData;
  28101. /**
  28102. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28103. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28104. * @param polygon a mesh built from polygonTriangulation.build()
  28105. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28106. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28107. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28108. * @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)
  28109. * @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)
  28110. * @returns the VertexData of the Polygon
  28111. */
  28112. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28113. /**
  28114. * Creates the VertexData of the IcoSphere
  28115. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28116. * * radius the radius of the IcoSphere, optional default 1
  28117. * * radiusX allows stretching in the x direction, optional, default radius
  28118. * * radiusY allows stretching in the y direction, optional, default radius
  28119. * * radiusZ allows stretching in the z direction, optional, default radius
  28120. * * flat when true creates a flat shaded mesh, optional, default true
  28121. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28122. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28123. * * 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)
  28124. * * 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)
  28125. * @returns the VertexData of the IcoSphere
  28126. */
  28127. static CreateIcoSphere(options: {
  28128. radius?: number;
  28129. radiusX?: number;
  28130. radiusY?: number;
  28131. radiusZ?: number;
  28132. flat?: boolean;
  28133. subdivisions?: number;
  28134. sideOrientation?: number;
  28135. frontUVs?: Vector4;
  28136. backUVs?: Vector4;
  28137. }): VertexData;
  28138. /**
  28139. * Creates the VertexData for a Polyhedron
  28140. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28141. * * type provided types are:
  28142. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28143. * * 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)
  28144. * * size the size of the IcoSphere, optional default 1
  28145. * * sizeX allows stretching in the x direction, optional, default size
  28146. * * sizeY allows stretching in the y direction, optional, default size
  28147. * * sizeZ allows stretching in the z direction, optional, default size
  28148. * * 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
  28149. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28150. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28151. * * flat when true creates a flat shaded mesh, optional, default true
  28152. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28153. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28154. * * 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. * * 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 Polyhedron
  28157. */
  28158. static CreatePolyhedron(options: {
  28159. type?: number;
  28160. size?: number;
  28161. sizeX?: number;
  28162. sizeY?: number;
  28163. sizeZ?: number;
  28164. custom?: any;
  28165. faceUV?: Vector4[];
  28166. faceColors?: Color4[];
  28167. flat?: boolean;
  28168. sideOrientation?: number;
  28169. frontUVs?: Vector4;
  28170. backUVs?: Vector4;
  28171. }): VertexData;
  28172. /**
  28173. * Creates the VertexData for a TorusKnot
  28174. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28175. * * radius the radius of the torus knot, optional, default 2
  28176. * * tube the thickness of the tube, optional, default 0.5
  28177. * * radialSegments the number of sides on each tube segments, optional, default 32
  28178. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28179. * * p the number of windings around the z axis, optional, default 2
  28180. * * q the number of windings around the x axis, optional, default 3
  28181. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28182. * * 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)
  28183. * * 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)
  28184. * @returns the VertexData of the Torus Knot
  28185. */
  28186. static CreateTorusKnot(options: {
  28187. radius?: number;
  28188. tube?: number;
  28189. radialSegments?: number;
  28190. tubularSegments?: number;
  28191. p?: number;
  28192. q?: number;
  28193. sideOrientation?: number;
  28194. frontUVs?: Vector4;
  28195. backUVs?: Vector4;
  28196. }): VertexData;
  28197. /**
  28198. * Compute normals for given positions and indices
  28199. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28200. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28201. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28202. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28203. * * facetNormals : optional array of facet normals (vector3)
  28204. * * facetPositions : optional array of facet positions (vector3)
  28205. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28206. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28207. * * bInfo : optional bounding info, required for facetPartitioning computation
  28208. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28209. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28210. * * useRightHandedSystem: optional boolean to for right handed system computation
  28211. * * depthSort : optional boolean to enable the facet depth sort computation
  28212. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28213. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28214. */
  28215. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28216. facetNormals?: any;
  28217. facetPositions?: any;
  28218. facetPartitioning?: any;
  28219. ratio?: number;
  28220. bInfo?: any;
  28221. bbSize?: Vector3;
  28222. subDiv?: any;
  28223. useRightHandedSystem?: boolean;
  28224. depthSort?: boolean;
  28225. distanceTo?: Vector3;
  28226. depthSortedFacets?: any;
  28227. }): void;
  28228. private static _ComputeSides;
  28229. /**
  28230. * Applies VertexData created from the imported parameters to the geometry
  28231. * @param parsedVertexData the parsed data from an imported file
  28232. * @param geometry the geometry to apply the VertexData to
  28233. */
  28234. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28235. }
  28236. }
  28237. declare module BABYLON {
  28238. /**
  28239. * Class containing static functions to help procedurally build meshes
  28240. */
  28241. class MeshBuilder {
  28242. private static updateSideOrientation;
  28243. /**
  28244. * Creates a box mesh
  28245. * * The parameter `size` sets the size (float) of each box side (default 1)
  28246. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28247. * * 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)
  28248. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28250. * * 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
  28251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28252. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  28253. * @param name defines the name of the mesh
  28254. * @param options defines the options used to create the mesh
  28255. * @param scene defines the hosting scene
  28256. * @returns the box mesh
  28257. */
  28258. static CreateBox(name: string, options: {
  28259. size?: number;
  28260. width?: number;
  28261. height?: number;
  28262. depth?: number;
  28263. faceUV?: Vector4[];
  28264. faceColors?: Color4[];
  28265. sideOrientation?: number;
  28266. frontUVs?: Vector4;
  28267. backUVs?: Vector4;
  28268. updatable?: boolean;
  28269. }, scene?: Nullable<Scene>): Mesh;
  28270. /**
  28271. * Creates a sphere mesh
  28272. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28273. * * 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`)
  28274. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28275. * * 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
  28276. * * 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)
  28277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28278. * * 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
  28279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28280. * @param name defines the name of the mesh
  28281. * @param options defines the options used to create the mesh
  28282. * @param scene defines the hosting scene
  28283. * @returns the sphere mesh
  28284. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  28285. */
  28286. static CreateSphere(name: string, options: {
  28287. segments?: number;
  28288. diameter?: number;
  28289. diameterX?: number;
  28290. diameterY?: number;
  28291. diameterZ?: number;
  28292. arc?: number;
  28293. slice?: number;
  28294. sideOrientation?: number;
  28295. frontUVs?: Vector4;
  28296. backUVs?: Vector4;
  28297. updatable?: boolean;
  28298. }, scene: any): Mesh;
  28299. /**
  28300. * Creates a plane polygonal mesh. By default, this is a disc
  28301. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28302. * * 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
  28303. * * 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
  28304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28305. * * 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
  28306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28307. * @param name defines the name of the mesh
  28308. * @param options defines the options used to create the mesh
  28309. * @param scene defines the hosting scene
  28310. * @returns the plane polygonal mesh
  28311. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28312. */
  28313. static CreateDisc(name: string, options: {
  28314. radius?: number;
  28315. tessellation?: number;
  28316. arc?: number;
  28317. updatable?: boolean;
  28318. sideOrientation?: number;
  28319. frontUVs?: Vector4;
  28320. backUVs?: Vector4;
  28321. }, scene?: Nullable<Scene>): Mesh;
  28322. /**
  28323. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28324. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28325. * * 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`)
  28326. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28327. * * 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
  28328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28329. * * 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
  28330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28331. * @param name defines the name of the mesh
  28332. * @param options defines the options used to create the mesh
  28333. * @param scene defines the hosting scene
  28334. * @returns the icosahedron mesh
  28335. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28336. */
  28337. static CreateIcoSphere(name: string, options: {
  28338. radius?: number;
  28339. radiusX?: number;
  28340. radiusY?: number;
  28341. radiusZ?: number;
  28342. flat?: boolean;
  28343. subdivisions?: number;
  28344. sideOrientation?: number;
  28345. frontUVs?: Vector4;
  28346. backUVs?: Vector4;
  28347. updatable?: boolean;
  28348. }, scene: Scene): Mesh;
  28349. /**
  28350. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28351. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28352. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28353. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28354. * * 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
  28355. * * 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
  28356. * * 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
  28357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28358. * * 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
  28359. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28360. * * 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
  28361. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28362. * * 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
  28363. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28365. * @param name defines the name of the mesh
  28366. * @param options defines the options used to create the mesh
  28367. * @param scene defines the hosting scene
  28368. * @returns the ribbon mesh
  28369. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  28370. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28371. */
  28372. static CreateRibbon(name: string, options: {
  28373. pathArray: Vector3[][];
  28374. closeArray?: boolean;
  28375. closePath?: boolean;
  28376. offset?: number;
  28377. updatable?: boolean;
  28378. sideOrientation?: number;
  28379. frontUVs?: Vector4;
  28380. backUVs?: Vector4;
  28381. instance?: Mesh;
  28382. invertUV?: boolean;
  28383. uvs?: Vector2[];
  28384. colors?: Color4[];
  28385. }, scene?: Nullable<Scene>): Mesh;
  28386. /**
  28387. * Creates a cylinder or a cone mesh
  28388. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28389. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28390. * * 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.
  28391. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28392. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28393. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28394. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28395. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28396. * * 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).
  28397. * * 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
  28398. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28399. * * 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
  28400. * * 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.
  28401. * * If `enclose` is false, a ring surface is one element.
  28402. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28403. * * 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
  28404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28405. * * 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
  28406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28407. * @param name defines the name of the mesh
  28408. * @param options defines the options used to create the mesh
  28409. * @param scene defines the hosting scene
  28410. * @returns the cylinder mesh
  28411. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  28412. */
  28413. static CreateCylinder(name: string, options: {
  28414. height?: number;
  28415. diameterTop?: number;
  28416. diameterBottom?: number;
  28417. diameter?: number;
  28418. tessellation?: number;
  28419. subdivisions?: number;
  28420. arc?: number;
  28421. faceColors?: Color4[];
  28422. faceUV?: Vector4[];
  28423. updatable?: boolean;
  28424. hasRings?: boolean;
  28425. enclose?: boolean;
  28426. sideOrientation?: number;
  28427. frontUVs?: Vector4;
  28428. backUVs?: Vector4;
  28429. }, scene: any): Mesh;
  28430. /**
  28431. * Creates a torus mesh
  28432. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28433. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28434. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28436. * * 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
  28437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28438. * @param name defines the name of the mesh
  28439. * @param options defines the options used to create the mesh
  28440. * @param scene defines the hosting scene
  28441. * @returns the torus mesh
  28442. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  28443. */
  28444. static CreateTorus(name: string, options: {
  28445. diameter?: number;
  28446. thickness?: number;
  28447. tessellation?: number;
  28448. updatable?: boolean;
  28449. sideOrientation?: number;
  28450. frontUVs?: Vector4;
  28451. backUVs?: Vector4;
  28452. }, scene: any): Mesh;
  28453. /**
  28454. * Creates a torus knot mesh
  28455. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28456. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28457. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28458. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28460. * * 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
  28461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28462. * @param name defines the name of the mesh
  28463. * @param options defines the options used to create the mesh
  28464. * @param scene defines the hosting scene
  28465. * @returns the torus knot mesh
  28466. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  28467. */
  28468. static CreateTorusKnot(name: string, options: {
  28469. radius?: number;
  28470. tube?: number;
  28471. radialSegments?: number;
  28472. tubularSegments?: number;
  28473. p?: number;
  28474. q?: number;
  28475. updatable?: boolean;
  28476. sideOrientation?: number;
  28477. frontUVs?: Vector4;
  28478. backUVs?: Vector4;
  28479. }, scene: any): Mesh;
  28480. /**
  28481. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28482. * * 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
  28483. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28484. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28485. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28486. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28487. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28488. * * 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
  28489. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28491. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28492. * @param name defines the name of the new line system
  28493. * @param options defines the options used to create the line system
  28494. * @param scene defines the hosting scene
  28495. * @returns a new line system mesh
  28496. */
  28497. static CreateLineSystem(name: string, options: {
  28498. lines: Vector3[][];
  28499. updatable?: boolean;
  28500. instance?: Nullable<LinesMesh>;
  28501. colors?: Nullable<Color4[][]>;
  28502. useVertexAlpha?: boolean;
  28503. }, scene: Nullable<Scene>): LinesMesh;
  28504. /**
  28505. * Creates a line mesh
  28506. * 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
  28507. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28508. * * The parameter `points` is an array successive Vector3
  28509. * * 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
  28510. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28511. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28512. * * When updating an instance, remember that only point positions can change, not the number of points
  28513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28514. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  28515. * @param name defines the name of the new line system
  28516. * @param options defines the options used to create the line system
  28517. * @param scene defines the hosting scene
  28518. * @returns a new line mesh
  28519. */
  28520. static CreateLines(name: string, options: {
  28521. points: Vector3[];
  28522. updatable?: boolean;
  28523. instance?: Nullable<LinesMesh>;
  28524. colors?: Color4[];
  28525. useVertexAlpha?: boolean;
  28526. }, scene?: Nullable<Scene>): LinesMesh;
  28527. /**
  28528. * Creates a dashed line mesh
  28529. * * 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
  28530. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28531. * * The parameter `points` is an array successive Vector3
  28532. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28533. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28534. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28535. * * 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
  28536. * * When updating an instance, remember that only point positions can change, not the number of points
  28537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28538. * @param name defines the name of the mesh
  28539. * @param options defines the options used to create the mesh
  28540. * @param scene defines the hosting scene
  28541. * @returns the dashed line mesh
  28542. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28543. */
  28544. static CreateDashedLines(name: string, options: {
  28545. points: Vector3[];
  28546. dashSize?: number;
  28547. gapSize?: number;
  28548. dashNb?: number;
  28549. updatable?: boolean;
  28550. instance?: LinesMesh;
  28551. }, scene?: Nullable<Scene>): LinesMesh;
  28552. /**
  28553. * 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.
  28554. * * 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.
  28555. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28556. * * 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.
  28557. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28558. * * 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
  28559. * * 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
  28560. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28562. * * 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
  28563. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28565. * @param name defines the name of the mesh
  28566. * @param options defines the options used to create the mesh
  28567. * @param scene defines the hosting scene
  28568. * @returns the extruded shape mesh
  28569. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28570. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28571. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28572. */
  28573. static ExtrudeShape(name: string, options: {
  28574. shape: Vector3[];
  28575. path: Vector3[];
  28576. scale?: number;
  28577. rotation?: number;
  28578. cap?: number;
  28579. updatable?: boolean;
  28580. sideOrientation?: number;
  28581. frontUVs?: Vector4;
  28582. backUVs?: Vector4;
  28583. instance?: Mesh;
  28584. invertUV?: boolean;
  28585. }, scene?: Nullable<Scene>): Mesh;
  28586. /**
  28587. * Creates an custom extruded shape mesh.
  28588. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28589. * * 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.
  28590. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28591. * * 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
  28592. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28593. * * 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
  28594. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28595. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28596. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28597. * * 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
  28598. * * 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
  28599. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28601. * * 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
  28602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28604. * @param name defines the name of the mesh
  28605. * @param options defines the options used to create the mesh
  28606. * @param scene defines the hosting scene
  28607. * @returns the custom extruded shape mesh
  28608. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28609. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28610. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28611. */
  28612. static ExtrudeShapeCustom(name: string, options: {
  28613. shape: Vector3[];
  28614. path: Vector3[];
  28615. scaleFunction?: any;
  28616. rotationFunction?: any;
  28617. ribbonCloseArray?: boolean;
  28618. ribbonClosePath?: boolean;
  28619. cap?: number;
  28620. updatable?: boolean;
  28621. sideOrientation?: number;
  28622. frontUVs?: Vector4;
  28623. backUVs?: Vector4;
  28624. instance?: Mesh;
  28625. invertUV?: boolean;
  28626. }, scene: Scene): Mesh;
  28627. /**
  28628. * Creates lathe mesh.
  28629. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28630. * * 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
  28631. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28632. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28633. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28634. * * 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
  28635. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28636. * * 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
  28637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28638. * * 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
  28639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28641. * @param name defines the name of the mesh
  28642. * @param options defines the options used to create the mesh
  28643. * @param scene defines the hosting scene
  28644. * @returns the lathe mesh
  28645. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28646. */
  28647. static CreateLathe(name: string, options: {
  28648. shape: Vector3[];
  28649. radius?: number;
  28650. tessellation?: number;
  28651. clip?: number;
  28652. arc?: number;
  28653. closed?: boolean;
  28654. updatable?: boolean;
  28655. sideOrientation?: number;
  28656. frontUVs?: Vector4;
  28657. backUVs?: Vector4;
  28658. cap?: number;
  28659. invertUV?: boolean;
  28660. }, scene: Scene): Mesh;
  28661. /**
  28662. * Creates a plane mesh
  28663. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28664. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28665. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28669. * @param name defines the name of the mesh
  28670. * @param options defines the options used to create the mesh
  28671. * @param scene defines the hosting scene
  28672. * @returns the plane mesh
  28673. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28674. */
  28675. static CreatePlane(name: string, options: {
  28676. size?: number;
  28677. width?: number;
  28678. height?: number;
  28679. sideOrientation?: number;
  28680. frontUVs?: Vector4;
  28681. backUVs?: Vector4;
  28682. updatable?: boolean;
  28683. sourcePlane?: Plane;
  28684. }, scene: Scene): Mesh;
  28685. /**
  28686. * Creates a ground mesh
  28687. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28688. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28690. * @param name defines the name of the mesh
  28691. * @param options defines the options used to create the mesh
  28692. * @param scene defines the hosting scene
  28693. * @returns the ground mesh
  28694. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28695. */
  28696. static CreateGround(name: string, options: {
  28697. width?: number;
  28698. height?: number;
  28699. subdivisions?: number;
  28700. subdivisionsX?: number;
  28701. subdivisionsY?: number;
  28702. updatable?: boolean;
  28703. }, scene: any): Mesh;
  28704. /**
  28705. * Creates a tiled ground mesh
  28706. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28707. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28708. * * 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
  28709. * * 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
  28710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28711. * @param name defines the name of the mesh
  28712. * @param options defines the options used to create the mesh
  28713. * @param scene defines the hosting scene
  28714. * @returns the tiled ground mesh
  28715. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  28716. */
  28717. static CreateTiledGround(name: string, options: {
  28718. xmin: number;
  28719. zmin: number;
  28720. xmax: number;
  28721. zmax: number;
  28722. subdivisions?: {
  28723. w: number;
  28724. h: number;
  28725. };
  28726. precision?: {
  28727. w: number;
  28728. h: number;
  28729. };
  28730. updatable?: boolean;
  28731. }, scene: Scene): Mesh;
  28732. /**
  28733. * Creates a ground mesh from a height map
  28734. * * The parameter `url` sets the URL of the height map image resource.
  28735. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28736. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28737. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28738. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28739. * * 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.
  28740. * * 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).
  28741. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28743. * @param name defines the name of the mesh
  28744. * @param url defines the url to the height map
  28745. * @param options defines the options used to create the mesh
  28746. * @param scene defines the hosting scene
  28747. * @returns the ground mesh
  28748. * @see http://doc.babylonjs.com/babylon101/height_map
  28749. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  28750. */
  28751. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28752. width?: number;
  28753. height?: number;
  28754. subdivisions?: number;
  28755. minHeight?: number;
  28756. maxHeight?: number;
  28757. colorFilter?: Color3;
  28758. alphaFilter?: number;
  28759. updatable?: boolean;
  28760. onReady?: (mesh: GroundMesh) => void;
  28761. }, scene: Scene): GroundMesh;
  28762. /**
  28763. * Creates a polygon mesh
  28764. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28765. * * 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
  28766. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28768. * * 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)
  28769. * * Remember you can only change the shape positions, not their number when updating a polygon
  28770. * @param name defines the name of the mesh
  28771. * @param options defines the options used to create the mesh
  28772. * @param scene defines the hosting scene
  28773. * @returns the polygon mesh
  28774. */
  28775. static CreatePolygon(name: string, options: {
  28776. shape: Vector3[];
  28777. holes?: Vector3[][];
  28778. depth?: number;
  28779. faceUV?: Vector4[];
  28780. faceColors?: Color4[];
  28781. updatable?: boolean;
  28782. sideOrientation?: number;
  28783. frontUVs?: Vector4;
  28784. backUVs?: Vector4;
  28785. }, scene: Scene): Mesh;
  28786. /**
  28787. * Creates an extruded polygon mesh, with depth in the Y direction.
  28788. * * 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)
  28789. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28790. * @param name defines the name of the mesh
  28791. * @param options defines the options used to create the mesh
  28792. * @param scene defines the hosting scene
  28793. * @returns the polygon mesh
  28794. */
  28795. static ExtrudePolygon(name: string, options: {
  28796. shape: Vector3[];
  28797. holes?: Vector3[][];
  28798. depth?: number;
  28799. faceUV?: Vector4[];
  28800. faceColors?: Color4[];
  28801. updatable?: boolean;
  28802. sideOrientation?: number;
  28803. frontUVs?: Vector4;
  28804. backUVs?: Vector4;
  28805. }, scene: Scene): Mesh;
  28806. /**
  28807. * Creates a tube mesh.
  28808. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28809. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28810. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28811. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28812. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28813. * * 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)
  28814. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28815. * * 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
  28816. * * 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
  28817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28818. * * 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
  28819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28821. * @param name defines the name of the mesh
  28822. * @param options defines the options used to create the mesh
  28823. * @param scene defines the hosting scene
  28824. * @returns the tube mesh
  28825. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28826. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  28827. */
  28828. static CreateTube(name: string, options: {
  28829. path: Vector3[];
  28830. radius?: number;
  28831. tessellation?: number;
  28832. radiusFunction?: {
  28833. (i: number, distance: number): number;
  28834. };
  28835. cap?: number;
  28836. arc?: number;
  28837. updatable?: boolean;
  28838. sideOrientation?: number;
  28839. frontUVs?: Vector4;
  28840. backUVs?: Vector4;
  28841. instance?: Mesh;
  28842. invertUV?: boolean;
  28843. }, scene: Scene): Mesh;
  28844. /**
  28845. * Creates a polyhedron mesh
  28846. * * 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
  28847. * * The parameter `size` (positive float, default 1) sets the polygon size
  28848. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28849. * * 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`
  28850. * * 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
  28851. * * 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)`)
  28852. * * 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
  28853. * * 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
  28854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28855. * * 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
  28856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28857. * @param name defines the name of the mesh
  28858. * @param options defines the options used to create the mesh
  28859. * @param scene defines the hosting scene
  28860. * @returns the polyhedron mesh
  28861. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  28862. */
  28863. static CreatePolyhedron(name: string, options: {
  28864. type?: number;
  28865. size?: number;
  28866. sizeX?: number;
  28867. sizeY?: number;
  28868. sizeZ?: number;
  28869. custom?: any;
  28870. faceUV?: Vector4[];
  28871. faceColors?: Color4[];
  28872. flat?: boolean;
  28873. updatable?: boolean;
  28874. sideOrientation?: number;
  28875. frontUVs?: Vector4;
  28876. backUVs?: Vector4;
  28877. }, scene: Scene): Mesh;
  28878. /**
  28879. * Creates a decal mesh.
  28880. * 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
  28881. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28882. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28883. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28884. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28885. * @param name defines the name of the mesh
  28886. * @param sourceMesh defines the mesh where the decal must be applied
  28887. * @param options defines the options used to create the mesh
  28888. * @param scene defines the hosting scene
  28889. * @returns the decal mesh
  28890. * @see http://doc.babylonjs.com/how_to/decals
  28891. */
  28892. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28893. position?: Vector3;
  28894. normal?: Vector3;
  28895. size?: Vector3;
  28896. angle?: number;
  28897. }): Mesh;
  28898. private static _ExtrudeShapeGeneric;
  28899. }
  28900. }
  28901. declare module BABYLON {
  28902. /**
  28903. * Class used to represent a specific level of detail of a mesh
  28904. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28905. */
  28906. class MeshLODLevel {
  28907. /** Defines the distance where this level should star being displayed */
  28908. distance: number;
  28909. /** Defines the mesh to use to render this level */
  28910. mesh: Nullable<Mesh>;
  28911. /**
  28912. * Creates a new LOD level
  28913. * @param distance defines the distance where this level should star being displayed
  28914. * @param mesh defines the mesh to use to render this level
  28915. */
  28916. constructor(
  28917. /** Defines the distance where this level should star being displayed */
  28918. distance: number,
  28919. /** Defines the mesh to use to render this level */
  28920. mesh: Nullable<Mesh>);
  28921. }
  28922. }
  28923. declare module BABYLON {
  28924. /**
  28925. * A simplifier interface for future simplification implementations
  28926. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28927. */
  28928. interface ISimplifier {
  28929. /**
  28930. * Simplification of a given mesh according to the given settings.
  28931. * Since this requires computation, it is assumed that the function runs async.
  28932. * @param settings The settings of the simplification, including quality and distance
  28933. * @param successCallback A callback that will be called after the mesh was simplified.
  28934. * @param errorCallback in case of an error, this callback will be called. optional.
  28935. */
  28936. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28937. }
  28938. /**
  28939. * Expected simplification settings.
  28940. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28941. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28942. */
  28943. interface ISimplificationSettings {
  28944. /**
  28945. * Gets or sets the expected quality
  28946. */
  28947. quality: number;
  28948. /**
  28949. * Gets or sets the distance when this optimized version should be used
  28950. */
  28951. distance: number;
  28952. /**
  28953. * Gets an already optimized mesh
  28954. */
  28955. optimizeMesh?: boolean;
  28956. }
  28957. /**
  28958. * Class used to specify simplification options
  28959. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28960. */
  28961. class SimplificationSettings implements ISimplificationSettings {
  28962. /** expected quality */
  28963. quality: number;
  28964. /** distance when this optimized version should be used */
  28965. distance: number;
  28966. /** already optimized mesh */
  28967. optimizeMesh?: boolean | undefined;
  28968. /**
  28969. * Creates a SimplificationSettings
  28970. * @param quality expected quality
  28971. * @param distance distance when this optimized version should be used
  28972. * @param optimizeMesh already optimized mesh
  28973. */
  28974. constructor(
  28975. /** expected quality */
  28976. quality: number,
  28977. /** distance when this optimized version should be used */
  28978. distance: number,
  28979. /** already optimized mesh */
  28980. optimizeMesh?: boolean | undefined);
  28981. }
  28982. /**
  28983. * Interface used to define a simplification task
  28984. */
  28985. interface ISimplificationTask {
  28986. /**
  28987. * Array of settings
  28988. */
  28989. settings: Array<ISimplificationSettings>;
  28990. /**
  28991. * Simplification type
  28992. */
  28993. simplificationType: SimplificationType;
  28994. /**
  28995. * Mesh to simplify
  28996. */
  28997. mesh: Mesh;
  28998. /**
  28999. * Callback called on success
  29000. */
  29001. successCallback?: () => void;
  29002. /**
  29003. * Defines if parallel processing can be used
  29004. */
  29005. parallelProcessing: boolean;
  29006. }
  29007. /**
  29008. * Queue used to order the simplification tasks
  29009. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29010. */
  29011. class SimplificationQueue {
  29012. private _simplificationArray;
  29013. /**
  29014. * Gets a boolean indicating that the process is still running
  29015. */
  29016. running: boolean;
  29017. /**
  29018. * Creates a new queue
  29019. */
  29020. constructor();
  29021. /**
  29022. * Adds a new simplification task
  29023. * @param task defines a task to add
  29024. */
  29025. addTask(task: ISimplificationTask): void;
  29026. /**
  29027. * Execute next task
  29028. */
  29029. executeNext(): void;
  29030. /**
  29031. * Execute a simplification task
  29032. * @param task defines the task to run
  29033. */
  29034. runSimplification(task: ISimplificationTask): void;
  29035. private getSimplifier;
  29036. }
  29037. /**
  29038. * The implemented types of simplification
  29039. * At the moment only Quadratic Error Decimation is implemented
  29040. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29041. */
  29042. enum SimplificationType {
  29043. /** Quadratic error decimation */
  29044. QUADRATIC = 0
  29045. }
  29046. }
  29047. declare module BABYLON {
  29048. interface Scene {
  29049. /** @hidden (Backing field) */
  29050. _simplificationQueue: SimplificationQueue;
  29051. /**
  29052. * Gets or sets the simplification queue attached to the scene
  29053. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29054. */
  29055. simplificationQueue: SimplificationQueue;
  29056. }
  29057. interface Mesh {
  29058. /**
  29059. * Simplify the mesh according to the given array of settings.
  29060. * Function will return immediately and will simplify async
  29061. * @param settings a collection of simplification settings
  29062. * @param parallelProcessing should all levels calculate parallel or one after the other
  29063. * @param simplificationType the type of simplification to run
  29064. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  29065. * @returns the current mesh
  29066. */
  29067. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  29068. }
  29069. /**
  29070. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29071. * created in a scene
  29072. */
  29073. class SimplicationQueueSceneComponent implements ISceneComponent {
  29074. /**
  29075. * The component name helpfull to identify the component in the list of scene components.
  29076. */
  29077. readonly name: string;
  29078. /**
  29079. * The scene the component belongs to.
  29080. */
  29081. scene: Scene;
  29082. /**
  29083. * Creates a new instance of the component for the given scene
  29084. * @param scene Defines the scene to register the component in
  29085. */
  29086. constructor(scene: Scene);
  29087. /**
  29088. * Registers the component in a given scene
  29089. */
  29090. register(): void;
  29091. /**
  29092. * Rebuilds the elements related to this component in case of
  29093. * context lost for instance.
  29094. */
  29095. rebuild(): void;
  29096. /**
  29097. * Disposes the component and the associated ressources
  29098. */
  29099. dispose(): void;
  29100. private _beforeCameraUpdate;
  29101. }
  29102. }
  29103. declare module BABYLON {
  29104. /**
  29105. * Polygon
  29106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29107. */
  29108. class Polygon {
  29109. /**
  29110. * Creates a rectangle
  29111. * @param xmin bottom X coord
  29112. * @param ymin bottom Y coord
  29113. * @param xmax top X coord
  29114. * @param ymax top Y coord
  29115. * @returns points that make the resulting rectation
  29116. */
  29117. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29118. /**
  29119. * Creates a circle
  29120. * @param radius radius of circle
  29121. * @param cx scale in x
  29122. * @param cy scale in y
  29123. * @param numberOfSides number of sides that make up the circle
  29124. * @returns points that make the resulting circle
  29125. */
  29126. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29127. /**
  29128. * Creates a polygon from input string
  29129. * @param input Input polygon data
  29130. * @returns the parsed points
  29131. */
  29132. static Parse(input: string): Vector2[];
  29133. /**
  29134. * Starts building a polygon from x and y coordinates
  29135. * @param x x coordinate
  29136. * @param y y coordinate
  29137. * @returns the started path2
  29138. */
  29139. static StartingAt(x: number, y: number): Path2;
  29140. }
  29141. /**
  29142. * Builds a polygon
  29143. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29144. */
  29145. class PolygonMeshBuilder {
  29146. private _points;
  29147. private _outlinepoints;
  29148. private _holes;
  29149. private _name;
  29150. private _scene;
  29151. private _epoints;
  29152. private _eholes;
  29153. private _addToepoint;
  29154. /**
  29155. * Creates a PolygonMeshBuilder
  29156. * @param name name of the builder
  29157. * @param contours Path of the polygon
  29158. * @param scene scene to add to
  29159. */
  29160. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29161. /**
  29162. * Adds a whole within the polygon
  29163. * @param hole Array of points defining the hole
  29164. * @returns this
  29165. */
  29166. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29167. /**
  29168. * Creates the polygon
  29169. * @param updatable If the mesh should be updatable
  29170. * @param depth The depth of the mesh created
  29171. * @returns the created mesh
  29172. */
  29173. build(updatable?: boolean, depth?: number): Mesh;
  29174. /**
  29175. * Adds a side to the polygon
  29176. * @param positions points that make the polygon
  29177. * @param normals normals of the polygon
  29178. * @param uvs uvs of the polygon
  29179. * @param indices indices of the polygon
  29180. * @param bounds bounds of the polygon
  29181. * @param points points of the polygon
  29182. * @param depth depth of the polygon
  29183. * @param flip flip of the polygon
  29184. */
  29185. private addSide;
  29186. }
  29187. }
  29188. declare module BABYLON {
  29189. /**
  29190. * Base class for submeshes
  29191. */
  29192. class BaseSubMesh {
  29193. /** @hidden */
  29194. _materialDefines: Nullable<MaterialDefines>;
  29195. /** @hidden */
  29196. _materialEffect: Nullable<Effect>;
  29197. /**
  29198. * Gets associated effect
  29199. */
  29200. readonly effect: Nullable<Effect>;
  29201. /**
  29202. * Sets associated effect (effect used to render this submesh)
  29203. * @param effect defines the effect to associate with
  29204. * @param defines defines the set of defines used to compile this effect
  29205. */
  29206. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29207. }
  29208. /**
  29209. * Defines a subdivision inside a mesh
  29210. */
  29211. class SubMesh extends BaseSubMesh implements ICullable {
  29212. /** the material index to use */
  29213. materialIndex: number;
  29214. /** vertex index start */
  29215. verticesStart: number;
  29216. /** vertices count */
  29217. verticesCount: number;
  29218. /** index start */
  29219. indexStart: number;
  29220. /** indices count */
  29221. indexCount: number;
  29222. /** @hidden */
  29223. _linesIndexCount: number;
  29224. private _mesh;
  29225. private _renderingMesh;
  29226. private _boundingInfo;
  29227. private _linesIndexBuffer;
  29228. /** @hidden */
  29229. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29230. /** @hidden */
  29231. _trianglePlanes: Plane[];
  29232. /** @hidden */
  29233. _lastColliderTransformMatrix: Matrix;
  29234. /** @hidden */
  29235. _renderId: number;
  29236. /** @hidden */
  29237. _alphaIndex: number;
  29238. /** @hidden */
  29239. _distanceToCamera: number;
  29240. /** @hidden */
  29241. _id: number;
  29242. private _currentMaterial;
  29243. /**
  29244. * Add a new submesh to a mesh
  29245. * @param materialIndex defines the material index to use
  29246. * @param verticesStart defines vertex index start
  29247. * @param verticesCount defines vertices count
  29248. * @param indexStart defines index start
  29249. * @param indexCount defines indices count
  29250. * @param mesh defines the parent mesh
  29251. * @param renderingMesh defines an optional rendering mesh
  29252. * @param createBoundingBox defines if bounding box should be created for this submesh
  29253. * @returns the new submesh
  29254. */
  29255. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29256. /**
  29257. * Creates a new submesh
  29258. * @param materialIndex defines the material index to use
  29259. * @param verticesStart defines vertex index start
  29260. * @param verticesCount defines vertices count
  29261. * @param indexStart defines index start
  29262. * @param indexCount defines indices count
  29263. * @param mesh defines the parent mesh
  29264. * @param renderingMesh defines an optional rendering mesh
  29265. * @param createBoundingBox defines if bounding box should be created for this submesh
  29266. */
  29267. constructor(
  29268. /** the material index to use */
  29269. materialIndex: number,
  29270. /** vertex index start */
  29271. verticesStart: number,
  29272. /** vertices count */
  29273. verticesCount: number,
  29274. /** index start */
  29275. indexStart: number,
  29276. /** indices count */
  29277. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29278. /**
  29279. * Returns true if this submesh covers the entire parent mesh
  29280. * @ignorenaming
  29281. */
  29282. readonly IsGlobal: boolean;
  29283. /**
  29284. * Returns the submesh BoudingInfo object
  29285. * @returns current bounding info (or mesh's one if the submesh is global)
  29286. */
  29287. getBoundingInfo(): BoundingInfo;
  29288. /**
  29289. * Sets the submesh BoundingInfo
  29290. * @param boundingInfo defines the new bounding info to use
  29291. * @returns the SubMesh
  29292. */
  29293. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29294. /**
  29295. * Returns the mesh of the current submesh
  29296. * @return the parent mesh
  29297. */
  29298. getMesh(): AbstractMesh;
  29299. /**
  29300. * Returns the rendering mesh of the submesh
  29301. * @returns the rendering mesh (could be different from parent mesh)
  29302. */
  29303. getRenderingMesh(): Mesh;
  29304. /**
  29305. * Returns the submesh material
  29306. * @returns null or the current material
  29307. */
  29308. getMaterial(): Nullable<Material>;
  29309. /**
  29310. * Sets a new updated BoundingInfo object to the submesh
  29311. * @returns the SubMesh
  29312. */
  29313. refreshBoundingInfo(): SubMesh;
  29314. /** @hidden */
  29315. _checkCollision(collider: Collider): boolean;
  29316. /**
  29317. * Updates the submesh BoundingInfo
  29318. * @param world defines the world matrix to use to update the bounding info
  29319. * @returns the submesh
  29320. */
  29321. updateBoundingInfo(world: Matrix): SubMesh;
  29322. /**
  29323. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29324. * @param frustumPlanes defines the frustum planes
  29325. * @returns true if the submesh is intersecting with the frustum
  29326. */
  29327. isInFrustum(frustumPlanes: Plane[]): boolean;
  29328. /**
  29329. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29330. * @param frustumPlanes defines the frustum planes
  29331. * @returns true if the submesh is inside the frustum
  29332. */
  29333. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29334. /**
  29335. * Renders the submesh
  29336. * @param enableAlphaMode defines if alpha needs to be used
  29337. * @returns the submesh
  29338. */
  29339. render(enableAlphaMode: boolean): SubMesh;
  29340. /**
  29341. * @hidden
  29342. */
  29343. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29344. /**
  29345. * Checks if the submesh intersects with a ray
  29346. * @param ray defines the ray to test
  29347. * @returns true is the passed ray intersects the submesh bounding box
  29348. */
  29349. canIntersects(ray: Ray): boolean;
  29350. /**
  29351. * Intersects current submesh with a ray
  29352. * @param ray defines the ray to test
  29353. * @param positions defines mesh's positions array
  29354. * @param indices defines mesh's indices array
  29355. * @param fastCheck defines if only bounding info should be used
  29356. * @returns intersection info or null if no intersection
  29357. */
  29358. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29359. /** @hidden */
  29360. private _intersectLines;
  29361. /** @hidden */
  29362. private _intersectTriangles;
  29363. /** @hidden */
  29364. _rebuild(): void;
  29365. /**
  29366. * Creates a new submesh from the passed mesh
  29367. * @param newMesh defines the new hosting mesh
  29368. * @param newRenderingMesh defines an optional rendering mesh
  29369. * @returns the new submesh
  29370. */
  29371. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29372. /**
  29373. * Release associated resources
  29374. */
  29375. dispose(): void;
  29376. /**
  29377. * Creates a new submesh from indices data
  29378. * @param materialIndex the index of the main mesh material
  29379. * @param startIndex the index where to start the copy in the mesh indices array
  29380. * @param indexCount the number of indices to copy then from the startIndex
  29381. * @param mesh the main mesh to create the submesh from
  29382. * @param renderingMesh the optional rendering mesh
  29383. * @returns a new submesh
  29384. */
  29385. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29386. }
  29387. }
  29388. declare module BABYLON {
  29389. /**
  29390. * 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.
  29391. * @see https://doc.babylonjs.com/how_to/transformnode
  29392. */
  29393. class TransformNode extends Node {
  29394. /**
  29395. * Object will not rotate to face the camera
  29396. */
  29397. static BILLBOARDMODE_NONE: number;
  29398. /**
  29399. * Object will rotate to face the camera but only on the x axis
  29400. */
  29401. static BILLBOARDMODE_X: number;
  29402. /**
  29403. * Object will rotate to face the camera but only on the y axis
  29404. */
  29405. static BILLBOARDMODE_Y: number;
  29406. /**
  29407. * Object will rotate to face the camera but only on the z axis
  29408. */
  29409. static BILLBOARDMODE_Z: number;
  29410. /**
  29411. * Object will rotate to face the camera
  29412. */
  29413. static BILLBOARDMODE_ALL: number;
  29414. private _forward;
  29415. private _forwardInverted;
  29416. private _up;
  29417. private _right;
  29418. private _rightInverted;
  29419. private _position;
  29420. private _rotation;
  29421. private _rotationQuaternion;
  29422. protected _scaling: Vector3;
  29423. protected _isDirty: boolean;
  29424. private _transformToBoneReferal;
  29425. /**
  29426. * Set the billboard mode. Default is 0.
  29427. *
  29428. * | Value | Type | Description |
  29429. * | --- | --- | --- |
  29430. * | 0 | BILLBOARDMODE_NONE | |
  29431. * | 1 | BILLBOARDMODE_X | |
  29432. * | 2 | BILLBOARDMODE_Y | |
  29433. * | 4 | BILLBOARDMODE_Z | |
  29434. * | 7 | BILLBOARDMODE_ALL | |
  29435. *
  29436. */
  29437. billboardMode: number;
  29438. /**
  29439. * 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
  29440. */
  29441. scalingDeterminant: number;
  29442. /**
  29443. * Sets the distance of the object to max, often used by skybox
  29444. */
  29445. infiniteDistance: boolean;
  29446. /**
  29447. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29448. * By default the system will update normals to compensate
  29449. */
  29450. ignoreNonUniformScaling: boolean;
  29451. /** @hidden */
  29452. _poseMatrix: Matrix;
  29453. private _localWorld;
  29454. private _absolutePosition;
  29455. private _pivotMatrix;
  29456. private _pivotMatrixInverse;
  29457. protected _postMultiplyPivotMatrix: boolean;
  29458. protected _isWorldMatrixFrozen: boolean;
  29459. /** @hidden */
  29460. _indexInSceneTransformNodesArray: number;
  29461. /**
  29462. * An event triggered after the world matrix is updated
  29463. */
  29464. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29465. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29466. /**
  29467. * Gets a string identifying the name of the class
  29468. * @returns "TransformNode" string
  29469. */
  29470. getClassName(): string;
  29471. /**
  29472. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29473. */
  29474. position: Vector3;
  29475. /**
  29476. * 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)).
  29477. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29478. */
  29479. rotation: Vector3;
  29480. /**
  29481. * 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)).
  29482. */
  29483. scaling: Vector3;
  29484. /**
  29485. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29486. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29487. */
  29488. rotationQuaternion: Nullable<Quaternion>;
  29489. /**
  29490. * The forward direction of that transform in world space.
  29491. */
  29492. readonly forward: Vector3;
  29493. /**
  29494. * The up direction of that transform in world space.
  29495. */
  29496. readonly up: Vector3;
  29497. /**
  29498. * The right direction of that transform in world space.
  29499. */
  29500. readonly right: Vector3;
  29501. /**
  29502. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29503. * @param matrix the matrix to copy the pose from
  29504. * @returns this TransformNode.
  29505. */
  29506. updatePoseMatrix(matrix: Matrix): TransformNode;
  29507. /**
  29508. * Returns the mesh Pose matrix.
  29509. * @returns the pose matrix
  29510. */
  29511. getPoseMatrix(): Matrix;
  29512. /** @hidden */
  29513. _isSynchronized(): boolean;
  29514. /** @hidden */
  29515. _initCache(): void;
  29516. /**
  29517. * Flag the transform node as dirty (Forcing it to update everything)
  29518. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29519. * @returns this transform node
  29520. */
  29521. markAsDirty(property: string): TransformNode;
  29522. /**
  29523. * Returns the current mesh absolute position.
  29524. * Returns a Vector3.
  29525. */
  29526. readonly absolutePosition: Vector3;
  29527. /**
  29528. * Sets a new matrix to apply before all other transformation
  29529. * @param matrix defines the transform matrix
  29530. * @returns the current TransformNode
  29531. */
  29532. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29533. /**
  29534. * Sets a new pivot matrix to the current node
  29535. * @param matrix defines the new pivot matrix to use
  29536. * @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
  29537. * @returns the current TransformNode
  29538. */
  29539. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29540. /**
  29541. * Returns the mesh pivot matrix.
  29542. * Default : Identity.
  29543. * @returns the matrix
  29544. */
  29545. getPivotMatrix(): Matrix;
  29546. /**
  29547. * Prevents the World matrix to be computed any longer.
  29548. * @returns the TransformNode.
  29549. */
  29550. freezeWorldMatrix(): TransformNode;
  29551. /**
  29552. * Allows back the World matrix computation.
  29553. * @returns the TransformNode.
  29554. */
  29555. unfreezeWorldMatrix(): this;
  29556. /**
  29557. * True if the World matrix has been frozen.
  29558. */
  29559. readonly isWorldMatrixFrozen: boolean;
  29560. /**
  29561. * Retuns the mesh absolute position in the World.
  29562. * @returns a Vector3.
  29563. */
  29564. getAbsolutePosition(): Vector3;
  29565. /**
  29566. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29567. * @param absolutePosition the absolute position to set
  29568. * @returns the TransformNode.
  29569. */
  29570. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29571. /**
  29572. * Sets the mesh position in its local space.
  29573. * @param vector3 the position to set in localspace
  29574. * @returns the TransformNode.
  29575. */
  29576. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29577. /**
  29578. * Returns the mesh position in the local space from the current World matrix values.
  29579. * @returns a new Vector3.
  29580. */
  29581. getPositionExpressedInLocalSpace(): Vector3;
  29582. /**
  29583. * Translates the mesh along the passed Vector3 in its local space.
  29584. * @param vector3 the distance to translate in localspace
  29585. * @returns the TransformNode.
  29586. */
  29587. locallyTranslate(vector3: Vector3): TransformNode;
  29588. private static _lookAtVectorCache;
  29589. /**
  29590. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29591. * @param targetPoint the position (must be in same space as current mesh) to look at
  29592. * @param yawCor optional yaw (y-axis) correction in radians
  29593. * @param pitchCor optional pitch (x-axis) correction in radians
  29594. * @param rollCor optional roll (z-axis) correction in radians
  29595. * @param space the choosen space of the target
  29596. * @returns the TransformNode.
  29597. */
  29598. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29599. /**
  29600. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29601. * This Vector3 is expressed in the World space.
  29602. * @param localAxis axis to rotate
  29603. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29604. */
  29605. getDirection(localAxis: Vector3): Vector3;
  29606. /**
  29607. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29608. * localAxis is expressed in the mesh local space.
  29609. * result is computed in the Wordl space from the mesh World matrix.
  29610. * @param localAxis axis to rotate
  29611. * @param result the resulting transformnode
  29612. * @returns this TransformNode.
  29613. */
  29614. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29615. /**
  29616. * Sets a new pivot point to the current node
  29617. * @param point defines the new pivot point to use
  29618. * @param space defines if the point is in world or local space (local by default)
  29619. * @returns the current TransformNode
  29620. */
  29621. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29622. /**
  29623. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29624. * @returns the pivot point
  29625. */
  29626. getPivotPoint(): Vector3;
  29627. /**
  29628. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29629. * @param result the vector3 to store the result
  29630. * @returns this TransformNode.
  29631. */
  29632. getPivotPointToRef(result: Vector3): TransformNode;
  29633. /**
  29634. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29635. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29636. */
  29637. getAbsolutePivotPoint(): Vector3;
  29638. /**
  29639. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29640. * @param result vector3 to store the result
  29641. * @returns this TransformNode.
  29642. */
  29643. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29644. /**
  29645. * Defines the passed node as the parent of the current node.
  29646. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29647. * @param node the node ot set as the parent
  29648. * @returns this TransformNode.
  29649. */
  29650. setParent(node: Nullable<Node>): TransformNode;
  29651. private _nonUniformScaling;
  29652. /**
  29653. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29654. */
  29655. readonly nonUniformScaling: boolean;
  29656. /** @hidden */
  29657. _updateNonUniformScalingState(value: boolean): boolean;
  29658. /**
  29659. * Attach the current TransformNode to another TransformNode associated with a bone
  29660. * @param bone Bone affecting the TransformNode
  29661. * @param affectedTransformNode TransformNode associated with the bone
  29662. * @returns this object
  29663. */
  29664. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29665. /**
  29666. * Detach the transform node if its associated with a bone
  29667. * @returns this object
  29668. */
  29669. detachFromBone(): TransformNode;
  29670. private static _rotationAxisCache;
  29671. /**
  29672. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29673. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29674. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29675. * The passed axis is also normalized.
  29676. * @param axis the axis to rotate around
  29677. * @param amount the amount to rotate in radians
  29678. * @param space Space to rotate in (Default: local)
  29679. * @returns the TransformNode.
  29680. */
  29681. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29682. /**
  29683. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29684. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29685. * The passed axis is also normalized. .
  29686. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29687. * @param point the point to rotate around
  29688. * @param axis the axis to rotate around
  29689. * @param amount the amount to rotate in radians
  29690. * @returns the TransformNode
  29691. */
  29692. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29693. /**
  29694. * Translates the mesh along the axis vector for the passed distance in the given space.
  29695. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29696. * @param axis the axis to translate in
  29697. * @param distance the distance to translate
  29698. * @param space Space to rotate in (Default: local)
  29699. * @returns the TransformNode.
  29700. */
  29701. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29702. /**
  29703. * Adds a rotation step to the mesh current rotation.
  29704. * x, y, z are Euler angles expressed in radians.
  29705. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29706. * This means this rotation is made in the mesh local space only.
  29707. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29708. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29709. * ```javascript
  29710. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29711. * ```
  29712. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29713. * 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.
  29714. * @param x Rotation to add
  29715. * @param y Rotation to add
  29716. * @param z Rotation to add
  29717. * @returns the TransformNode.
  29718. */
  29719. addRotation(x: number, y: number, z: number): TransformNode;
  29720. /**
  29721. * Computes the world matrix of the node
  29722. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29723. * @returns the world matrix
  29724. */
  29725. computeWorldMatrix(force?: boolean): Matrix;
  29726. protected _afterComputeWorldMatrix(): void;
  29727. /**
  29728. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29729. * @param func callback function to add
  29730. *
  29731. * @returns the TransformNode.
  29732. */
  29733. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29734. /**
  29735. * Removes a registered callback function.
  29736. * @param func callback function to remove
  29737. * @returns the TransformNode.
  29738. */
  29739. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29740. /**
  29741. * Gets the position of the current mesh in camera space
  29742. * @param camera defines the camera to use
  29743. * @returns a position
  29744. */
  29745. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29746. /**
  29747. * Returns the distance from the mesh to the active camera
  29748. * @param camera defines the camera to use
  29749. * @returns the distance
  29750. */
  29751. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29752. /**
  29753. * Clone the current transform node
  29754. * @param name Name of the new clone
  29755. * @param newParent New parent for the clone
  29756. * @param doNotCloneChildren Do not clone children hierarchy
  29757. * @returns the new transform node
  29758. */
  29759. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29760. /**
  29761. * Serializes the objects information.
  29762. * @param currentSerializationObject defines the object to serialize in
  29763. * @returns the serialized object
  29764. */
  29765. serialize(currentSerializationObject?: any): any;
  29766. /**
  29767. * Returns a new TransformNode object parsed from the source provided.
  29768. * @param parsedTransformNode is the source.
  29769. * @param scene the scne the object belongs to
  29770. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29771. * @returns a new TransformNode object parsed from the source provided.
  29772. */
  29773. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29774. /**
  29775. * Releases resources associated with this transform node.
  29776. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29777. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29778. */
  29779. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29780. }
  29781. }
  29782. declare module BABYLON {
  29783. /**
  29784. * Specialized buffer used to store vertex data
  29785. */
  29786. class VertexBuffer {
  29787. /** @hidden */
  29788. _buffer: Buffer;
  29789. private _kind;
  29790. private _size;
  29791. private _ownsBuffer;
  29792. private _instanced;
  29793. private _instanceDivisor;
  29794. /**
  29795. * The byte type.
  29796. */
  29797. static readonly BYTE: number;
  29798. /**
  29799. * The unsigned byte type.
  29800. */
  29801. static readonly UNSIGNED_BYTE: number;
  29802. /**
  29803. * The short type.
  29804. */
  29805. static readonly SHORT: number;
  29806. /**
  29807. * The unsigned short type.
  29808. */
  29809. static readonly UNSIGNED_SHORT: number;
  29810. /**
  29811. * The integer type.
  29812. */
  29813. static readonly INT: number;
  29814. /**
  29815. * The unsigned integer type.
  29816. */
  29817. static readonly UNSIGNED_INT: number;
  29818. /**
  29819. * The float type.
  29820. */
  29821. static readonly FLOAT: number;
  29822. /**
  29823. * Gets or sets the instance divisor when in instanced mode
  29824. */
  29825. instanceDivisor: number;
  29826. /**
  29827. * Gets the byte stride.
  29828. */
  29829. readonly byteStride: number;
  29830. /**
  29831. * Gets the byte offset.
  29832. */
  29833. readonly byteOffset: number;
  29834. /**
  29835. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29836. */
  29837. readonly normalized: boolean;
  29838. /**
  29839. * Gets the data type of each component in the array.
  29840. */
  29841. readonly type: number;
  29842. /**
  29843. * Constructor
  29844. * @param engine the engine
  29845. * @param data the data to use for this vertex buffer
  29846. * @param kind the vertex buffer kind
  29847. * @param updatable whether the data is updatable
  29848. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29849. * @param stride the stride (optional)
  29850. * @param instanced whether the buffer is instanced (optional)
  29851. * @param offset the offset of the data (optional)
  29852. * @param size the number of components (optional)
  29853. * @param type the type of the component (optional)
  29854. * @param normalized whether the data contains normalized data (optional)
  29855. * @param useBytes set to true if stride and offset are in bytes (optional)
  29856. */
  29857. 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);
  29858. /** @hidden */
  29859. _rebuild(): void;
  29860. /**
  29861. * Returns the kind of the VertexBuffer (string)
  29862. * @returns a string
  29863. */
  29864. getKind(): string;
  29865. /**
  29866. * Gets a boolean indicating if the VertexBuffer is updatable?
  29867. * @returns true if the buffer is updatable
  29868. */
  29869. isUpdatable(): boolean;
  29870. /**
  29871. * Gets current buffer's data
  29872. * @returns a DataArray or null
  29873. */
  29874. getData(): Nullable<DataArray>;
  29875. /**
  29876. * Gets underlying native buffer
  29877. * @returns underlying native buffer
  29878. */
  29879. getBuffer(): Nullable<WebGLBuffer>;
  29880. /**
  29881. * Gets the stride in float32 units (i.e. byte stride / 4).
  29882. * May not be an integer if the byte stride is not divisible by 4.
  29883. * DEPRECATED. Use byteStride instead.
  29884. * @returns the stride in float32 units
  29885. */
  29886. getStrideSize(): number;
  29887. /**
  29888. * Returns the offset as a multiple of the type byte length.
  29889. * DEPRECATED. Use byteOffset instead.
  29890. * @returns the offset in bytes
  29891. */
  29892. getOffset(): number;
  29893. /**
  29894. * Returns the number of components per vertex attribute (integer)
  29895. * @returns the size in float
  29896. */
  29897. getSize(): number;
  29898. /**
  29899. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29900. * @returns true if this buffer is instanced
  29901. */
  29902. getIsInstanced(): boolean;
  29903. /**
  29904. * Returns the instancing divisor, zero for non-instanced (integer).
  29905. * @returns a number
  29906. */
  29907. getInstanceDivisor(): number;
  29908. /**
  29909. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29910. * @param data defines the data to store
  29911. */
  29912. create(data?: DataArray): void;
  29913. /**
  29914. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29915. * This function will create a new buffer if the current one is not updatable
  29916. * @param data defines the data to store
  29917. */
  29918. update(data: DataArray): void;
  29919. /**
  29920. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29921. * Returns the directly updated WebGLBuffer.
  29922. * @param data the new data
  29923. * @param offset the new offset
  29924. * @param useBytes set to true if the offset is in bytes
  29925. */
  29926. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29927. /**
  29928. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29929. */
  29930. dispose(): void;
  29931. /**
  29932. * Enumerates each value of this vertex buffer as numbers.
  29933. * @param count the number of values to enumerate
  29934. * @param callback the callback function called for each value
  29935. */
  29936. forEach(count: number, callback: (value: number, index: number) => void): void;
  29937. /**
  29938. * Positions
  29939. */
  29940. static readonly PositionKind: string;
  29941. /**
  29942. * Normals
  29943. */
  29944. static readonly NormalKind: string;
  29945. /**
  29946. * Tangents
  29947. */
  29948. static readonly TangentKind: string;
  29949. /**
  29950. * Texture coordinates
  29951. */
  29952. static readonly UVKind: string;
  29953. /**
  29954. * Texture coordinates 2
  29955. */
  29956. static readonly UV2Kind: string;
  29957. /**
  29958. * Texture coordinates 3
  29959. */
  29960. static readonly UV3Kind: string;
  29961. /**
  29962. * Texture coordinates 4
  29963. */
  29964. static readonly UV4Kind: string;
  29965. /**
  29966. * Texture coordinates 5
  29967. */
  29968. static readonly UV5Kind: string;
  29969. /**
  29970. * Texture coordinates 6
  29971. */
  29972. static readonly UV6Kind: string;
  29973. /**
  29974. * Colors
  29975. */
  29976. static readonly ColorKind: string;
  29977. /**
  29978. * Matrix indices (for bones)
  29979. */
  29980. static readonly MatricesIndicesKind: string;
  29981. /**
  29982. * Matrix weights (for bones)
  29983. */
  29984. static readonly MatricesWeightsKind: string;
  29985. /**
  29986. * Additional matrix indices (for bones)
  29987. */
  29988. static readonly MatricesIndicesExtraKind: string;
  29989. /**
  29990. * Additional matrix weights (for bones)
  29991. */
  29992. static readonly MatricesWeightsExtraKind: string;
  29993. /**
  29994. * Deduces the stride given a kind.
  29995. * @param kind The kind string to deduce
  29996. * @returns The deduced stride
  29997. */
  29998. static DeduceStride(kind: string): number;
  29999. /**
  30000. * Gets the byte length of the given type.
  30001. * @param type the type
  30002. * @returns the number of bytes
  30003. */
  30004. static GetTypeByteLength(type: number): number;
  30005. /**
  30006. * Enumerates each value of the given parameters as numbers.
  30007. * @param data the data to enumerate
  30008. * @param byteOffset the byte offset of the data
  30009. * @param byteStride the byte stride of the data
  30010. * @param componentCount the number of components per element
  30011. * @param componentType the type of the component
  30012. * @param count the total number of components
  30013. * @param normalized whether the data is normalized
  30014. * @param callback the callback function called for each value
  30015. */
  30016. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  30017. private static _GetFloatValue;
  30018. }
  30019. }
  30020. declare module BABYLON {
  30021. /**
  30022. * Class used to enable access to IndexedDB
  30023. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30024. */
  30025. class Database implements IOfflineProvider {
  30026. private _callbackManifestChecked;
  30027. private _currentSceneUrl;
  30028. private _db;
  30029. private _enableSceneOffline;
  30030. private _enableTexturesOffline;
  30031. private _manifestVersionFound;
  30032. private _mustUpdateRessources;
  30033. private _hasReachedQuota;
  30034. private _isSupported;
  30035. private _idbFactory;
  30036. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30037. private static IsUASupportingBlobStorage;
  30038. /**
  30039. * Gets a boolean indicating if Database storate is enabled (off by default)
  30040. */
  30041. static IDBStorageEnabled: boolean;
  30042. /**
  30043. * Gets a boolean indicating if scene must be saved in the database
  30044. */
  30045. readonly enableSceneOffline: boolean;
  30046. /**
  30047. * Gets a boolean indicating if textures must be saved in the database
  30048. */
  30049. readonly enableTexturesOffline: boolean;
  30050. /**
  30051. * Creates a new Database
  30052. * @param urlToScene defines the url to load the scene
  30053. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30054. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30055. */
  30056. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30057. private static _ParseURL;
  30058. private static _ReturnFullUrlLocation;
  30059. private _checkManifestFile;
  30060. /**
  30061. * Open the database and make it available
  30062. * @param successCallback defines the callback to call on success
  30063. * @param errorCallback defines the callback to call on error
  30064. */
  30065. open(successCallback: () => void, errorCallback: () => void): void;
  30066. /**
  30067. * Loads an image from the database
  30068. * @param url defines the url to load from
  30069. * @param image defines the target DOM image
  30070. */
  30071. loadImage(url: string, image: HTMLImageElement): void;
  30072. private _loadImageFromDBAsync;
  30073. private _saveImageIntoDBAsync;
  30074. private _checkVersionFromDB;
  30075. private _loadVersionFromDBAsync;
  30076. private _saveVersionIntoDBAsync;
  30077. /**
  30078. * Loads a file from database
  30079. * @param url defines the URL to load from
  30080. * @param sceneLoaded defines a callback to call on success
  30081. * @param progressCallBack defines a callback to call when progress changed
  30082. * @param errorCallback defines a callback to call on error
  30083. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30084. */
  30085. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30086. private _loadFileAsync;
  30087. private _saveFileAsync;
  30088. }
  30089. }
  30090. declare module BABYLON {
  30091. /**
  30092. * Class used to enable access to offline support
  30093. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30094. */
  30095. interface IOfflineProvider {
  30096. /**
  30097. * Gets a boolean indicating if scene must be saved in the database
  30098. */
  30099. enableSceneOffline: boolean;
  30100. /**
  30101. * Gets a boolean indicating if textures must be saved in the database
  30102. */
  30103. enableTexturesOffline: boolean;
  30104. /**
  30105. * Open the offline support and make it available
  30106. * @param successCallback defines the callback to call on success
  30107. * @param errorCallback defines the callback to call on error
  30108. */
  30109. open(successCallback: () => void, errorCallback: () => void): void;
  30110. /**
  30111. * Loads an image from the offline support
  30112. * @param url defines the url to load from
  30113. * @param image defines the target DOM image
  30114. */
  30115. loadImage(url: string, image: HTMLImageElement): void;
  30116. /**
  30117. * Loads a file from offline support
  30118. * @param url defines the URL to load from
  30119. * @param sceneLoaded defines a callback to call on success
  30120. * @param progressCallBack defines a callback to call when progress changed
  30121. * @param errorCallback defines a callback to call on error
  30122. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30123. */
  30124. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30125. }
  30126. }
  30127. declare module BABYLON {
  30128. /**
  30129. * This represents the base class for particle system in Babylon.
  30130. * 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.
  30131. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30132. * @example https://doc.babylonjs.com/babylon101/particles
  30133. */
  30134. class BaseParticleSystem {
  30135. /**
  30136. * Source color is added to the destination color without alpha affecting the result
  30137. */
  30138. static BLENDMODE_ONEONE: number;
  30139. /**
  30140. * Blend current color and particle color using particle’s alpha
  30141. */
  30142. static BLENDMODE_STANDARD: number;
  30143. /**
  30144. * Add current color and particle color multiplied by particle’s alpha
  30145. */
  30146. static BLENDMODE_ADD: number;
  30147. /**
  30148. * Multiply current color with particle color
  30149. */
  30150. static BLENDMODE_MULTIPLY: number;
  30151. /**
  30152. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30153. */
  30154. static BLENDMODE_MULTIPLYADD: number;
  30155. /**
  30156. * List of animations used by the particle system.
  30157. */
  30158. animations: Animation[];
  30159. /**
  30160. * The id of the Particle system.
  30161. */
  30162. id: string;
  30163. /**
  30164. * The friendly name of the Particle system.
  30165. */
  30166. name: string;
  30167. /**
  30168. * The rendering group used by the Particle system to chose when to render.
  30169. */
  30170. renderingGroupId: number;
  30171. /**
  30172. * The emitter represents the Mesh or position we are attaching the particle system to.
  30173. */
  30174. emitter: Nullable<AbstractMesh | Vector3>;
  30175. /**
  30176. * The maximum number of particles to emit per frame
  30177. */
  30178. emitRate: number;
  30179. /**
  30180. * If you want to launch only a few particles at once, that can be done, as well.
  30181. */
  30182. manualEmitCount: number;
  30183. /**
  30184. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30185. */
  30186. updateSpeed: number;
  30187. /**
  30188. * The amount of time the particle system is running (depends of the overall update speed).
  30189. */
  30190. targetStopDuration: number;
  30191. /**
  30192. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30193. */
  30194. disposeOnStop: boolean;
  30195. /**
  30196. * Minimum power of emitting particles.
  30197. */
  30198. minEmitPower: number;
  30199. /**
  30200. * Maximum power of emitting particles.
  30201. */
  30202. maxEmitPower: number;
  30203. /**
  30204. * Minimum life time of emitting particles.
  30205. */
  30206. minLifeTime: number;
  30207. /**
  30208. * Maximum life time of emitting particles.
  30209. */
  30210. maxLifeTime: number;
  30211. /**
  30212. * Minimum Size of emitting particles.
  30213. */
  30214. minSize: number;
  30215. /**
  30216. * Maximum Size of emitting particles.
  30217. */
  30218. maxSize: number;
  30219. /**
  30220. * Minimum scale of emitting particles on X axis.
  30221. */
  30222. minScaleX: number;
  30223. /**
  30224. * Maximum scale of emitting particles on X axis.
  30225. */
  30226. maxScaleX: number;
  30227. /**
  30228. * Minimum scale of emitting particles on Y axis.
  30229. */
  30230. minScaleY: number;
  30231. /**
  30232. * Maximum scale of emitting particles on Y axis.
  30233. */
  30234. maxScaleY: number;
  30235. /**
  30236. * Gets or sets the minimal initial rotation in radians.
  30237. */
  30238. minInitialRotation: number;
  30239. /**
  30240. * Gets or sets the maximal initial rotation in radians.
  30241. */
  30242. maxInitialRotation: number;
  30243. /**
  30244. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30245. */
  30246. minAngularSpeed: number;
  30247. /**
  30248. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30249. */
  30250. maxAngularSpeed: number;
  30251. /**
  30252. * The texture used to render each particle. (this can be a spritesheet)
  30253. */
  30254. particleTexture: Nullable<Texture>;
  30255. /**
  30256. * The layer mask we are rendering the particles through.
  30257. */
  30258. layerMask: number;
  30259. /**
  30260. * This can help using your own shader to render the particle system.
  30261. * The according effect will be created
  30262. */
  30263. customShader: any;
  30264. /**
  30265. * By default particle system starts as soon as they are created. This prevents the
  30266. * automatic start to happen and let you decide when to start emitting particles.
  30267. */
  30268. preventAutoStart: boolean;
  30269. /**
  30270. * Gets or sets a texture used to add random noise to particle positions
  30271. */
  30272. noiseTexture: Nullable<ProceduralTexture>;
  30273. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30274. noiseStrength: Vector3;
  30275. /**
  30276. * Callback triggered when the particle animation is ending.
  30277. */
  30278. onAnimationEnd: Nullable<() => void>;
  30279. /**
  30280. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30281. */
  30282. blendMode: number;
  30283. /**
  30284. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30285. * to override the particles.
  30286. */
  30287. forceDepthWrite: boolean;
  30288. /** 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 */
  30289. preWarmCycles: number;
  30290. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30291. preWarmStepOffset: number;
  30292. /**
  30293. * 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)
  30294. */
  30295. spriteCellChangeSpeed: number;
  30296. /**
  30297. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30298. */
  30299. startSpriteCellID: number;
  30300. /**
  30301. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30302. */
  30303. endSpriteCellID: number;
  30304. /**
  30305. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30306. */
  30307. spriteCellWidth: number;
  30308. /**
  30309. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30310. */
  30311. spriteCellHeight: number;
  30312. /**
  30313. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30314. */
  30315. spriteRandomStartCell: boolean;
  30316. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30317. translationPivot: Vector2;
  30318. /** @hidden */
  30319. protected _isAnimationSheetEnabled: boolean;
  30320. /**
  30321. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30322. */
  30323. beginAnimationOnStart: boolean;
  30324. /**
  30325. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30326. */
  30327. beginAnimationFrom: number;
  30328. /**
  30329. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30330. */
  30331. beginAnimationTo: number;
  30332. /**
  30333. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30334. */
  30335. beginAnimationLoop: boolean;
  30336. /**
  30337. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30338. */
  30339. isAnimationSheetEnabled: boolean;
  30340. /**
  30341. * Get hosting scene
  30342. * @returns the scene
  30343. */
  30344. getScene(): Scene;
  30345. /**
  30346. * You can use gravity if you want to give an orientation to your particles.
  30347. */
  30348. gravity: Vector3;
  30349. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30350. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30351. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30352. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30353. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30354. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30355. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30356. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30357. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30358. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30359. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30360. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30361. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30362. /**
  30363. * Defines the delay in milliseconds before starting the system (0 by default)
  30364. */
  30365. startDelay: number;
  30366. /**
  30367. * Gets the current list of drag gradients.
  30368. * You must use addDragGradient and removeDragGradient to udpate this list
  30369. * @returns the list of drag gradients
  30370. */
  30371. getDragGradients(): Nullable<Array<FactorGradient>>;
  30372. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30373. limitVelocityDamping: number;
  30374. /**
  30375. * Gets the current list of limit velocity gradients.
  30376. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30377. * @returns the list of limit velocity gradients
  30378. */
  30379. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30380. /**
  30381. * Gets the current list of color gradients.
  30382. * You must use addColorGradient and removeColorGradient to udpate this list
  30383. * @returns the list of color gradients
  30384. */
  30385. getColorGradients(): Nullable<Array<ColorGradient>>;
  30386. /**
  30387. * Gets the current list of size gradients.
  30388. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30389. * @returns the list of size gradients
  30390. */
  30391. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30392. /**
  30393. * Gets the current list of color remap gradients.
  30394. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30395. * @returns the list of color remap gradients
  30396. */
  30397. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30398. /**
  30399. * Gets the current list of alpha remap gradients.
  30400. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30401. * @returns the list of alpha remap gradients
  30402. */
  30403. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30404. /**
  30405. * Gets the current list of life time gradients.
  30406. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30407. * @returns the list of life time gradients
  30408. */
  30409. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30410. /**
  30411. * Gets the current list of angular speed gradients.
  30412. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30413. * @returns the list of angular speed gradients
  30414. */
  30415. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30416. /**
  30417. * Gets the current list of velocity gradients.
  30418. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30419. * @returns the list of velocity gradients
  30420. */
  30421. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30422. /**
  30423. * Gets the current list of start size gradients.
  30424. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30425. * @returns the list of start size gradients
  30426. */
  30427. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30428. /**
  30429. * Gets the current list of emit rate gradients.
  30430. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30431. * @returns the list of emit rate gradients
  30432. */
  30433. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30434. /**
  30435. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30436. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30437. */
  30438. direction1: Vector3;
  30439. /**
  30440. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30441. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30442. */
  30443. direction2: Vector3;
  30444. /**
  30445. * 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.
  30446. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30447. */
  30448. minEmitBox: Vector3;
  30449. /**
  30450. * 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.
  30451. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30452. */
  30453. maxEmitBox: Vector3;
  30454. /**
  30455. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30456. */
  30457. color1: Color4;
  30458. /**
  30459. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30460. */
  30461. color2: Color4;
  30462. /**
  30463. * Color the particle will have at the end of its lifetime
  30464. */
  30465. colorDead: Color4;
  30466. /**
  30467. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30468. */
  30469. textureMask: Color4;
  30470. /**
  30471. * The particle emitter type defines the emitter used by the particle system.
  30472. * It can be for example box, sphere, or cone...
  30473. */
  30474. particleEmitterType: IParticleEmitterType;
  30475. /** @hidden */
  30476. _isSubEmitter: boolean;
  30477. /**
  30478. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30479. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30480. */
  30481. billboardMode: number;
  30482. protected _isBillboardBased: boolean;
  30483. /**
  30484. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30485. */
  30486. isBillboardBased: boolean;
  30487. /**
  30488. * The scene the particle system belongs to.
  30489. */
  30490. protected _scene: Scene;
  30491. /**
  30492. * Local cache of defines for image processing.
  30493. */
  30494. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30495. /**
  30496. * Default configuration related to image processing available in the standard Material.
  30497. */
  30498. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30499. /**
  30500. * Gets the image processing configuration used either in this material.
  30501. */
  30502. /**
  30503. * Sets the Default image processing configuration used either in the this material.
  30504. *
  30505. * If sets to null, the scene one is in use.
  30506. */
  30507. imageProcessingConfiguration: ImageProcessingConfiguration;
  30508. /**
  30509. * Attaches a new image processing configuration to the Standard Material.
  30510. * @param configuration
  30511. */
  30512. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30513. /** @hidden */
  30514. protected _reset(): void;
  30515. /** @hidden */
  30516. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30517. /**
  30518. * Instantiates a particle system.
  30519. * 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.
  30520. * @param name The name of the particle system
  30521. */
  30522. constructor(name: string);
  30523. /**
  30524. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30525. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30526. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30527. * @returns the emitter
  30528. */
  30529. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30530. /**
  30531. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30532. * @param radius The radius of the hemisphere to emit from
  30533. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30534. * @returns the emitter
  30535. */
  30536. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30537. /**
  30538. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30539. * @param radius The radius of the sphere to emit from
  30540. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30541. * @returns the emitter
  30542. */
  30543. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30544. /**
  30545. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30546. * @param radius The radius of the sphere to emit from
  30547. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30548. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30549. * @returns the emitter
  30550. */
  30551. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30552. /**
  30553. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30554. * @param radius The radius of the emission cylinder
  30555. * @param height The height of the emission cylinder
  30556. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30557. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30558. * @returns the emitter
  30559. */
  30560. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30561. /**
  30562. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30563. * @param radius The radius of the cylinder to emit from
  30564. * @param height The height of the emission cylinder
  30565. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30566. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30567. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30568. * @returns the emitter
  30569. */
  30570. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30571. /**
  30572. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30573. * @param radius The radius of the cone to emit from
  30574. * @param angle The base angle of the cone
  30575. * @returns the emitter
  30576. */
  30577. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30578. /**
  30579. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30580. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30581. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30582. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30583. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30584. * @returns the emitter
  30585. */
  30586. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30587. }
  30588. }
  30589. declare module BABYLON {
  30590. /**
  30591. * This represents a GPU particle system in Babylon
  30592. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30593. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30594. */
  30595. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30596. /**
  30597. * The layer mask we are rendering the particles through.
  30598. */
  30599. layerMask: number;
  30600. private _capacity;
  30601. private _activeCount;
  30602. private _currentActiveCount;
  30603. private _accumulatedCount;
  30604. private _renderEffect;
  30605. private _updateEffect;
  30606. private _buffer0;
  30607. private _buffer1;
  30608. private _spriteBuffer;
  30609. private _updateVAO;
  30610. private _renderVAO;
  30611. private _targetIndex;
  30612. private _sourceBuffer;
  30613. private _targetBuffer;
  30614. private _engine;
  30615. private _currentRenderId;
  30616. private _started;
  30617. private _stopped;
  30618. private _timeDelta;
  30619. private _randomTexture;
  30620. private _randomTexture2;
  30621. private _attributesStrideSize;
  30622. private _updateEffectOptions;
  30623. private _randomTextureSize;
  30624. private _actualFrame;
  30625. private readonly _rawTextureWidth;
  30626. /**
  30627. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30628. */
  30629. static readonly IsSupported: boolean;
  30630. /**
  30631. * An event triggered when the system is disposed.
  30632. */
  30633. onDisposeObservable: Observable<GPUParticleSystem>;
  30634. /**
  30635. * Gets the maximum number of particles active at the same time.
  30636. * @returns The max number of active particles.
  30637. */
  30638. getCapacity(): number;
  30639. /**
  30640. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30641. * to override the particles.
  30642. */
  30643. forceDepthWrite: boolean;
  30644. /**
  30645. * Gets or set the number of active particles
  30646. */
  30647. activeParticleCount: number;
  30648. private _preWarmDone;
  30649. /**
  30650. * Is this system ready to be used/rendered
  30651. * @return true if the system is ready
  30652. */
  30653. isReady(): boolean;
  30654. /**
  30655. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30656. * @returns True if it has been started, otherwise false.
  30657. */
  30658. isStarted(): boolean;
  30659. /**
  30660. * Starts the particle system and begins to emit
  30661. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30662. */
  30663. start(delay?: number): void;
  30664. /**
  30665. * Stops the particle system.
  30666. */
  30667. stop(): void;
  30668. /**
  30669. * Remove all active particles
  30670. */
  30671. reset(): void;
  30672. /**
  30673. * Returns the string "GPUParticleSystem"
  30674. * @returns a string containing the class name
  30675. */
  30676. getClassName(): string;
  30677. private _colorGradientsTexture;
  30678. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30679. /**
  30680. * Adds a new color gradient
  30681. * @param gradient defines the gradient to use (between 0 and 1)
  30682. * @param color1 defines the color to affect to the specified gradient
  30683. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30684. * @returns the current particle system
  30685. */
  30686. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30687. /**
  30688. * Remove a specific color gradient
  30689. * @param gradient defines the gradient to remove
  30690. * @returns the current particle system
  30691. */
  30692. removeColorGradient(gradient: number): GPUParticleSystem;
  30693. private _angularSpeedGradientsTexture;
  30694. private _sizeGradientsTexture;
  30695. private _velocityGradientsTexture;
  30696. private _limitVelocityGradientsTexture;
  30697. private _dragGradientsTexture;
  30698. private _addFactorGradient;
  30699. /**
  30700. * Adds a new size gradient
  30701. * @param gradient defines the gradient to use (between 0 and 1)
  30702. * @param factor defines the size factor to affect to the specified gradient
  30703. * @returns the current particle system
  30704. */
  30705. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30706. /**
  30707. * Remove a specific size gradient
  30708. * @param gradient defines the gradient to remove
  30709. * @returns the current particle system
  30710. */
  30711. removeSizeGradient(gradient: number): GPUParticleSystem;
  30712. /**
  30713. * Adds a new angular speed gradient
  30714. * @param gradient defines the gradient to use (between 0 and 1)
  30715. * @param factor defines the angular speed to affect to the specified gradient
  30716. * @returns the current particle system
  30717. */
  30718. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30719. /**
  30720. * Remove a specific angular speed gradient
  30721. * @param gradient defines the gradient to remove
  30722. * @returns the current particle system
  30723. */
  30724. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30725. /**
  30726. * Adds a new velocity gradient
  30727. * @param gradient defines the gradient to use (between 0 and 1)
  30728. * @param factor defines the velocity to affect to the specified gradient
  30729. * @returns the current particle system
  30730. */
  30731. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30732. /**
  30733. * Remove a specific velocity gradient
  30734. * @param gradient defines the gradient to remove
  30735. * @returns the current particle system
  30736. */
  30737. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30738. /**
  30739. * Adds a new limit velocity gradient
  30740. * @param gradient defines the gradient to use (between 0 and 1)
  30741. * @param factor defines the limit velocity value to affect to the specified gradient
  30742. * @returns the current particle system
  30743. */
  30744. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30745. /**
  30746. * Remove a specific limit velocity gradient
  30747. * @param gradient defines the gradient to remove
  30748. * @returns the current particle system
  30749. */
  30750. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30751. /**
  30752. * Adds a new drag gradient
  30753. * @param gradient defines the gradient to use (between 0 and 1)
  30754. * @param factor defines the drag value to affect to the specified gradient
  30755. * @returns the current particle system
  30756. */
  30757. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30758. /**
  30759. * Remove a specific drag gradient
  30760. * @param gradient defines the gradient to remove
  30761. * @returns the current particle system
  30762. */
  30763. removeDragGradient(gradient: number): GPUParticleSystem;
  30764. /**
  30765. * Not supported by GPUParticleSystem
  30766. * @param gradient defines the gradient to use (between 0 and 1)
  30767. * @param factor defines the emit rate value to affect to the specified gradient
  30768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30769. * @returns the current particle system
  30770. */
  30771. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30772. /**
  30773. * Not supported by GPUParticleSystem
  30774. * @param gradient defines the gradient to remove
  30775. * @returns the current particle system
  30776. */
  30777. removeEmitRateGradient(gradient: number): IParticleSystem;
  30778. /**
  30779. * Not supported by GPUParticleSystem
  30780. * @param gradient defines the gradient to use (between 0 and 1)
  30781. * @param factor defines the start size value to affect to the specified gradient
  30782. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30783. * @returns the current particle system
  30784. */
  30785. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30786. /**
  30787. * Not supported by GPUParticleSystem
  30788. * @param gradient defines the gradient to remove
  30789. * @returns the current particle system
  30790. */
  30791. removeStartSizeGradient(gradient: number): IParticleSystem;
  30792. /**
  30793. * Not supported by GPUParticleSystem
  30794. * @param gradient defines the gradient to use (between 0 and 1)
  30795. * @param min defines the color remap minimal range
  30796. * @param max defines the color remap maximal range
  30797. * @returns the current particle system
  30798. */
  30799. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30800. /**
  30801. * Not supported by GPUParticleSystem
  30802. * @param gradient defines the gradient to remove
  30803. * @returns the current particle system
  30804. */
  30805. removeColorRemapGradient(gradient: number): IParticleSystem;
  30806. /**
  30807. * Not supported by GPUParticleSystem
  30808. * @param gradient defines the gradient to use (between 0 and 1)
  30809. * @param min defines the alpha remap minimal range
  30810. * @param max defines the alpha remap maximal range
  30811. * @returns the current particle system
  30812. */
  30813. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30814. /**
  30815. * Not supported by GPUParticleSystem
  30816. * @param gradient defines the gradient to remove
  30817. * @returns the current particle system
  30818. */
  30819. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30820. /**
  30821. * Not supported by GPUParticleSystem
  30822. * @param gradient defines the gradient to use (between 0 and 1)
  30823. * @param color defines the color to affect to the specified gradient
  30824. * @returns the current particle system
  30825. */
  30826. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30827. /**
  30828. * Not supported by GPUParticleSystem
  30829. * @param gradient defines the gradient to remove
  30830. * @returns the current particle system
  30831. */
  30832. removeRampGradient(gradient: number): IParticleSystem;
  30833. /**
  30834. * Not supported by GPUParticleSystem
  30835. * @returns the list of ramp gradients
  30836. */
  30837. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30838. /**
  30839. * Not supported by GPUParticleSystem
  30840. * Gets or sets a boolean indicating that ramp gradients must be used
  30841. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30842. */
  30843. useRampGradients: boolean;
  30844. /**
  30845. * Not supported by GPUParticleSystem
  30846. * @param gradient defines the gradient to use (between 0 and 1)
  30847. * @param factor defines the life time factor to affect to the specified gradient
  30848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30849. * @returns the current particle system
  30850. */
  30851. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30852. /**
  30853. * Not supported by GPUParticleSystem
  30854. * @param gradient defines the gradient to remove
  30855. * @returns the current particle system
  30856. */
  30857. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30858. /**
  30859. * Instantiates a GPU particle system.
  30860. * 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.
  30861. * @param name The name of the particle system
  30862. * @param options The options used to create the system
  30863. * @param scene The scene the particle system belongs to
  30864. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30865. */
  30866. constructor(name: string, options: Partial<{
  30867. capacity: number;
  30868. randomTextureSize: number;
  30869. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  30870. protected _reset(): void;
  30871. private _createUpdateVAO;
  30872. private _createRenderVAO;
  30873. private _initialize;
  30874. /** @hidden */
  30875. _recreateUpdateEffect(): void;
  30876. /** @hidden */
  30877. _recreateRenderEffect(): void;
  30878. /**
  30879. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  30880. * @param preWarm defines if we are in the pre-warmimg phase
  30881. */
  30882. animate(preWarm?: boolean): void;
  30883. private _createFactorGradientTexture;
  30884. private _createSizeGradientTexture;
  30885. private _createAngularSpeedGradientTexture;
  30886. private _createVelocityGradientTexture;
  30887. private _createLimitVelocityGradientTexture;
  30888. private _createDragGradientTexture;
  30889. private _createColorGradientTexture;
  30890. /**
  30891. * Renders the particle system in its current state
  30892. * @param preWarm defines if the system should only update the particles but not render them
  30893. * @returns the current number of particles
  30894. */
  30895. render(preWarm?: boolean): number;
  30896. /**
  30897. * Rebuilds the particle system
  30898. */
  30899. rebuild(): void;
  30900. private _releaseBuffers;
  30901. private _releaseVAOs;
  30902. /**
  30903. * Disposes the particle system and free the associated resources
  30904. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30905. */
  30906. dispose(disposeTexture?: boolean): void;
  30907. /**
  30908. * Clones the particle system.
  30909. * @param name The name of the cloned object
  30910. * @param newEmitter The new emitter to use
  30911. * @returns the cloned particle system
  30912. */
  30913. clone(name: string, newEmitter: any): GPUParticleSystem;
  30914. /**
  30915. * Serializes the particle system to a JSON object.
  30916. * @returns the JSON object
  30917. */
  30918. serialize(): any;
  30919. /**
  30920. * Parses a JSON object to create a GPU particle system.
  30921. * @param parsedParticleSystem The JSON object to parse
  30922. * @param scene The scene to create the particle system in
  30923. * @param rootUrl The root url to use to load external dependencies like texture
  30924. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  30925. * @returns the parsed GPU particle system
  30926. */
  30927. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  30928. }
  30929. }
  30930. declare module BABYLON {
  30931. /**
  30932. * Interface representing a particle system in Babylon.js.
  30933. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  30934. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  30935. */
  30936. interface IParticleSystem {
  30937. /**
  30938. * List of animations used by the particle system.
  30939. */
  30940. animations: Animation[];
  30941. /**
  30942. * The id of the Particle system.
  30943. */
  30944. id: string;
  30945. /**
  30946. * The name of the Particle system.
  30947. */
  30948. name: string;
  30949. /**
  30950. * The emitter represents the Mesh or position we are attaching the particle system to.
  30951. */
  30952. emitter: Nullable<AbstractMesh | Vector3>;
  30953. /**
  30954. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30955. */
  30956. isBillboardBased: boolean;
  30957. /**
  30958. * The rendering group used by the Particle system to chose when to render.
  30959. */
  30960. renderingGroupId: number;
  30961. /**
  30962. * The layer mask we are rendering the particles through.
  30963. */
  30964. layerMask: number;
  30965. /**
  30966. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30967. */
  30968. updateSpeed: number;
  30969. /**
  30970. * The amount of time the particle system is running (depends of the overall update speed).
  30971. */
  30972. targetStopDuration: number;
  30973. /**
  30974. * The texture used to render each particle. (this can be a spritesheet)
  30975. */
  30976. particleTexture: Nullable<Texture>;
  30977. /**
  30978. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  30979. */
  30980. blendMode: number;
  30981. /**
  30982. * Minimum life time of emitting particles.
  30983. */
  30984. minLifeTime: number;
  30985. /**
  30986. * Maximum life time of emitting particles.
  30987. */
  30988. maxLifeTime: number;
  30989. /**
  30990. * Minimum Size of emitting particles.
  30991. */
  30992. minSize: number;
  30993. /**
  30994. * Maximum Size of emitting particles.
  30995. */
  30996. maxSize: number;
  30997. /**
  30998. * Minimum scale of emitting particles on X axis.
  30999. */
  31000. minScaleX: number;
  31001. /**
  31002. * Maximum scale of emitting particles on X axis.
  31003. */
  31004. maxScaleX: number;
  31005. /**
  31006. * Minimum scale of emitting particles on Y axis.
  31007. */
  31008. minScaleY: number;
  31009. /**
  31010. * Maximum scale of emitting particles on Y axis.
  31011. */
  31012. maxScaleY: number;
  31013. /**
  31014. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31015. */
  31016. color1: Color4;
  31017. /**
  31018. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31019. */
  31020. color2: Color4;
  31021. /**
  31022. * Color the particle will have at the end of its lifetime.
  31023. */
  31024. colorDead: Color4;
  31025. /**
  31026. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31027. */
  31028. emitRate: number;
  31029. /**
  31030. * You can use gravity if you want to give an orientation to your particles.
  31031. */
  31032. gravity: Vector3;
  31033. /**
  31034. * Minimum power of emitting particles.
  31035. */
  31036. minEmitPower: number;
  31037. /**
  31038. * Maximum power of emitting particles.
  31039. */
  31040. maxEmitPower: number;
  31041. /**
  31042. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31043. */
  31044. minAngularSpeed: number;
  31045. /**
  31046. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31047. */
  31048. maxAngularSpeed: number;
  31049. /**
  31050. * Gets or sets the minimal initial rotation in radians.
  31051. */
  31052. minInitialRotation: number;
  31053. /**
  31054. * Gets or sets the maximal initial rotation in radians.
  31055. */
  31056. maxInitialRotation: number;
  31057. /**
  31058. * The particle emitter type defines the emitter used by the particle system.
  31059. * It can be for example box, sphere, or cone...
  31060. */
  31061. particleEmitterType: Nullable<IParticleEmitterType>;
  31062. /**
  31063. * Defines the delay in milliseconds before starting the system (0 by default)
  31064. */
  31065. startDelay: number;
  31066. /**
  31067. * 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
  31068. */
  31069. preWarmCycles: number;
  31070. /**
  31071. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31072. */
  31073. preWarmStepOffset: number;
  31074. /**
  31075. * 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)
  31076. */
  31077. spriteCellChangeSpeed: number;
  31078. /**
  31079. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31080. */
  31081. startSpriteCellID: number;
  31082. /**
  31083. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31084. */
  31085. endSpriteCellID: number;
  31086. /**
  31087. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31088. */
  31089. spriteCellWidth: number;
  31090. /**
  31091. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31092. */
  31093. spriteCellHeight: number;
  31094. /**
  31095. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31096. */
  31097. spriteRandomStartCell: boolean;
  31098. /**
  31099. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31100. */
  31101. isAnimationSheetEnabled: boolean;
  31102. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31103. translationPivot: Vector2;
  31104. /**
  31105. * Gets or sets a texture used to add random noise to particle positions
  31106. */
  31107. noiseTexture: Nullable<BaseTexture>;
  31108. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31109. noiseStrength: Vector3;
  31110. /**
  31111. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31112. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31113. */
  31114. billboardMode: number;
  31115. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31116. limitVelocityDamping: number;
  31117. /**
  31118. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31119. */
  31120. beginAnimationOnStart: boolean;
  31121. /**
  31122. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31123. */
  31124. beginAnimationFrom: number;
  31125. /**
  31126. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31127. */
  31128. beginAnimationTo: number;
  31129. /**
  31130. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31131. */
  31132. beginAnimationLoop: boolean;
  31133. /**
  31134. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31135. */
  31136. disposeOnStop: boolean;
  31137. /**
  31138. * Gets the maximum number of particles active at the same time.
  31139. * @returns The max number of active particles.
  31140. */
  31141. getCapacity(): number;
  31142. /**
  31143. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31144. * @returns True if it has been started, otherwise false.
  31145. */
  31146. isStarted(): boolean;
  31147. /**
  31148. * Animates the particle system for this frame.
  31149. */
  31150. animate(): void;
  31151. /**
  31152. * Renders the particle system in its current state.
  31153. * @returns the current number of particles
  31154. */
  31155. render(): number;
  31156. /**
  31157. * Dispose the particle system and frees its associated resources.
  31158. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31159. */
  31160. dispose(disposeTexture?: boolean): void;
  31161. /**
  31162. * Clones the particle system.
  31163. * @param name The name of the cloned object
  31164. * @param newEmitter The new emitter to use
  31165. * @returns the cloned particle system
  31166. */
  31167. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31168. /**
  31169. * Serializes the particle system to a JSON object.
  31170. * @returns the JSON object
  31171. */
  31172. serialize(): any;
  31173. /**
  31174. * Rebuild the particle system
  31175. */
  31176. rebuild(): void;
  31177. /**
  31178. * Starts the particle system and begins to emit
  31179. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31180. */
  31181. start(delay?: number): void;
  31182. /**
  31183. * Stops the particle system.
  31184. */
  31185. stop(): void;
  31186. /**
  31187. * Remove all active particles
  31188. */
  31189. reset(): void;
  31190. /**
  31191. * Is this system ready to be used/rendered
  31192. * @return true if the system is ready
  31193. */
  31194. isReady(): boolean;
  31195. /**
  31196. * Adds a new color gradient
  31197. * @param gradient defines the gradient to use (between 0 and 1)
  31198. * @param color1 defines the color to affect to the specified gradient
  31199. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31200. * @returns the current particle system
  31201. */
  31202. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31203. /**
  31204. * Remove a specific color gradient
  31205. * @param gradient defines the gradient to remove
  31206. * @returns the current particle system
  31207. */
  31208. removeColorGradient(gradient: number): IParticleSystem;
  31209. /**
  31210. * Adds a new size gradient
  31211. * @param gradient defines the gradient to use (between 0 and 1)
  31212. * @param factor defines the size factor to affect to the specified gradient
  31213. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31214. * @returns the current particle system
  31215. */
  31216. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31217. /**
  31218. * Remove a specific size gradient
  31219. * @param gradient defines the gradient to remove
  31220. * @returns the current particle system
  31221. */
  31222. removeSizeGradient(gradient: number): IParticleSystem;
  31223. /**
  31224. * Gets the current list of color gradients.
  31225. * You must use addColorGradient and removeColorGradient to udpate this list
  31226. * @returns the list of color gradients
  31227. */
  31228. getColorGradients(): Nullable<Array<ColorGradient>>;
  31229. /**
  31230. * Gets the current list of size gradients.
  31231. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31232. * @returns the list of size gradients
  31233. */
  31234. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31235. /**
  31236. * Gets the current list of angular speed gradients.
  31237. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31238. * @returns the list of angular speed gradients
  31239. */
  31240. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31241. /**
  31242. * Adds a new angular speed gradient
  31243. * @param gradient defines the gradient to use (between 0 and 1)
  31244. * @param factor defines the angular speed to affect to the specified gradient
  31245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31246. * @returns the current particle system
  31247. */
  31248. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31249. /**
  31250. * Remove a specific angular speed gradient
  31251. * @param gradient defines the gradient to remove
  31252. * @returns the current particle system
  31253. */
  31254. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31255. /**
  31256. * Gets the current list of velocity gradients.
  31257. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31258. * @returns the list of velocity gradients
  31259. */
  31260. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31261. /**
  31262. * Adds a new velocity gradient
  31263. * @param gradient defines the gradient to use (between 0 and 1)
  31264. * @param factor defines the velocity to affect to the specified gradient
  31265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31266. * @returns the current particle system
  31267. */
  31268. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31269. /**
  31270. * Remove a specific velocity gradient
  31271. * @param gradient defines the gradient to remove
  31272. * @returns the current particle system
  31273. */
  31274. removeVelocityGradient(gradient: number): IParticleSystem;
  31275. /**
  31276. * Gets the current list of limit velocity gradients.
  31277. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31278. * @returns the list of limit velocity gradients
  31279. */
  31280. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31281. /**
  31282. * Adds a new limit velocity gradient
  31283. * @param gradient defines the gradient to use (between 0 and 1)
  31284. * @param factor defines the limit velocity to affect to the specified gradient
  31285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31286. * @returns the current particle system
  31287. */
  31288. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31289. /**
  31290. * Remove a specific limit velocity gradient
  31291. * @param gradient defines the gradient to remove
  31292. * @returns the current particle system
  31293. */
  31294. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31295. /**
  31296. * Adds a new drag gradient
  31297. * @param gradient defines the gradient to use (between 0 and 1)
  31298. * @param factor defines the drag to affect to the specified gradient
  31299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31300. * @returns the current particle system
  31301. */
  31302. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31303. /**
  31304. * Remove a specific drag gradient
  31305. * @param gradient defines the gradient to remove
  31306. * @returns the current particle system
  31307. */
  31308. removeDragGradient(gradient: number): IParticleSystem;
  31309. /**
  31310. * Gets the current list of drag gradients.
  31311. * You must use addDragGradient and removeDragGradient to udpate this list
  31312. * @returns the list of drag gradients
  31313. */
  31314. getDragGradients(): Nullable<Array<FactorGradient>>;
  31315. /**
  31316. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31317. * @param gradient defines the gradient to use (between 0 and 1)
  31318. * @param factor defines the emit rate to affect to the specified gradient
  31319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31320. * @returns the current particle system
  31321. */
  31322. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31323. /**
  31324. * Remove a specific emit rate gradient
  31325. * @param gradient defines the gradient to remove
  31326. * @returns the current particle system
  31327. */
  31328. removeEmitRateGradient(gradient: number): IParticleSystem;
  31329. /**
  31330. * Gets the current list of emit rate gradients.
  31331. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31332. * @returns the list of emit rate gradients
  31333. */
  31334. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31335. /**
  31336. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31337. * @param gradient defines the gradient to use (between 0 and 1)
  31338. * @param factor defines the start size to affect to the specified gradient
  31339. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31340. * @returns the current particle system
  31341. */
  31342. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31343. /**
  31344. * Remove a specific start size gradient
  31345. * @param gradient defines the gradient to remove
  31346. * @returns the current particle system
  31347. */
  31348. removeStartSizeGradient(gradient: number): IParticleSystem;
  31349. /**
  31350. * Gets the current list of start size gradients.
  31351. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31352. * @returns the list of start size gradients
  31353. */
  31354. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31355. /**
  31356. * Adds a new life time gradient
  31357. * @param gradient defines the gradient to use (between 0 and 1)
  31358. * @param factor defines the life time factor to affect to the specified gradient
  31359. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31360. * @returns the current particle system
  31361. */
  31362. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31363. /**
  31364. * Remove a specific life time gradient
  31365. * @param gradient defines the gradient to remove
  31366. * @returns the current particle system
  31367. */
  31368. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31369. /**
  31370. * Gets the current list of life time gradients.
  31371. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31372. * @returns the list of life time gradients
  31373. */
  31374. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31375. /**
  31376. * Gets the current list of color gradients.
  31377. * You must use addColorGradient and removeColorGradient to udpate this list
  31378. * @returns the list of color gradients
  31379. */
  31380. getColorGradients(): Nullable<Array<ColorGradient>>;
  31381. /**
  31382. * Adds a new ramp gradient used to remap particle colors
  31383. * @param gradient defines the gradient to use (between 0 and 1)
  31384. * @param color defines the color to affect to the specified gradient
  31385. * @returns the current particle system
  31386. */
  31387. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31388. /**
  31389. * Gets the current list of ramp gradients.
  31390. * You must use addRampGradient and removeRampGradient to udpate this list
  31391. * @returns the list of ramp gradients
  31392. */
  31393. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31394. /** Gets or sets a boolean indicating that ramp gradients must be used
  31395. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31396. */
  31397. useRampGradients: boolean;
  31398. /**
  31399. * Adds a new color remap gradient
  31400. * @param gradient defines the gradient to use (between 0 and 1)
  31401. * @param min defines the color remap minimal range
  31402. * @param max defines the color remap maximal range
  31403. * @returns the current particle system
  31404. */
  31405. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31406. /**
  31407. * Gets the current list of color remap gradients.
  31408. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31409. * @returns the list of color remap gradients
  31410. */
  31411. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31412. /**
  31413. * Adds a new alpha remap gradient
  31414. * @param gradient defines the gradient to use (between 0 and 1)
  31415. * @param min defines the alpha remap minimal range
  31416. * @param max defines the alpha remap maximal range
  31417. * @returns the current particle system
  31418. */
  31419. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31420. /**
  31421. * Gets the current list of alpha remap gradients.
  31422. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31423. * @returns the list of alpha remap gradients
  31424. */
  31425. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31426. /**
  31427. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31428. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31429. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31430. * @returns the emitter
  31431. */
  31432. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31433. /**
  31434. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31435. * @param radius The radius of the hemisphere to emit from
  31436. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31437. * @returns the emitter
  31438. */
  31439. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31440. /**
  31441. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31442. * @param radius The radius of the sphere to emit from
  31443. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31444. * @returns the emitter
  31445. */
  31446. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31447. /**
  31448. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31449. * @param radius The radius of the sphere to emit from
  31450. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31451. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31452. * @returns the emitter
  31453. */
  31454. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31455. /**
  31456. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31457. * @param radius The radius of the emission cylinder
  31458. * @param height The height of the emission cylinder
  31459. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31460. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31461. * @returns the emitter
  31462. */
  31463. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31464. /**
  31465. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31466. * @param radius The radius of the cylinder to emit from
  31467. * @param height The height of the emission cylinder
  31468. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31471. * @returns the emitter
  31472. */
  31473. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31474. /**
  31475. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31476. * @param radius The radius of the cone to emit from
  31477. * @param angle The base angle of the cone
  31478. * @returns the emitter
  31479. */
  31480. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31481. /**
  31482. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31483. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31484. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31485. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31486. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31487. * @returns the emitter
  31488. */
  31489. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31490. /**
  31491. * Get hosting scene
  31492. * @returns the scene
  31493. */
  31494. getScene(): Scene;
  31495. }
  31496. }
  31497. declare module BABYLON {
  31498. /**
  31499. * A particle represents one of the element emitted by a particle system.
  31500. * This is mainly define by its coordinates, direction, velocity and age.
  31501. */
  31502. class Particle {
  31503. /**
  31504. * The particle system the particle belongs to.
  31505. */
  31506. particleSystem: ParticleSystem;
  31507. private static _Count;
  31508. /**
  31509. * Unique ID of the particle
  31510. */
  31511. id: number;
  31512. /**
  31513. * The world position of the particle in the scene.
  31514. */
  31515. position: Vector3;
  31516. /**
  31517. * The world direction of the particle in the scene.
  31518. */
  31519. direction: Vector3;
  31520. /**
  31521. * The color of the particle.
  31522. */
  31523. color: Color4;
  31524. /**
  31525. * The color change of the particle per step.
  31526. */
  31527. colorStep: Color4;
  31528. /**
  31529. * Defines how long will the life of the particle be.
  31530. */
  31531. lifeTime: number;
  31532. /**
  31533. * The current age of the particle.
  31534. */
  31535. age: number;
  31536. /**
  31537. * The current size of the particle.
  31538. */
  31539. size: number;
  31540. /**
  31541. * The current scale of the particle.
  31542. */
  31543. scale: Vector2;
  31544. /**
  31545. * The current angle of the particle.
  31546. */
  31547. angle: number;
  31548. /**
  31549. * Defines how fast is the angle changing.
  31550. */
  31551. angularSpeed: number;
  31552. /**
  31553. * Defines the cell index used by the particle to be rendered from a sprite.
  31554. */
  31555. cellIndex: number;
  31556. /**
  31557. * The information required to support color remapping
  31558. */
  31559. remapData: Vector4;
  31560. /** @hidden */
  31561. _randomCellOffset?: number;
  31562. /** @hidden */
  31563. _initialDirection: Nullable<Vector3>;
  31564. /** @hidden */
  31565. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31566. /** @hidden */
  31567. _initialStartSpriteCellID: number;
  31568. /** @hidden */
  31569. _initialEndSpriteCellID: number;
  31570. /** @hidden */
  31571. _currentColorGradient: Nullable<ColorGradient>;
  31572. /** @hidden */
  31573. _currentColor1: Color4;
  31574. /** @hidden */
  31575. _currentColor2: Color4;
  31576. /** @hidden */
  31577. _currentSizeGradient: Nullable<FactorGradient>;
  31578. /** @hidden */
  31579. _currentSize1: number;
  31580. /** @hidden */
  31581. _currentSize2: number;
  31582. /** @hidden */
  31583. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31584. /** @hidden */
  31585. _currentAngularSpeed1: number;
  31586. /** @hidden */
  31587. _currentAngularSpeed2: number;
  31588. /** @hidden */
  31589. _currentVelocityGradient: Nullable<FactorGradient>;
  31590. /** @hidden */
  31591. _currentVelocity1: number;
  31592. /** @hidden */
  31593. _currentVelocity2: number;
  31594. /** @hidden */
  31595. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31596. /** @hidden */
  31597. _currentLimitVelocity1: number;
  31598. /** @hidden */
  31599. _currentLimitVelocity2: number;
  31600. /** @hidden */
  31601. _currentDragGradient: Nullable<FactorGradient>;
  31602. /** @hidden */
  31603. _currentDrag1: number;
  31604. /** @hidden */
  31605. _currentDrag2: number;
  31606. /** @hidden */
  31607. _randomNoiseCoordinates1: Vector3;
  31608. /** @hidden */
  31609. _randomNoiseCoordinates2: Vector3;
  31610. /**
  31611. * Creates a new instance Particle
  31612. * @param particleSystem the particle system the particle belongs to
  31613. */
  31614. constructor(
  31615. /**
  31616. * The particle system the particle belongs to.
  31617. */
  31618. particleSystem: ParticleSystem);
  31619. private updateCellInfoFromSystem;
  31620. /**
  31621. * Defines how the sprite cell index is updated for the particle
  31622. */
  31623. updateCellIndex(): void;
  31624. /** @hidden */
  31625. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31626. /** @hidden */
  31627. _inheritParticleInfoToSubEmitters(): void;
  31628. /** @hidden */
  31629. _reset(): void;
  31630. /**
  31631. * Copy the properties of particle to another one.
  31632. * @param other the particle to copy the information to.
  31633. */
  31634. copyTo(other: Particle): void;
  31635. }
  31636. }
  31637. declare module BABYLON {
  31638. /**
  31639. * This class is made for on one-liner static method to help creating particle system set.
  31640. */
  31641. class ParticleHelper {
  31642. /**
  31643. * Gets or sets base Assets URL
  31644. */
  31645. static BaseAssetsUrl: string;
  31646. /**
  31647. * Create a default particle system that you can tweak
  31648. * @param emitter defines the emitter to use
  31649. * @param capacity defines the system capacity (default is 500 particles)
  31650. * @param scene defines the hosting scene
  31651. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31652. * @returns the new Particle system
  31653. */
  31654. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31655. /**
  31656. * This is the main static method (one-liner) of this helper to create different particle systems
  31657. * @param type This string represents the type to the particle system to create
  31658. * @param scene The scene where the particle system should live
  31659. * @param gpu If the system will use gpu
  31660. * @returns the ParticleSystemSet created
  31661. */
  31662. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31663. /**
  31664. * Static function used to export a particle system to a ParticleSystemSet variable.
  31665. * Please note that the emitter shape is not exported
  31666. * @param systems defines the particle systems to export
  31667. * @returns the created particle system set
  31668. */
  31669. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31670. }
  31671. }
  31672. declare module BABYLON {
  31673. /**
  31674. * This represents a particle system in Babylon.
  31675. * 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.
  31676. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31677. * @example https://doc.babylonjs.com/babylon101/particles
  31678. */
  31679. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31680. /**
  31681. * Billboard mode will only apply to Y axis
  31682. */
  31683. static readonly BILLBOARDMODE_Y: number;
  31684. /**
  31685. * Billboard mode will apply to all axes
  31686. */
  31687. static readonly BILLBOARDMODE_ALL: number;
  31688. /**
  31689. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31690. */
  31691. static readonly BILLBOARDMODE_STRETCHED: number;
  31692. /**
  31693. * This function can be defined to provide custom update for active particles.
  31694. * This function will be called instead of regular update (age, position, color, etc.).
  31695. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31696. */
  31697. updateFunction: (particles: Particle[]) => void;
  31698. private _emitterWorldMatrix;
  31699. /**
  31700. * This function can be defined to specify initial direction for every new particle.
  31701. * It by default use the emitterType defined function
  31702. */
  31703. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31704. /**
  31705. * This function can be defined to specify initial position for every new particle.
  31706. * It by default use the emitterType defined function
  31707. */
  31708. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31709. /**
  31710. * @hidden
  31711. */
  31712. _inheritedVelocityOffset: Vector3;
  31713. /**
  31714. * An event triggered when the system is disposed
  31715. */
  31716. onDisposeObservable: Observable<ParticleSystem>;
  31717. private _onDisposeObserver;
  31718. /**
  31719. * Sets a callback that will be triggered when the system is disposed
  31720. */
  31721. onDispose: () => void;
  31722. private _particles;
  31723. private _epsilon;
  31724. private _capacity;
  31725. private _stockParticles;
  31726. private _newPartsExcess;
  31727. private _vertexData;
  31728. private _vertexBuffer;
  31729. private _vertexBuffers;
  31730. private _spriteBuffer;
  31731. private _indexBuffer;
  31732. private _effect;
  31733. private _customEffect;
  31734. private _cachedDefines;
  31735. private _scaledColorStep;
  31736. private _colorDiff;
  31737. private _scaledDirection;
  31738. private _scaledGravity;
  31739. private _currentRenderId;
  31740. private _alive;
  31741. private _useInstancing;
  31742. private _started;
  31743. private _stopped;
  31744. private _actualFrame;
  31745. private _scaledUpdateSpeed;
  31746. private _vertexBufferSize;
  31747. /** @hidden */
  31748. _currentEmitRateGradient: Nullable<FactorGradient>;
  31749. /** @hidden */
  31750. _currentEmitRate1: number;
  31751. /** @hidden */
  31752. _currentEmitRate2: number;
  31753. /** @hidden */
  31754. _currentStartSizeGradient: Nullable<FactorGradient>;
  31755. /** @hidden */
  31756. _currentStartSize1: number;
  31757. /** @hidden */
  31758. _currentStartSize2: number;
  31759. private readonly _rawTextureWidth;
  31760. private _rampGradientsTexture;
  31761. private _useRampGradients;
  31762. /** Gets or sets a boolean indicating that ramp gradients must be used
  31763. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31764. */
  31765. useRampGradients: boolean;
  31766. /**
  31767. * 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.
  31768. * 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: [])
  31769. */
  31770. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31771. private _subEmitters;
  31772. /**
  31773. * @hidden
  31774. * If the particle systems emitter should be disposed when the particle system is disposed
  31775. */
  31776. _disposeEmitterOnDispose: boolean;
  31777. /**
  31778. * The current active Sub-systems, this property is used by the root particle system only.
  31779. */
  31780. activeSubSystems: Array<ParticleSystem>;
  31781. private _rootParticleSystem;
  31782. /**
  31783. * Gets the current list of active particles
  31784. */
  31785. readonly particles: Particle[];
  31786. /**
  31787. * Returns the string "ParticleSystem"
  31788. * @returns a string containing the class name
  31789. */
  31790. getClassName(): string;
  31791. /**
  31792. * Instantiates a particle system.
  31793. * 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.
  31794. * @param name The name of the particle system
  31795. * @param capacity The max number of particles alive at the same time
  31796. * @param scene The scene the particle system belongs to
  31797. * @param customEffect a custom effect used to change the way particles are rendered by default
  31798. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31799. * @param epsilon Offset used to render the particles
  31800. */
  31801. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  31802. private _addFactorGradient;
  31803. private _removeFactorGradient;
  31804. /**
  31805. * Adds a new life time gradient
  31806. * @param gradient defines the gradient to use (between 0 and 1)
  31807. * @param factor defines the life time factor to affect to the specified gradient
  31808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31809. * @returns the current particle system
  31810. */
  31811. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31812. /**
  31813. * Remove a specific life time gradient
  31814. * @param gradient defines the gradient to remove
  31815. * @returns the current particle system
  31816. */
  31817. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31818. /**
  31819. * Adds a new size gradient
  31820. * @param gradient defines the gradient to use (between 0 and 1)
  31821. * @param factor defines the size factor to affect to the specified gradient
  31822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31823. * @returns the current particle system
  31824. */
  31825. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31826. /**
  31827. * Remove a specific size gradient
  31828. * @param gradient defines the gradient to remove
  31829. * @returns the current particle system
  31830. */
  31831. removeSizeGradient(gradient: number): IParticleSystem;
  31832. /**
  31833. * Adds a new color remap gradient
  31834. * @param gradient defines the gradient to use (between 0 and 1)
  31835. * @param min defines the color remap minimal range
  31836. * @param max defines the color remap maximal range
  31837. * @returns the current particle system
  31838. */
  31839. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31840. /**
  31841. * Remove a specific color remap gradient
  31842. * @param gradient defines the gradient to remove
  31843. * @returns the current particle system
  31844. */
  31845. removeColorRemapGradient(gradient: number): IParticleSystem;
  31846. /**
  31847. * Adds a new alpha remap gradient
  31848. * @param gradient defines the gradient to use (between 0 and 1)
  31849. * @param min defines the alpha remap minimal range
  31850. * @param max defines the alpha remap maximal range
  31851. * @returns the current particle system
  31852. */
  31853. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31854. /**
  31855. * Remove a specific alpha remap gradient
  31856. * @param gradient defines the gradient to remove
  31857. * @returns the current particle system
  31858. */
  31859. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31860. /**
  31861. * Adds a new angular speed gradient
  31862. * @param gradient defines the gradient to use (between 0 and 1)
  31863. * @param factor defines the angular speed to affect to the specified gradient
  31864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31865. * @returns the current particle system
  31866. */
  31867. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31868. /**
  31869. * Remove a specific angular speed gradient
  31870. * @param gradient defines the gradient to remove
  31871. * @returns the current particle system
  31872. */
  31873. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31874. /**
  31875. * Adds a new velocity gradient
  31876. * @param gradient defines the gradient to use (between 0 and 1)
  31877. * @param factor defines the velocity to affect to the specified gradient
  31878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31879. * @returns the current particle system
  31880. */
  31881. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31882. /**
  31883. * Remove a specific velocity gradient
  31884. * @param gradient defines the gradient to remove
  31885. * @returns the current particle system
  31886. */
  31887. removeVelocityGradient(gradient: number): IParticleSystem;
  31888. /**
  31889. * Adds a new limit velocity gradient
  31890. * @param gradient defines the gradient to use (between 0 and 1)
  31891. * @param factor defines the limit velocity value to affect to the specified gradient
  31892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31893. * @returns the current particle system
  31894. */
  31895. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31896. /**
  31897. * Remove a specific limit velocity gradient
  31898. * @param gradient defines the gradient to remove
  31899. * @returns the current particle system
  31900. */
  31901. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31902. /**
  31903. * Adds a new drag gradient
  31904. * @param gradient defines the gradient to use (between 0 and 1)
  31905. * @param factor defines the drag value to affect to the specified gradient
  31906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31907. * @returns the current particle system
  31908. */
  31909. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31910. /**
  31911. * Remove a specific drag gradient
  31912. * @param gradient defines the gradient to remove
  31913. * @returns the current particle system
  31914. */
  31915. removeDragGradient(gradient: number): IParticleSystem;
  31916. /**
  31917. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31918. * @param gradient defines the gradient to use (between 0 and 1)
  31919. * @param factor defines the emit rate value to affect to the specified gradient
  31920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31921. * @returns the current particle system
  31922. */
  31923. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31924. /**
  31925. * Remove a specific emit rate gradient
  31926. * @param gradient defines the gradient to remove
  31927. * @returns the current particle system
  31928. */
  31929. removeEmitRateGradient(gradient: number): IParticleSystem;
  31930. /**
  31931. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31932. * @param gradient defines the gradient to use (between 0 and 1)
  31933. * @param factor defines the start size value to affect to the specified gradient
  31934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31935. * @returns the current particle system
  31936. */
  31937. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31938. /**
  31939. * Remove a specific start size gradient
  31940. * @param gradient defines the gradient to remove
  31941. * @returns the current particle system
  31942. */
  31943. removeStartSizeGradient(gradient: number): IParticleSystem;
  31944. private _createRampGradientTexture;
  31945. /**
  31946. * Gets the current list of ramp gradients.
  31947. * You must use addRampGradient and removeRampGradient to udpate this list
  31948. * @returns the list of ramp gradients
  31949. */
  31950. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31951. /**
  31952. * Adds a new ramp gradient used to remap particle colors
  31953. * @param gradient defines the gradient to use (between 0 and 1)
  31954. * @param color defines the color to affect to the specified gradient
  31955. * @returns the current particle system
  31956. */
  31957. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  31958. /**
  31959. * Remove a specific ramp gradient
  31960. * @param gradient defines the gradient to remove
  31961. * @returns the current particle system
  31962. */
  31963. removeRampGradient(gradient: number): ParticleSystem;
  31964. /**
  31965. * Adds a new color gradient
  31966. * @param gradient defines the gradient to use (between 0 and 1)
  31967. * @param color1 defines the color to affect to the specified gradient
  31968. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31969. * @returns this particle system
  31970. */
  31971. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31972. /**
  31973. * Remove a specific color gradient
  31974. * @param gradient defines the gradient to remove
  31975. * @returns this particle system
  31976. */
  31977. removeColorGradient(gradient: number): IParticleSystem;
  31978. private _fetchR;
  31979. protected _reset(): void;
  31980. private _resetEffect;
  31981. private _createVertexBuffers;
  31982. private _createIndexBuffer;
  31983. /**
  31984. * Gets the maximum number of particles active at the same time.
  31985. * @returns The max number of active particles.
  31986. */
  31987. getCapacity(): number;
  31988. /**
  31989. * Gets whether there are still active particles in the system.
  31990. * @returns True if it is alive, otherwise false.
  31991. */
  31992. isAlive(): boolean;
  31993. /**
  31994. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31995. * @returns True if it has been started, otherwise false.
  31996. */
  31997. isStarted(): boolean;
  31998. private _prepareSubEmitterInternalArray;
  31999. /**
  32000. * Starts the particle system and begins to emit
  32001. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32002. */
  32003. start(delay?: number): void;
  32004. /**
  32005. * Stops the particle system.
  32006. * @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.
  32007. */
  32008. stop(stopSubEmitters?: boolean): void;
  32009. /**
  32010. * Remove all active particles
  32011. */
  32012. reset(): void;
  32013. /**
  32014. * @hidden (for internal use only)
  32015. */
  32016. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32017. /**
  32018. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32019. * Its lifetime will start back at 0.
  32020. */
  32021. recycleParticle: (particle: Particle) => void;
  32022. private _stopSubEmitters;
  32023. private _createParticle;
  32024. private _removeFromRoot;
  32025. private _emitFromParticle;
  32026. private _update;
  32027. /** @hidden */
  32028. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32029. /** @hidden */
  32030. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32031. /** @hidden */
  32032. private _getEffect;
  32033. /**
  32034. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32035. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32036. */
  32037. animate(preWarmOnly?: boolean): void;
  32038. private _appendParticleVertices;
  32039. /**
  32040. * Rebuilds the particle system.
  32041. */
  32042. rebuild(): void;
  32043. /**
  32044. * Is this system ready to be used/rendered
  32045. * @return true if the system is ready
  32046. */
  32047. isReady(): boolean;
  32048. private _render;
  32049. /**
  32050. * Renders the particle system in its current state.
  32051. * @returns the current number of particles
  32052. */
  32053. render(): number;
  32054. /**
  32055. * Disposes the particle system and free the associated resources
  32056. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32057. */
  32058. dispose(disposeTexture?: boolean): void;
  32059. /**
  32060. * Clones the particle system.
  32061. * @param name The name of the cloned object
  32062. * @param newEmitter The new emitter to use
  32063. * @returns the cloned particle system
  32064. */
  32065. clone(name: string, newEmitter: any): ParticleSystem;
  32066. /**
  32067. * Serializes the particle system to a JSON object.
  32068. * @returns the JSON object
  32069. */
  32070. serialize(): any;
  32071. /** @hidden */
  32072. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32073. /** @hidden */
  32074. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32075. /**
  32076. * Parses a JSON object to create a particle system.
  32077. * @param parsedParticleSystem The JSON object to parse
  32078. * @param scene The scene to create the particle system in
  32079. * @param rootUrl The root url to use to load external dependencies like texture
  32080. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32081. * @returns the Parsed particle system
  32082. */
  32083. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32084. }
  32085. }
  32086. declare module BABYLON {
  32087. interface Engine {
  32088. /**
  32089. * Create an effect to use with particle systems.
  32090. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32091. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32092. * @param uniformsNames defines a list of attribute names
  32093. * @param samplers defines an array of string used to represent textures
  32094. * @param defines defines the string containing the defines to use to compile the shaders
  32095. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32096. * @param onCompiled defines a function to call when the effect creation is successful
  32097. * @param onError defines a function to call when the effect creation has failed
  32098. * @returns the new Effect
  32099. */
  32100. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32101. }
  32102. interface Mesh {
  32103. /**
  32104. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32105. * @returns an array of IParticleSystem
  32106. */
  32107. getEmittedParticleSystems(): IParticleSystem[];
  32108. /**
  32109. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32110. * @returns an array of IParticleSystem
  32111. */
  32112. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32113. }
  32114. }
  32115. declare module BABYLON {
  32116. /**
  32117. * Represents a set of particle systems working together to create a specific effect
  32118. */
  32119. class ParticleSystemSet implements IDisposable {
  32120. private _emitterCreationOptions;
  32121. private _emitterNode;
  32122. /**
  32123. * Gets the particle system list
  32124. */
  32125. systems: IParticleSystem[];
  32126. /**
  32127. * Gets the emitter node used with this set
  32128. */
  32129. readonly emitterNode: Nullable<TransformNode>;
  32130. /**
  32131. * Creates a new emitter mesh as a sphere
  32132. * @param options defines the options used to create the sphere
  32133. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32134. * @param scene defines the hosting scene
  32135. */
  32136. setEmitterAsSphere(options: {
  32137. diameter: number;
  32138. segments: number;
  32139. color: Color3;
  32140. }, renderingGroupId: number, scene: Scene): void;
  32141. /**
  32142. * Starts all particle systems of the set
  32143. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32144. */
  32145. start(emitter?: AbstractMesh): void;
  32146. /**
  32147. * Release all associated resources
  32148. */
  32149. dispose(): void;
  32150. /**
  32151. * Serialize the set into a JSON compatible object
  32152. * @returns a JSON compatible representation of the set
  32153. */
  32154. serialize(): any;
  32155. /**
  32156. * Parse a new ParticleSystemSet from a serialized source
  32157. * @param data defines a JSON compatible representation of the set
  32158. * @param scene defines the hosting scene
  32159. * @param gpu defines if we want GPU particles or CPU particles
  32160. * @returns a new ParticleSystemSet
  32161. */
  32162. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32163. }
  32164. }
  32165. declare module BABYLON {
  32166. /**
  32167. * Represents one particle of a solid particle system.
  32168. */
  32169. class SolidParticle {
  32170. /**
  32171. * particle global index
  32172. */
  32173. idx: number;
  32174. /**
  32175. * The color of the particle
  32176. */
  32177. color: Nullable<Color4>;
  32178. /**
  32179. * The world space position of the particle.
  32180. */
  32181. position: Vector3;
  32182. /**
  32183. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32184. */
  32185. rotation: Vector3;
  32186. /**
  32187. * The world space rotation quaternion of the particle.
  32188. */
  32189. rotationQuaternion: Nullable<Quaternion>;
  32190. /**
  32191. * The scaling of the particle.
  32192. */
  32193. scaling: Vector3;
  32194. /**
  32195. * The uvs of the particle.
  32196. */
  32197. uvs: Vector4;
  32198. /**
  32199. * The current speed of the particle.
  32200. */
  32201. velocity: Vector3;
  32202. /**
  32203. * The pivot point in the particle local space.
  32204. */
  32205. pivot: Vector3;
  32206. /**
  32207. * Must the particle be translated from its pivot point in its local space ?
  32208. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32209. * Default : false
  32210. */
  32211. translateFromPivot: boolean;
  32212. /**
  32213. * Is the particle active or not ?
  32214. */
  32215. alive: boolean;
  32216. /**
  32217. * Is the particle visible or not ?
  32218. */
  32219. isVisible: boolean;
  32220. /**
  32221. * Index of this particle in the global "positions" array (Internal use)
  32222. * @hidden
  32223. */
  32224. _pos: number;
  32225. /**
  32226. * @hidden Index of this particle in the global "indices" array (Internal use)
  32227. */
  32228. _ind: number;
  32229. /**
  32230. * @hidden ModelShape of this particle (Internal use)
  32231. */
  32232. _model: ModelShape;
  32233. /**
  32234. * ModelShape id of this particle
  32235. */
  32236. shapeId: number;
  32237. /**
  32238. * Index of the particle in its shape id (Internal use)
  32239. */
  32240. idxInShape: number;
  32241. /**
  32242. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32243. */
  32244. _modelBoundingInfo: BoundingInfo;
  32245. /**
  32246. * @hidden Particle BoundingInfo object (Internal use)
  32247. */
  32248. _boundingInfo: BoundingInfo;
  32249. /**
  32250. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32251. */
  32252. _sps: SolidParticleSystem;
  32253. /**
  32254. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32255. */
  32256. _stillInvisible: boolean;
  32257. /**
  32258. * @hidden Last computed particle rotation matrix
  32259. */
  32260. _rotationMatrix: number[];
  32261. /**
  32262. * Parent particle Id, if any.
  32263. * Default null.
  32264. */
  32265. parentId: Nullable<number>;
  32266. /**
  32267. * @hidden Internal global position in the SPS.
  32268. */
  32269. _globalPosition: Vector3;
  32270. /**
  32271. * Creates a Solid Particle object.
  32272. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32273. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32274. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32275. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32276. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32277. * @param shapeId (integer) is the model shape identifier in the SPS.
  32278. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32279. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32280. */
  32281. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32282. /**
  32283. * Legacy support, changed scale to scaling
  32284. */
  32285. /**
  32286. * Legacy support, changed scale to scaling
  32287. */
  32288. scale: Vector3;
  32289. /**
  32290. * Legacy support, changed quaternion to rotationQuaternion
  32291. */
  32292. /**
  32293. * Legacy support, changed quaternion to rotationQuaternion
  32294. */
  32295. quaternion: Nullable<Quaternion>;
  32296. /**
  32297. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32298. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32299. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32300. * @returns true if it intersects
  32301. */
  32302. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32303. /**
  32304. * get the rotation matrix of the particle
  32305. * @hidden
  32306. */
  32307. getRotationMatrix(m: Matrix): void;
  32308. }
  32309. /**
  32310. * Represents the shape of the model used by one particle of a solid particle system.
  32311. * SPS internal tool, don't use it manually.
  32312. */
  32313. class ModelShape {
  32314. /**
  32315. * The shape id
  32316. * @hidden
  32317. */
  32318. shapeID: number;
  32319. /**
  32320. * flat array of model positions (internal use)
  32321. * @hidden
  32322. */
  32323. _shape: Vector3[];
  32324. /**
  32325. * flat array of model UVs (internal use)
  32326. * @hidden
  32327. */
  32328. _shapeUV: number[];
  32329. /**
  32330. * length of the shape in the model indices array (internal use)
  32331. * @hidden
  32332. */
  32333. _indicesLength: number;
  32334. /**
  32335. * Custom position function (internal use)
  32336. * @hidden
  32337. */
  32338. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32339. /**
  32340. * Custom vertex function (internal use)
  32341. * @hidden
  32342. */
  32343. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32344. /**
  32345. * 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.
  32346. * SPS internal tool, don't use it manually.
  32347. * @hidden
  32348. */
  32349. 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>);
  32350. }
  32351. /**
  32352. * Represents a Depth Sorted Particle in the solid particle system.
  32353. */
  32354. class DepthSortedParticle {
  32355. /**
  32356. * Index of the particle in the "indices" array
  32357. */
  32358. ind: number;
  32359. /**
  32360. * Length of the particle shape in the "indices" array
  32361. */
  32362. indicesLength: number;
  32363. /**
  32364. * Squared distance from the particle to the camera
  32365. */
  32366. sqDistance: number;
  32367. }
  32368. }
  32369. declare module BABYLON {
  32370. /**
  32371. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32372. *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.
  32373. * The SPS is also a particle system. It provides some methods to manage the particles.
  32374. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32375. *
  32376. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32377. */
  32378. class SolidParticleSystem implements IDisposable {
  32379. /**
  32380. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32381. * Example : var p = SPS.particles[i];
  32382. */
  32383. particles: SolidParticle[];
  32384. /**
  32385. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32386. */
  32387. nbParticles: number;
  32388. /**
  32389. * If the particles must ever face the camera (default false). Useful for planar particles.
  32390. */
  32391. billboard: boolean;
  32392. /**
  32393. * Recompute normals when adding a shape
  32394. */
  32395. recomputeNormals: boolean;
  32396. /**
  32397. * This a counter ofr your own usage. It's not set by any SPS functions.
  32398. */
  32399. counter: number;
  32400. /**
  32401. * The SPS name. This name is also given to the underlying mesh.
  32402. */
  32403. name: string;
  32404. /**
  32405. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32406. */
  32407. mesh: Mesh;
  32408. /**
  32409. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32410. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32411. */
  32412. vars: any;
  32413. /**
  32414. * This array is populated when the SPS is set as 'pickable'.
  32415. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32416. * Each element of this array is an object `{idx: int, faceId: int}`.
  32417. * `idx` is the picked particle index in the `SPS.particles` array
  32418. * `faceId` is the picked face index counted within this particle.
  32419. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32420. */
  32421. pickedParticles: {
  32422. idx: number;
  32423. faceId: number;
  32424. }[];
  32425. /**
  32426. * This array is populated when `enableDepthSort` is set to true.
  32427. * Each element of this array is an instance of the class DepthSortedParticle.
  32428. */
  32429. depthSortedParticles: DepthSortedParticle[];
  32430. /**
  32431. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32432. * @hidden
  32433. */
  32434. _bSphereOnly: boolean;
  32435. /**
  32436. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32437. * @hidden
  32438. */
  32439. _bSphereRadiusFactor: number;
  32440. private _scene;
  32441. private _positions;
  32442. private _indices;
  32443. private _normals;
  32444. private _colors;
  32445. private _uvs;
  32446. private _indices32;
  32447. private _positions32;
  32448. private _normals32;
  32449. private _fixedNormal32;
  32450. private _colors32;
  32451. private _uvs32;
  32452. private _index;
  32453. private _updatable;
  32454. private _pickable;
  32455. private _isVisibilityBoxLocked;
  32456. private _alwaysVisible;
  32457. private _depthSort;
  32458. private _shapeCounter;
  32459. private _copy;
  32460. private _color;
  32461. private _computeParticleColor;
  32462. private _computeParticleTexture;
  32463. private _computeParticleRotation;
  32464. private _computeParticleVertex;
  32465. private _computeBoundingBox;
  32466. private _depthSortParticles;
  32467. private _camera;
  32468. private _mustUnrotateFixedNormals;
  32469. private _particlesIntersect;
  32470. private _needs32Bits;
  32471. /**
  32472. * Creates a SPS (Solid Particle System) object.
  32473. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32474. * @param scene (Scene) is the scene in which the SPS is added.
  32475. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32476. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32477. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32478. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32479. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32480. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32481. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32482. */
  32483. constructor(name: string, scene: Scene, options?: {
  32484. updatable?: boolean;
  32485. isPickable?: boolean;
  32486. enableDepthSort?: boolean;
  32487. particleIntersection?: boolean;
  32488. boundingSphereOnly?: boolean;
  32489. bSphereRadiusFactor?: number;
  32490. });
  32491. /**
  32492. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32493. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32494. * @returns the created mesh
  32495. */
  32496. buildMesh(): Mesh;
  32497. /**
  32498. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32499. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32500. * Thus the particles generated from `digest()` have their property `position` set yet.
  32501. * @param mesh ( Mesh ) is the mesh to be digested
  32502. * @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
  32503. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32504. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32505. * @returns the current SPS
  32506. */
  32507. digest(mesh: Mesh, options?: {
  32508. facetNb?: number;
  32509. number?: number;
  32510. delta?: number;
  32511. }): SolidParticleSystem;
  32512. private _unrotateFixedNormals;
  32513. private _resetCopy;
  32514. private _meshBuilder;
  32515. private _posToShape;
  32516. private _uvsToShapeUV;
  32517. private _addParticle;
  32518. /**
  32519. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32520. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32521. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32522. * @param nb (positive integer) the number of particles to be created from this model
  32523. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32524. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32525. * @returns the number of shapes in the system
  32526. */
  32527. addShape(mesh: Mesh, nb: number, options?: {
  32528. positionFunction?: any;
  32529. vertexFunction?: any;
  32530. }): number;
  32531. private _rebuildParticle;
  32532. /**
  32533. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32534. * @returns the SPS.
  32535. */
  32536. rebuildMesh(): SolidParticleSystem;
  32537. /**
  32538. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32539. * This method calls `updateParticle()` for each particle of the SPS.
  32540. * For an animated SPS, it is usually called within the render loop.
  32541. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32542. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32543. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32544. * @returns the SPS.
  32545. */
  32546. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32547. /**
  32548. * Disposes the SPS.
  32549. */
  32550. dispose(): void;
  32551. /**
  32552. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32553. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32554. * @returns the SPS.
  32555. */
  32556. refreshVisibleSize(): SolidParticleSystem;
  32557. /**
  32558. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32559. * @param size the size (float) of the visibility box
  32560. * note : this doesn't lock the SPS mesh bounding box.
  32561. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32562. */
  32563. setVisibilityBox(size: number): void;
  32564. /**
  32565. * Gets whether the SPS as always visible or not
  32566. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32567. */
  32568. /**
  32569. * Sets the SPS as always visible or not
  32570. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32571. */
  32572. isAlwaysVisible: boolean;
  32573. /**
  32574. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32575. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32576. */
  32577. /**
  32578. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32579. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32580. */
  32581. isVisibilityBoxLocked: boolean;
  32582. /**
  32583. * Tells to `setParticles()` to compute the particle rotations or not.
  32584. * Default value : true. The SPS is faster when it's set to false.
  32585. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32586. */
  32587. /**
  32588. * Gets if `setParticles()` computes the particle rotations or not.
  32589. * Default value : true. The SPS is faster when it's set to false.
  32590. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32591. */
  32592. computeParticleRotation: boolean;
  32593. /**
  32594. * Tells to `setParticles()` to compute the particle colors or not.
  32595. * Default value : true. The SPS is faster when it's set to false.
  32596. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32597. */
  32598. /**
  32599. * Gets if `setParticles()` computes the particle colors or not.
  32600. * Default value : true. The SPS is faster when it's set to false.
  32601. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32602. */
  32603. computeParticleColor: boolean;
  32604. /**
  32605. * Gets if `setParticles()` computes the particle textures or not.
  32606. * Default value : true. The SPS is faster when it's set to false.
  32607. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32608. */
  32609. computeParticleTexture: boolean;
  32610. /**
  32611. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32612. * Default value : false. The SPS is faster when it's set to false.
  32613. * Note : the particle custom vertex positions aren't stored values.
  32614. */
  32615. /**
  32616. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32617. * Default value : false. The SPS is faster when it's set to false.
  32618. * Note : the particle custom vertex positions aren't stored values.
  32619. */
  32620. computeParticleVertex: boolean;
  32621. /**
  32622. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32623. */
  32624. /**
  32625. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32626. */
  32627. computeBoundingBox: boolean;
  32628. /**
  32629. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32630. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32631. * Default : `true`
  32632. */
  32633. /**
  32634. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32635. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32636. * Default : `true`
  32637. */
  32638. depthSortParticles: boolean;
  32639. /**
  32640. * This function does nothing. It may be overwritten to set all the particle first values.
  32641. * The SPS doesn't call this function, you may have to call it by your own.
  32642. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32643. */
  32644. initParticles(): void;
  32645. /**
  32646. * This function does nothing. It may be overwritten to recycle a particle.
  32647. * The SPS doesn't call this function, you may have to call it by your own.
  32648. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32649. * @param particle The particle to recycle
  32650. * @returns the recycled particle
  32651. */
  32652. recycleParticle(particle: SolidParticle): SolidParticle;
  32653. /**
  32654. * Updates a particle : this function should be overwritten by the user.
  32655. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32656. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32657. * @example : just set a particle position or velocity and recycle conditions
  32658. * @param particle The particle to update
  32659. * @returns the updated particle
  32660. */
  32661. updateParticle(particle: SolidParticle): SolidParticle;
  32662. /**
  32663. * Updates a vertex of a particle : it can be overwritten by the user.
  32664. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32665. * @param particle the current particle
  32666. * @param vertex the current index of the current particle
  32667. * @param pt the index of the current vertex in the particle shape
  32668. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32669. * @example : just set a vertex particle position
  32670. * @returns the updated vertex
  32671. */
  32672. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32673. /**
  32674. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32675. * This does nothing and may be overwritten by the user.
  32676. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32677. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32678. * @param update the boolean update value actually passed to setParticles()
  32679. */
  32680. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32681. /**
  32682. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32683. * This will be passed three parameters.
  32684. * This does nothing and may be overwritten by the user.
  32685. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32686. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32687. * @param update the boolean update value actually passed to setParticles()
  32688. */
  32689. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32690. }
  32691. }
  32692. declare module BABYLON {
  32693. /**
  32694. * Type of sub emitter
  32695. */
  32696. enum SubEmitterType {
  32697. /**
  32698. * Attached to the particle over it's lifetime
  32699. */
  32700. ATTACHED = 0,
  32701. /**
  32702. * Created when the particle dies
  32703. */
  32704. END = 1
  32705. }
  32706. /**
  32707. * Sub emitter class used to emit particles from an existing particle
  32708. */
  32709. class SubEmitter {
  32710. /**
  32711. * the particle system to be used by the sub emitter
  32712. */
  32713. particleSystem: ParticleSystem;
  32714. /**
  32715. * Type of the submitter (Default: END)
  32716. */
  32717. type: SubEmitterType;
  32718. /**
  32719. * 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)
  32720. * Note: This only is supported when using an emitter of type Mesh
  32721. */
  32722. inheritDirection: boolean;
  32723. /**
  32724. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32725. */
  32726. inheritedVelocityAmount: number;
  32727. /**
  32728. * Creates a sub emitter
  32729. * @param particleSystem the particle system to be used by the sub emitter
  32730. */
  32731. constructor(
  32732. /**
  32733. * the particle system to be used by the sub emitter
  32734. */
  32735. particleSystem: ParticleSystem);
  32736. /**
  32737. * Clones the sub emitter
  32738. * @returns the cloned sub emitter
  32739. */
  32740. clone(): SubEmitter;
  32741. /**
  32742. * Serialize current object to a JSON object
  32743. * @returns the serialized object
  32744. */
  32745. serialize(): any;
  32746. /**
  32747. * Creates a new SubEmitter from a serialized JSON version
  32748. * @param serializationObject defines the JSON object to read from
  32749. * @param scene defines the hosting scene
  32750. * @param rootUrl defines the rootUrl for data loading
  32751. * @returns a new SubEmitter
  32752. */
  32753. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32754. /** Release associated resources */
  32755. dispose(): void;
  32756. }
  32757. }
  32758. declare module BABYLON {
  32759. /**
  32760. * Interface used to describe a physics joint
  32761. */
  32762. interface PhysicsImpostorJoint {
  32763. /** Defines the main impostor to which the joint is linked */
  32764. mainImpostor: PhysicsImpostor;
  32765. /** Defines the impostor that is connected to the main impostor using this joint */
  32766. connectedImpostor: PhysicsImpostor;
  32767. /** Defines the joint itself */
  32768. joint: PhysicsJoint;
  32769. }
  32770. /** @hidden */
  32771. interface IPhysicsEnginePlugin {
  32772. world: any;
  32773. name: string;
  32774. setGravity(gravity: Vector3): void;
  32775. setTimeStep(timeStep: number): void;
  32776. getTimeStep(): number;
  32777. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32778. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32779. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32780. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32781. removePhysicsBody(impostor: PhysicsImpostor): void;
  32782. generateJoint(joint: PhysicsImpostorJoint): void;
  32783. removeJoint(joint: PhysicsImpostorJoint): void;
  32784. isSupported(): boolean;
  32785. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32786. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32787. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32788. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32789. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32790. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32791. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32792. getBodyMass(impostor: PhysicsImpostor): number;
  32793. getBodyFriction(impostor: PhysicsImpostor): number;
  32794. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32795. getBodyRestitution(impostor: PhysicsImpostor): number;
  32796. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32797. sleepBody(impostor: PhysicsImpostor): void;
  32798. wakeUpBody(impostor: PhysicsImpostor): void;
  32799. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32800. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32801. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32802. getRadius(impostor: PhysicsImpostor): number;
  32803. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32804. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32805. dispose(): void;
  32806. }
  32807. /**
  32808. * Interface used to define a physics engine
  32809. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32810. */
  32811. interface IPhysicsEngine {
  32812. /**
  32813. * Gets the gravity vector used by the simulation
  32814. */
  32815. gravity: Vector3;
  32816. /**
  32817. * Sets the gravity vector used by the simulation
  32818. * @param gravity defines the gravity vector to use
  32819. */
  32820. setGravity(gravity: Vector3): void;
  32821. /**
  32822. * Set the time step of the physics engine.
  32823. * Default is 1/60.
  32824. * To slow it down, enter 1/600 for example.
  32825. * To speed it up, 1/30
  32826. * @param newTimeStep the new timestep to apply to this world.
  32827. */
  32828. setTimeStep(newTimeStep: number): void;
  32829. /**
  32830. * Get the time step of the physics engine.
  32831. * @returns the current time step
  32832. */
  32833. getTimeStep(): number;
  32834. /**
  32835. * Release all resources
  32836. */
  32837. dispose(): void;
  32838. /**
  32839. * Gets the name of the current physics plugin
  32840. * @returns the name of the plugin
  32841. */
  32842. getPhysicsPluginName(): string;
  32843. /**
  32844. * Adding a new impostor for the impostor tracking.
  32845. * This will be done by the impostor itself.
  32846. * @param impostor the impostor to add
  32847. */
  32848. addImpostor(impostor: PhysicsImpostor): void;
  32849. /**
  32850. * Remove an impostor from the engine.
  32851. * This impostor and its mesh will not longer be updated by the physics engine.
  32852. * @param impostor the impostor to remove
  32853. */
  32854. removeImpostor(impostor: PhysicsImpostor): void;
  32855. /**
  32856. * Add a joint to the physics engine
  32857. * @param mainImpostor defines the main impostor to which the joint is added.
  32858. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32859. * @param joint defines the joint that will connect both impostors.
  32860. */
  32861. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32862. /**
  32863. * Removes a joint from the simulation
  32864. * @param mainImpostor defines the impostor used with the joint
  32865. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32866. * @param joint defines the joint to remove
  32867. */
  32868. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32869. /**
  32870. * Gets the current plugin used to run the simulation
  32871. * @returns current plugin
  32872. */
  32873. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32874. /**
  32875. * Gets the list of physic impostors
  32876. * @returns an array of PhysicsImpostor
  32877. */
  32878. getImpostors(): Array<PhysicsImpostor>;
  32879. /**
  32880. * Gets the impostor for a physics enabled object
  32881. * @param object defines the object impersonated by the impostor
  32882. * @returns the PhysicsImpostor or null if not found
  32883. */
  32884. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32885. /**
  32886. * Gets the impostor for a physics body object
  32887. * @param body defines physics body used by the impostor
  32888. * @returns the PhysicsImpostor or null if not found
  32889. */
  32890. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32891. /**
  32892. * Called by the scene. No need to call it.
  32893. * @param delta defines the timespam between frames
  32894. */
  32895. _step(delta: number): void;
  32896. }
  32897. }
  32898. declare module BABYLON {
  32899. /**
  32900. * Class used to control physics engine
  32901. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32902. */
  32903. class PhysicsEngine implements IPhysicsEngine {
  32904. private _physicsPlugin;
  32905. /**
  32906. * Global value used to control the smallest number supported by the simulation
  32907. */
  32908. static Epsilon: number;
  32909. private _impostors;
  32910. private _joints;
  32911. /**
  32912. * Gets the gravity vector used by the simulation
  32913. */
  32914. gravity: Vector3;
  32915. /**
  32916. * Creates a new Physics Engine
  32917. * @param gravity defines the gravity vector used by the simulation
  32918. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  32919. */
  32920. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  32921. /**
  32922. * Sets the gravity vector used by the simulation
  32923. * @param gravity defines the gravity vector to use
  32924. */
  32925. setGravity(gravity: Vector3): void;
  32926. /**
  32927. * Set the time step of the physics engine.
  32928. * Default is 1/60.
  32929. * To slow it down, enter 1/600 for example.
  32930. * To speed it up, 1/30
  32931. * @param newTimeStep defines the new timestep to apply to this world.
  32932. */
  32933. setTimeStep(newTimeStep?: number): void;
  32934. /**
  32935. * Get the time step of the physics engine.
  32936. * @returns the current time step
  32937. */
  32938. getTimeStep(): number;
  32939. /**
  32940. * Release all resources
  32941. */
  32942. dispose(): void;
  32943. /**
  32944. * Gets the name of the current physics plugin
  32945. * @returns the name of the plugin
  32946. */
  32947. getPhysicsPluginName(): string;
  32948. /**
  32949. * Adding a new impostor for the impostor tracking.
  32950. * This will be done by the impostor itself.
  32951. * @param impostor the impostor to add
  32952. */
  32953. addImpostor(impostor: PhysicsImpostor): void;
  32954. /**
  32955. * Remove an impostor from the engine.
  32956. * This impostor and its mesh will not longer be updated by the physics engine.
  32957. * @param impostor the impostor to remove
  32958. */
  32959. removeImpostor(impostor: PhysicsImpostor): void;
  32960. /**
  32961. * Add a joint to the physics engine
  32962. * @param mainImpostor defines the main impostor to which the joint is added.
  32963. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32964. * @param joint defines the joint that will connect both impostors.
  32965. */
  32966. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32967. /**
  32968. * Removes a joint from the simulation
  32969. * @param mainImpostor defines the impostor used with the joint
  32970. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32971. * @param joint defines the joint to remove
  32972. */
  32973. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32974. /**
  32975. * Called by the scene. No need to call it.
  32976. * @param delta defines the timespam between frames
  32977. */
  32978. _step(delta: number): void;
  32979. /**
  32980. * Gets the current plugin used to run the simulation
  32981. * @returns current plugin
  32982. */
  32983. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32984. /**
  32985. * Gets the list of physic impostors
  32986. * @returns an array of PhysicsImpostor
  32987. */
  32988. getImpostors(): Array<PhysicsImpostor>;
  32989. /**
  32990. * Gets the impostor for a physics enabled object
  32991. * @param object defines the object impersonated by the impostor
  32992. * @returns the PhysicsImpostor or null if not found
  32993. */
  32994. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32995. /**
  32996. * Gets the impostor for a physics body object
  32997. * @param body defines physics body used by the impostor
  32998. * @returns the PhysicsImpostor or null if not found
  32999. */
  33000. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33001. }
  33002. }
  33003. declare module BABYLON {
  33004. interface Scene {
  33005. /** @hidden (Backing field) */
  33006. _physicsEngine: Nullable<IPhysicsEngine>;
  33007. /**
  33008. * Gets the current physics engine
  33009. * @returns a IPhysicsEngine or null if none attached
  33010. */
  33011. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33012. /**
  33013. * Enables physics to the current scene
  33014. * @param gravity defines the scene's gravity for the physics engine
  33015. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33016. * @return a boolean indicating if the physics engine was initialized
  33017. */
  33018. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33019. /**
  33020. * Disables and disposes the physics engine associated with the scene
  33021. */
  33022. disablePhysicsEngine(): void;
  33023. /**
  33024. * Gets a boolean indicating if there is an active physics engine
  33025. * @returns a boolean indicating if there is an active physics engine
  33026. */
  33027. isPhysicsEnabled(): boolean;
  33028. /**
  33029. * Deletes a physics compound impostor
  33030. * @param compound defines the compound to delete
  33031. */
  33032. deleteCompoundImpostor(compound: any): void;
  33033. /**
  33034. * An event triggered when physic simulation is about to be run
  33035. */
  33036. onBeforePhysicsObservable: Observable<Scene>;
  33037. /**
  33038. * An event triggered when physic simulation has been done
  33039. */
  33040. onAfterPhysicsObservable: Observable<Scene>;
  33041. }
  33042. interface AbstractMesh {
  33043. /** @hidden */
  33044. _physicsImpostor: Nullable<PhysicsImpostor>;
  33045. /**
  33046. * Gets or sets impostor used for physic simulation
  33047. * @see http://doc.babylonjs.com/features/physics_engine
  33048. */
  33049. physicsImpostor: Nullable<PhysicsImpostor>;
  33050. /**
  33051. * Gets the current physics impostor
  33052. * @see http://doc.babylonjs.com/features/physics_engine
  33053. * @returns a physics impostor or null
  33054. */
  33055. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33056. /** Apply a physic impulse to the mesh
  33057. * @param force defines the force to apply
  33058. * @param contactPoint defines where to apply the force
  33059. * @returns the current mesh
  33060. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33061. */
  33062. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33063. /**
  33064. * Creates a physic joint between two meshes
  33065. * @param otherMesh defines the other mesh to use
  33066. * @param pivot1 defines the pivot to use on this mesh
  33067. * @param pivot2 defines the pivot to use on the other mesh
  33068. * @param options defines additional options (can be plugin dependent)
  33069. * @returns the current mesh
  33070. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33071. */
  33072. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33073. /** @hidden */
  33074. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33075. }
  33076. /**
  33077. * Defines the physics engine scene component responsible to manage a physics engine
  33078. */
  33079. class PhysicsEngineSceneComponent implements ISceneComponent {
  33080. /**
  33081. * The component name helpful to identify the component in the list of scene components.
  33082. */
  33083. readonly name: string;
  33084. /**
  33085. * The scene the component belongs to.
  33086. */
  33087. scene: Scene;
  33088. /**
  33089. * Creates a new instance of the component for the given scene
  33090. * @param scene Defines the scene to register the component in
  33091. */
  33092. constructor(scene: Scene);
  33093. /**
  33094. * Registers the component in a given scene
  33095. */
  33096. register(): void;
  33097. /**
  33098. * Rebuilds the elements related to this component in case of
  33099. * context lost for instance.
  33100. */
  33101. rebuild(): void;
  33102. /**
  33103. * Disposes the component and the associated ressources
  33104. */
  33105. dispose(): void;
  33106. }
  33107. }
  33108. declare module BABYLON {
  33109. /**
  33110. * A helper for physics simulations
  33111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33112. */
  33113. class PhysicsHelper {
  33114. private _scene;
  33115. private _physicsEngine;
  33116. /**
  33117. * Initializes the Physics helper
  33118. * @param scene Babylon.js scene
  33119. */
  33120. constructor(scene: Scene);
  33121. /**
  33122. * Applies a radial explosion impulse
  33123. * @param origin the origin of the explosion
  33124. * @param radius the explosion radius
  33125. * @param strength the explosion strength
  33126. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33127. * @returns A physics radial explosion event, or null
  33128. */
  33129. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33130. /**
  33131. * Applies a radial explosion force
  33132. * @param origin the origin of the explosion
  33133. * @param radius the explosion radius
  33134. * @param strength the explosion strength
  33135. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33136. * @returns A physics radial explosion event, or null
  33137. */
  33138. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33139. /**
  33140. * Creates a gravitational field
  33141. * @param origin the origin of the explosion
  33142. * @param radius the explosion radius
  33143. * @param strength the explosion strength
  33144. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33145. * @returns A physics gravitational field event, or null
  33146. */
  33147. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33148. /**
  33149. * Creates a physics updraft event
  33150. * @param origin the origin of the updraft
  33151. * @param radius the radius of the updraft
  33152. * @param strength the strength of the updraft
  33153. * @param height the height of the updraft
  33154. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33155. * @returns A physics updraft event, or null
  33156. */
  33157. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33158. /**
  33159. * Creates a physics vortex event
  33160. * @param origin the of the vortex
  33161. * @param radius the radius of the vortex
  33162. * @param strength the strength of the vortex
  33163. * @param height the height of the vortex
  33164. * @returns a Physics vortex event, or null
  33165. * A physics vortex event or null
  33166. */
  33167. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33168. }
  33169. /**
  33170. * Represents a physics radial explosion event
  33171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33172. */
  33173. class PhysicsRadialExplosionEvent {
  33174. private _scene;
  33175. private _sphere;
  33176. private _sphereOptions;
  33177. private _rays;
  33178. private _dataFetched;
  33179. /**
  33180. * Initializes a radial explosioin event
  33181. * @param scene BabylonJS scene
  33182. */
  33183. constructor(scene: Scene);
  33184. /**
  33185. * Returns the data related to the radial explosion event (sphere & rays).
  33186. * @returns The radial explosion event data
  33187. */
  33188. getData(): PhysicsRadialExplosionEventData;
  33189. /**
  33190. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33191. * @param impostor A physics imposter
  33192. * @param origin the origin of the explosion
  33193. * @param radius the explosion radius
  33194. * @param strength the explosion strength
  33195. * @param falloff possible options: Constant & Linear
  33196. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33197. */
  33198. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33199. /**
  33200. * Disposes the sphere.
  33201. * @param force Specifies if the sphere should be disposed by force
  33202. */
  33203. dispose(force?: boolean): void;
  33204. /*** Helpers ***/
  33205. private _prepareSphere;
  33206. private _intersectsWithSphere;
  33207. }
  33208. /**
  33209. * Represents a gravitational field event
  33210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33211. */
  33212. class PhysicsGravitationalFieldEvent {
  33213. private _physicsHelper;
  33214. private _scene;
  33215. private _origin;
  33216. private _radius;
  33217. private _strength;
  33218. private _falloff;
  33219. private _tickCallback;
  33220. private _sphere;
  33221. private _dataFetched;
  33222. /**
  33223. * Initializes the physics gravitational field event
  33224. * @param physicsHelper A physics helper
  33225. * @param scene BabylonJS scene
  33226. * @param origin The origin position of the gravitational field event
  33227. * @param radius The radius of the gravitational field event
  33228. * @param strength The strength of the gravitational field event
  33229. * @param falloff The falloff for the gravitational field event
  33230. */
  33231. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33232. /**
  33233. * Returns the data related to the gravitational field event (sphere).
  33234. * @returns A gravitational field event
  33235. */
  33236. getData(): PhysicsGravitationalFieldEventData;
  33237. /**
  33238. * Enables the gravitational field.
  33239. */
  33240. enable(): void;
  33241. /**
  33242. * Disables the gravitational field.
  33243. */
  33244. disable(): void;
  33245. /**
  33246. * Disposes the sphere.
  33247. * @param force The force to dispose from the gravitational field event
  33248. */
  33249. dispose(force?: boolean): void;
  33250. private _tick;
  33251. }
  33252. /**
  33253. * Represents a physics updraft event
  33254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33255. */
  33256. class PhysicsUpdraftEvent {
  33257. private _scene;
  33258. private _origin;
  33259. private _radius;
  33260. private _strength;
  33261. private _height;
  33262. private _updraftMode;
  33263. private _physicsEngine;
  33264. private _originTop;
  33265. private _originDirection;
  33266. private _tickCallback;
  33267. private _cylinder;
  33268. private _cylinderPosition;
  33269. private _dataFetched;
  33270. /**
  33271. * Initializes the physics updraft event
  33272. * @param _scene BabylonJS scene
  33273. * @param _origin The origin position of the updraft
  33274. * @param _radius The radius of the updraft
  33275. * @param _strength The strength of the updraft
  33276. * @param _height The height of the updraft
  33277. * @param _updraftMode The mode of the updraft
  33278. */
  33279. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33280. /**
  33281. * Returns the data related to the updraft event (cylinder).
  33282. * @returns A physics updraft event
  33283. */
  33284. getData(): PhysicsUpdraftEventData;
  33285. /**
  33286. * Enables the updraft.
  33287. */
  33288. enable(): void;
  33289. /**
  33290. * Disables the cortex.
  33291. */
  33292. disable(): void;
  33293. /**
  33294. * Disposes the sphere.
  33295. * @param force Specifies if the updraft should be disposed by force
  33296. */
  33297. dispose(force?: boolean): void;
  33298. private getImpostorForceAndContactPoint;
  33299. private _tick;
  33300. /*** Helpers ***/
  33301. private _prepareCylinder;
  33302. private _intersectsWithCylinder;
  33303. }
  33304. /**
  33305. * Represents a physics vortex event
  33306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33307. */
  33308. class PhysicsVortexEvent {
  33309. private _scene;
  33310. private _origin;
  33311. private _radius;
  33312. private _strength;
  33313. private _height;
  33314. private _physicsEngine;
  33315. private _originTop;
  33316. private _centripetalForceThreshold;
  33317. private _updraftMultiplier;
  33318. private _tickCallback;
  33319. private _cylinder;
  33320. private _cylinderPosition;
  33321. private _dataFetched;
  33322. /**
  33323. * Initializes the physics vortex event
  33324. * @param _scene The BabylonJS scene
  33325. * @param _origin The origin position of the vortex
  33326. * @param _radius The radius of the vortex
  33327. * @param _strength The strength of the vortex
  33328. * @param _height The height of the vortex
  33329. */
  33330. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33331. /**
  33332. * Returns the data related to the vortex event (cylinder).
  33333. * @returns The physics vortex event data
  33334. */
  33335. getData(): PhysicsVortexEventData;
  33336. /**
  33337. * Enables the vortex.
  33338. */
  33339. enable(): void;
  33340. /**
  33341. * Disables the cortex.
  33342. */
  33343. disable(): void;
  33344. /**
  33345. * Disposes the sphere.
  33346. * @param force
  33347. */
  33348. dispose(force?: boolean): void;
  33349. private getImpostorForceAndContactPoint;
  33350. private _tick;
  33351. /*** Helpers ***/
  33352. private _prepareCylinder;
  33353. private _intersectsWithCylinder;
  33354. }
  33355. /**
  33356. * The strenght of the force in correspondence to the distance of the affected object
  33357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33358. */
  33359. enum PhysicsRadialImpulseFalloff {
  33360. /** Defines that impulse is constant in strength across it's whole radius */
  33361. Constant = 0,
  33362. /** DEfines that impulse gets weaker if it's further from the origin */
  33363. Linear = 1
  33364. }
  33365. /**
  33366. * The strength of the force in correspondence to the distance of the affected object
  33367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33368. */
  33369. enum PhysicsUpdraftMode {
  33370. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33371. Center = 0,
  33372. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33373. Perpendicular = 1
  33374. }
  33375. /**
  33376. * Interface for a physics force and contact point
  33377. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33378. */
  33379. interface PhysicsForceAndContactPoint {
  33380. /**
  33381. * The force applied at the contact point
  33382. */
  33383. force: Vector3;
  33384. /**
  33385. * The contact point
  33386. */
  33387. contactPoint: Vector3;
  33388. }
  33389. /**
  33390. * Interface for radial explosion event data
  33391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33392. */
  33393. interface PhysicsRadialExplosionEventData {
  33394. /**
  33395. * A sphere used for the radial explosion event
  33396. */
  33397. sphere: Mesh;
  33398. /**
  33399. * An array of rays for the radial explosion event
  33400. */
  33401. rays: Array<Ray>;
  33402. }
  33403. /**
  33404. * Interface for gravitational field event data
  33405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33406. */
  33407. interface PhysicsGravitationalFieldEventData {
  33408. /**
  33409. * A sphere mesh used for the gravitational field event
  33410. */
  33411. sphere: Mesh;
  33412. }
  33413. /**
  33414. * Interface for updraft event data
  33415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33416. */
  33417. interface PhysicsUpdraftEventData {
  33418. /**
  33419. * A cylinder used for the updraft event
  33420. */
  33421. cylinder: Mesh;
  33422. }
  33423. /**
  33424. * Interface for vortex event data
  33425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33426. */
  33427. interface PhysicsVortexEventData {
  33428. /**
  33429. * A cylinder used for the vortex event
  33430. */
  33431. cylinder: Mesh;
  33432. }
  33433. }
  33434. declare module BABYLON {
  33435. /**
  33436. * The interface for the physics imposter parameters
  33437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33438. */
  33439. interface PhysicsImpostorParameters {
  33440. /**
  33441. * The mass of the physics imposter
  33442. */
  33443. mass: number;
  33444. /**
  33445. * The friction of the physics imposter
  33446. */
  33447. friction?: number;
  33448. /**
  33449. * The coefficient of restitution of the physics imposter
  33450. */
  33451. restitution?: number;
  33452. /**
  33453. * The native options of the physics imposter
  33454. */
  33455. nativeOptions?: any;
  33456. /**
  33457. * Specifies if the parent should be ignored
  33458. */
  33459. ignoreParent?: boolean;
  33460. /**
  33461. * Specifies if bi-directional transformations should be disabled
  33462. */
  33463. disableBidirectionalTransformation?: boolean;
  33464. }
  33465. /**
  33466. * Interface for a physics-enabled object
  33467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33468. */
  33469. interface IPhysicsEnabledObject {
  33470. /**
  33471. * The position of the physics-enabled object
  33472. */
  33473. position: Vector3;
  33474. /**
  33475. * The rotation of the physics-enabled object
  33476. */
  33477. rotationQuaternion: Nullable<Quaternion>;
  33478. /**
  33479. * The scale of the physics-enabled object
  33480. */
  33481. scaling: Vector3;
  33482. /**
  33483. * The rotation of the physics-enabled object
  33484. */
  33485. rotation?: Vector3;
  33486. /**
  33487. * The parent of the physics-enabled object
  33488. */
  33489. parent?: any;
  33490. /**
  33491. * The bounding info of the physics-enabled object
  33492. * @returns The bounding info of the physics-enabled object
  33493. */
  33494. getBoundingInfo(): BoundingInfo;
  33495. /**
  33496. * Computes the world matrix
  33497. * @param force Specifies if the world matrix should be computed by force
  33498. * @returns A world matrix
  33499. */
  33500. computeWorldMatrix(force: boolean): Matrix;
  33501. /**
  33502. * Gets the world matrix
  33503. * @returns A world matrix
  33504. */
  33505. getWorldMatrix?(): Matrix;
  33506. /**
  33507. * Gets the child meshes
  33508. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33509. * @returns An array of abstract meshes
  33510. */
  33511. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33512. /**
  33513. * Gets the vertex data
  33514. * @param kind The type of vertex data
  33515. * @returns A nullable array of numbers, or a float32 array
  33516. */
  33517. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33518. /**
  33519. * Gets the indices from the mesh
  33520. * @returns A nullable array of index arrays
  33521. */
  33522. getIndices?(): Nullable<IndicesArray>;
  33523. /**
  33524. * Gets the scene from the mesh
  33525. * @returns the indices array or null
  33526. */
  33527. getScene?(): Scene;
  33528. /**
  33529. * Gets the absolute position from the mesh
  33530. * @returns the absolute position
  33531. */
  33532. getAbsolutePosition(): Vector3;
  33533. /**
  33534. * Gets the absolute pivot point from the mesh
  33535. * @returns the absolute pivot point
  33536. */
  33537. getAbsolutePivotPoint(): Vector3;
  33538. /**
  33539. * Rotates the mesh
  33540. * @param axis The axis of rotation
  33541. * @param amount The amount of rotation
  33542. * @param space The space of the rotation
  33543. * @returns The rotation transform node
  33544. */
  33545. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33546. /**
  33547. * Translates the mesh
  33548. * @param axis The axis of translation
  33549. * @param distance The distance of translation
  33550. * @param space The space of the translation
  33551. * @returns The transform node
  33552. */
  33553. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33554. /**
  33555. * Sets the absolute position of the mesh
  33556. * @param absolutePosition The absolute position of the mesh
  33557. * @returns The transform node
  33558. */
  33559. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33560. /**
  33561. * Gets the class name of the mesh
  33562. * @returns The class name
  33563. */
  33564. getClassName(): string;
  33565. }
  33566. /**
  33567. * Represents a physics imposter
  33568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33569. */
  33570. class PhysicsImpostor {
  33571. /**
  33572. * The physics-enabled object used as the physics imposter
  33573. */
  33574. object: IPhysicsEnabledObject;
  33575. /**
  33576. * The type of the physics imposter
  33577. */
  33578. type: number;
  33579. private _options;
  33580. private _scene?;
  33581. /**
  33582. * The default object size of the imposter
  33583. */
  33584. static DEFAULT_OBJECT_SIZE: Vector3;
  33585. /**
  33586. * The identity quaternion of the imposter
  33587. */
  33588. static IDENTITY_QUATERNION: Quaternion;
  33589. private _physicsEngine;
  33590. private _physicsBody;
  33591. private _bodyUpdateRequired;
  33592. private _onBeforePhysicsStepCallbacks;
  33593. private _onAfterPhysicsStepCallbacks;
  33594. private _onPhysicsCollideCallbacks;
  33595. private _deltaPosition;
  33596. private _deltaRotation;
  33597. private _deltaRotationConjugated;
  33598. private _parent;
  33599. private _isDisposed;
  33600. private static _tmpVecs;
  33601. private static _tmpQuat;
  33602. /**
  33603. * Specifies if the physics imposter is disposed
  33604. */
  33605. readonly isDisposed: boolean;
  33606. /**
  33607. * Gets the mass of the physics imposter
  33608. */
  33609. mass: number;
  33610. /**
  33611. * Gets the coefficient of friction
  33612. */
  33613. /**
  33614. * Sets the coefficient of friction
  33615. */
  33616. friction: number;
  33617. /**
  33618. * Gets the coefficient of restitution
  33619. */
  33620. /**
  33621. * Sets the coefficient of restitution
  33622. */
  33623. restitution: number;
  33624. /**
  33625. * The unique id of the physics imposter
  33626. * set by the physics engine when adding this impostor to the array
  33627. */
  33628. uniqueId: number;
  33629. private _joints;
  33630. /**
  33631. * Initializes the physics imposter
  33632. * @param object The physics-enabled object used as the physics imposter
  33633. * @param type The type of the physics imposter
  33634. * @param _options The options for the physics imposter
  33635. * @param _scene The Babylon scene
  33636. */
  33637. constructor(
  33638. /**
  33639. * The physics-enabled object used as the physics imposter
  33640. */
  33641. object: IPhysicsEnabledObject,
  33642. /**
  33643. * The type of the physics imposter
  33644. */
  33645. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33646. /**
  33647. * This function will completly initialize this impostor.
  33648. * It will create a new body - but only if this mesh has no parent.
  33649. * If it has, this impostor will not be used other than to define the impostor
  33650. * of the child mesh.
  33651. * @hidden
  33652. */
  33653. _init(): void;
  33654. private _getPhysicsParent;
  33655. /**
  33656. * Should a new body be generated.
  33657. * @returns boolean specifying if body initialization is required
  33658. */
  33659. isBodyInitRequired(): boolean;
  33660. /**
  33661. * Sets the updated scaling
  33662. * @param updated Specifies if the scaling is updated
  33663. */
  33664. setScalingUpdated(updated: boolean): void;
  33665. /**
  33666. * Force a regeneration of this or the parent's impostor's body.
  33667. * Use under cautious - This will remove all joints already implemented.
  33668. */
  33669. forceUpdate(): void;
  33670. /**
  33671. * Gets the body that holds this impostor. Either its own, or its parent.
  33672. */
  33673. /**
  33674. * Set the physics body. Used mainly by the physics engine/plugin
  33675. */
  33676. physicsBody: any;
  33677. /**
  33678. * Get the parent of the physics imposter
  33679. * @returns Physics imposter or null
  33680. */
  33681. /**
  33682. * Sets the parent of the physics imposter
  33683. */
  33684. parent: Nullable<PhysicsImpostor>;
  33685. /**
  33686. * Resets the update flags
  33687. */
  33688. resetUpdateFlags(): void;
  33689. /**
  33690. * Gets the object extend size
  33691. * @returns the object extend size
  33692. */
  33693. getObjectExtendSize(): Vector3;
  33694. /**
  33695. * Gets the object center
  33696. * @returns The object center
  33697. */
  33698. getObjectCenter(): Vector3;
  33699. /**
  33700. * Get a specific parametes from the options parameter
  33701. * @param paramName The object parameter name
  33702. * @returns The object parameter
  33703. */
  33704. getParam(paramName: string): any;
  33705. /**
  33706. * Sets a specific parameter in the options given to the physics plugin
  33707. * @param paramName The parameter name
  33708. * @param value The value of the parameter
  33709. */
  33710. setParam(paramName: string, value: number): void;
  33711. /**
  33712. * Specifically change the body's mass option. Won't recreate the physics body object
  33713. * @param mass The mass of the physics imposter
  33714. */
  33715. setMass(mass: number): void;
  33716. /**
  33717. * Gets the linear velocity
  33718. * @returns linear velocity or null
  33719. */
  33720. getLinearVelocity(): Nullable<Vector3>;
  33721. /**
  33722. * Sets the linear velocity
  33723. * @param velocity linear velocity or null
  33724. */
  33725. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33726. /**
  33727. * Gets the angular velocity
  33728. * @returns angular velocity or null
  33729. */
  33730. getAngularVelocity(): Nullable<Vector3>;
  33731. /**
  33732. * Sets the angular velocity
  33733. * @param velocity The velocity or null
  33734. */
  33735. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33736. /**
  33737. * Execute a function with the physics plugin native code
  33738. * Provide a function the will have two variables - the world object and the physics body object
  33739. * @param func The function to execute with the physics plugin native code
  33740. */
  33741. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33742. /**
  33743. * Register a function that will be executed before the physics world is stepping forward
  33744. * @param func The function to execute before the physics world is stepped forward
  33745. */
  33746. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33747. /**
  33748. * Unregister a function that will be executed before the physics world is stepping forward
  33749. * @param func The function to execute before the physics world is stepped forward
  33750. */
  33751. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33752. /**
  33753. * Register a function that will be executed after the physics step
  33754. * @param func The function to execute after physics step
  33755. */
  33756. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33757. /**
  33758. * Unregisters a function that will be executed after the physics step
  33759. * @param func The function to execute after physics step
  33760. */
  33761. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33762. /**
  33763. * register a function that will be executed when this impostor collides against a different body
  33764. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33765. * @param func Callback that is executed on collision
  33766. */
  33767. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33768. /**
  33769. * Unregisters the physics imposter on contact
  33770. * @param collideAgainst The physics object to collide against
  33771. * @param func Callback to execute on collision
  33772. */
  33773. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33774. private _tmpQuat;
  33775. private _tmpQuat2;
  33776. /**
  33777. * Get the parent rotation
  33778. * @returns The parent rotation
  33779. */
  33780. getParentsRotation(): Quaternion;
  33781. /**
  33782. * this function is executed by the physics engine.
  33783. */
  33784. beforeStep: () => void;
  33785. /**
  33786. * this function is executed by the physics engine
  33787. */
  33788. afterStep: () => void;
  33789. /**
  33790. * Legacy collision detection event support
  33791. */
  33792. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33793. /**
  33794. * event and body object due to cannon's event-based architecture.
  33795. */
  33796. onCollide: (e: {
  33797. body: any;
  33798. }) => void;
  33799. /**
  33800. * Apply a force
  33801. * @param force The force to apply
  33802. * @param contactPoint The contact point for the force
  33803. * @returns The physics imposter
  33804. */
  33805. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33806. /**
  33807. * Apply an impulse
  33808. * @param force The impulse force
  33809. * @param contactPoint The contact point for the impulse force
  33810. * @returns The physics imposter
  33811. */
  33812. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33813. /**
  33814. * A help function to create a joint
  33815. * @param otherImpostor A physics imposter used to create a joint
  33816. * @param jointType The type of joint
  33817. * @param jointData The data for the joint
  33818. * @returns The physics imposter
  33819. */
  33820. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33821. /**
  33822. * Add a joint to this impostor with a different impostor
  33823. * @param otherImpostor A physics imposter used to add a joint
  33824. * @param joint The joint to add
  33825. * @returns The physics imposter
  33826. */
  33827. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33828. /**
  33829. * Will keep this body still, in a sleep mode.
  33830. * @returns the physics imposter
  33831. */
  33832. sleep(): PhysicsImpostor;
  33833. /**
  33834. * Wake the body up.
  33835. * @returns The physics imposter
  33836. */
  33837. wakeUp(): PhysicsImpostor;
  33838. /**
  33839. * Clones the physics imposter
  33840. * @param newObject The physics imposter clones to this physics-enabled object
  33841. * @returns A nullable physics imposter
  33842. */
  33843. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33844. /**
  33845. * Disposes the physics imposter
  33846. */
  33847. dispose(): void;
  33848. /**
  33849. * Sets the delta position
  33850. * @param position The delta position amount
  33851. */
  33852. setDeltaPosition(position: Vector3): void;
  33853. /**
  33854. * Sets the delta rotation
  33855. * @param rotation The delta rotation amount
  33856. */
  33857. setDeltaRotation(rotation: Quaternion): void;
  33858. /**
  33859. * Gets the box size of the physics imposter and stores the result in the input parameter
  33860. * @param result Stores the box size
  33861. * @returns The physics imposter
  33862. */
  33863. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33864. /**
  33865. * Gets the radius of the physics imposter
  33866. * @returns Radius of the physics imposter
  33867. */
  33868. getRadius(): number;
  33869. /**
  33870. * Sync a bone with this impostor
  33871. * @param bone The bone to sync to the impostor.
  33872. * @param boneMesh The mesh that the bone is influencing.
  33873. * @param jointPivot The pivot of the joint / bone in local space.
  33874. * @param distToJoint Optional distance from the impostor to the joint.
  33875. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33876. */
  33877. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33878. /**
  33879. * Sync impostor to a bone
  33880. * @param bone The bone that the impostor will be synced to.
  33881. * @param boneMesh The mesh that the bone is influencing.
  33882. * @param jointPivot The pivot of the joint / bone in local space.
  33883. * @param distToJoint Optional distance from the impostor to the joint.
  33884. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33885. * @param boneAxis Optional vector3 axis the bone is aligned with
  33886. */
  33887. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33888. /**
  33889. * No-Imposter type
  33890. */
  33891. static NoImpostor: number;
  33892. /**
  33893. * Sphere-Imposter type
  33894. */
  33895. static SphereImpostor: number;
  33896. /**
  33897. * Box-Imposter type
  33898. */
  33899. static BoxImpostor: number;
  33900. /**
  33901. * Plane-Imposter type
  33902. */
  33903. static PlaneImpostor: number;
  33904. /**
  33905. * Mesh-imposter type
  33906. */
  33907. static MeshImpostor: number;
  33908. /**
  33909. * Cylinder-Imposter type
  33910. */
  33911. static CylinderImpostor: number;
  33912. /**
  33913. * Particle-Imposter type
  33914. */
  33915. static ParticleImpostor: number;
  33916. /**
  33917. * Heightmap-Imposter type
  33918. */
  33919. static HeightmapImpostor: number;
  33920. }
  33921. }
  33922. declare module BABYLON {
  33923. /**
  33924. * Interface for Physics-Joint data
  33925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33926. */
  33927. interface PhysicsJointData {
  33928. /**
  33929. * The main pivot of the joint
  33930. */
  33931. mainPivot?: Vector3;
  33932. /**
  33933. * The connected pivot of the joint
  33934. */
  33935. connectedPivot?: Vector3;
  33936. /**
  33937. * The main axis of the joint
  33938. */
  33939. mainAxis?: Vector3;
  33940. /**
  33941. * The connected axis of the joint
  33942. */
  33943. connectedAxis?: Vector3;
  33944. /**
  33945. * The collision of the joint
  33946. */
  33947. collision?: boolean;
  33948. /**
  33949. * Native Oimo/Cannon/Energy data
  33950. */
  33951. nativeParams?: any;
  33952. }
  33953. /**
  33954. * This is a holder class for the physics joint created by the physics plugin
  33955. * It holds a set of functions to control the underlying joint
  33956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33957. */
  33958. class PhysicsJoint {
  33959. /**
  33960. * The type of the physics joint
  33961. */
  33962. type: number;
  33963. /**
  33964. * The data for the physics joint
  33965. */
  33966. jointData: PhysicsJointData;
  33967. private _physicsJoint;
  33968. protected _physicsPlugin: IPhysicsEnginePlugin;
  33969. /**
  33970. * Initializes the physics joint
  33971. * @param type The type of the physics joint
  33972. * @param jointData The data for the physics joint
  33973. */
  33974. constructor(
  33975. /**
  33976. * The type of the physics joint
  33977. */
  33978. type: number,
  33979. /**
  33980. * The data for the physics joint
  33981. */
  33982. jointData: PhysicsJointData);
  33983. /**
  33984. * Gets the physics joint
  33985. */
  33986. /**
  33987. * Sets the physics joint
  33988. */
  33989. physicsJoint: any;
  33990. /**
  33991. * Sets the physics plugin
  33992. */
  33993. physicsPlugin: IPhysicsEnginePlugin;
  33994. /**
  33995. * Execute a function that is physics-plugin specific.
  33996. * @param {Function} func the function that will be executed.
  33997. * It accepts two parameters: the physics world and the physics joint
  33998. */
  33999. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34000. /**
  34001. * Distance-Joint type
  34002. */
  34003. static DistanceJoint: number;
  34004. /**
  34005. * Hinge-Joint type
  34006. */
  34007. static HingeJoint: number;
  34008. /**
  34009. * Ball-and-Socket joint type
  34010. */
  34011. static BallAndSocketJoint: number;
  34012. /**
  34013. * Wheel-Joint type
  34014. */
  34015. static WheelJoint: number;
  34016. /**
  34017. * Slider-Joint type
  34018. */
  34019. static SliderJoint: number;
  34020. /**
  34021. * Prismatic-Joint type
  34022. */
  34023. static PrismaticJoint: number;
  34024. /**
  34025. * Universal-Joint type
  34026. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34027. */
  34028. static UniversalJoint: number;
  34029. /**
  34030. * Hinge-Joint 2 type
  34031. */
  34032. static Hinge2Joint: number;
  34033. /**
  34034. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34035. */
  34036. static PointToPointJoint: number;
  34037. /**
  34038. * Spring-Joint type
  34039. */
  34040. static SpringJoint: number;
  34041. /**
  34042. * Lock-Joint type
  34043. */
  34044. static LockJoint: number;
  34045. }
  34046. /**
  34047. * A class representing a physics distance joint
  34048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34049. */
  34050. class DistanceJoint extends PhysicsJoint {
  34051. /**
  34052. *
  34053. * @param jointData The data for the Distance-Joint
  34054. */
  34055. constructor(jointData: DistanceJointData);
  34056. /**
  34057. * Update the predefined distance.
  34058. * @param maxDistance The maximum preferred distance
  34059. * @param minDistance The minimum preferred distance
  34060. */
  34061. updateDistance(maxDistance: number, minDistance?: number): void;
  34062. }
  34063. /**
  34064. * Represents a Motor-Enabled Joint
  34065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34066. */
  34067. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34068. /**
  34069. * Initializes the Motor-Enabled Joint
  34070. * @param type The type of the joint
  34071. * @param jointData The physica joint data for the joint
  34072. */
  34073. constructor(type: number, jointData: PhysicsJointData);
  34074. /**
  34075. * Set the motor values.
  34076. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34077. * @param force the force to apply
  34078. * @param maxForce max force for this motor.
  34079. */
  34080. setMotor(force?: number, maxForce?: number): void;
  34081. /**
  34082. * Set the motor's limits.
  34083. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34084. * @param upperLimit The upper limit of the motor
  34085. * @param lowerLimit The lower limit of the motor
  34086. */
  34087. setLimit(upperLimit: number, lowerLimit?: number): void;
  34088. }
  34089. /**
  34090. * This class represents a single physics Hinge-Joint
  34091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34092. */
  34093. class HingeJoint extends MotorEnabledJoint {
  34094. /**
  34095. * Initializes the Hinge-Joint
  34096. * @param jointData The joint data for the Hinge-Joint
  34097. */
  34098. constructor(jointData: PhysicsJointData);
  34099. /**
  34100. * Set the motor values.
  34101. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34102. * @param {number} force the force to apply
  34103. * @param {number} maxForce max force for this motor.
  34104. */
  34105. setMotor(force?: number, maxForce?: number): void;
  34106. /**
  34107. * Set the motor's limits.
  34108. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34109. * @param upperLimit The upper limit of the motor
  34110. * @param lowerLimit The lower limit of the motor
  34111. */
  34112. setLimit(upperLimit: number, lowerLimit?: number): void;
  34113. }
  34114. /**
  34115. * This class represents a dual hinge physics joint (same as wheel joint)
  34116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34117. */
  34118. class Hinge2Joint extends MotorEnabledJoint {
  34119. /**
  34120. * Initializes the Hinge2-Joint
  34121. * @param jointData The joint data for the Hinge2-Joint
  34122. */
  34123. constructor(jointData: PhysicsJointData);
  34124. /**
  34125. * Set the motor values.
  34126. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34127. * @param {number} force the force to apply
  34128. * @param {number} maxForce max force for this motor.
  34129. * @param {motorIndex} the motor's index, 0 or 1.
  34130. */
  34131. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34132. /**
  34133. * Set the motor limits.
  34134. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34135. * @param {number} upperLimit the upper limit
  34136. * @param {number} lowerLimit lower limit
  34137. * @param {motorIndex} the motor's index, 0 or 1.
  34138. */
  34139. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34140. }
  34141. /**
  34142. * Interface for a motor enabled joint
  34143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34144. */
  34145. interface IMotorEnabledJoint {
  34146. /**
  34147. * Physics joint
  34148. */
  34149. physicsJoint: any;
  34150. /**
  34151. * Sets the motor of the motor-enabled joint
  34152. * @param force The force of the motor
  34153. * @param maxForce The maximum force of the motor
  34154. * @param motorIndex The index of the motor
  34155. */
  34156. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34157. /**
  34158. * Sets the limit of the motor
  34159. * @param upperLimit The upper limit of the motor
  34160. * @param lowerLimit The lower limit of the motor
  34161. * @param motorIndex The index of the motor
  34162. */
  34163. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34164. }
  34165. /**
  34166. * Joint data for a Distance-Joint
  34167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34168. */
  34169. interface DistanceJointData extends PhysicsJointData {
  34170. /**
  34171. * Max distance the 2 joint objects can be apart
  34172. */
  34173. maxDistance: number;
  34174. }
  34175. /**
  34176. * Joint data from a spring joint
  34177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34178. */
  34179. interface SpringJointData extends PhysicsJointData {
  34180. /**
  34181. * Length of the spring
  34182. */
  34183. length: number;
  34184. /**
  34185. * Stiffness of the spring
  34186. */
  34187. stiffness: number;
  34188. /**
  34189. * Damping of the spring
  34190. */
  34191. damping: number;
  34192. /** this callback will be called when applying the force to the impostors. */
  34193. forceApplicationCallback: () => void;
  34194. }
  34195. }
  34196. declare module BABYLON {
  34197. interface Scene {
  34198. /**
  34199. * The list of reflection probes added to the scene
  34200. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34201. */
  34202. reflectionProbes: Array<ReflectionProbe>;
  34203. }
  34204. /**
  34205. * Class used to generate realtime reflection / refraction cube textures
  34206. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34207. */
  34208. class ReflectionProbe {
  34209. /** defines the name of the probe */
  34210. name: string;
  34211. private _scene;
  34212. private _renderTargetTexture;
  34213. private _projectionMatrix;
  34214. private _viewMatrix;
  34215. private _target;
  34216. private _add;
  34217. private _attachedMesh;
  34218. private _invertYAxis;
  34219. /** Gets or sets probe position (center of the cube map) */
  34220. position: Vector3;
  34221. /**
  34222. * Creates a new reflection probe
  34223. * @param name defines the name of the probe
  34224. * @param size defines the texture resolution (for each face)
  34225. * @param scene defines the hosting scene
  34226. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34227. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34228. */
  34229. constructor(
  34230. /** defines the name of the probe */
  34231. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34232. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34233. samples: number;
  34234. /** Gets or sets the refresh rate to use (on every frame by default) */
  34235. refreshRate: number;
  34236. /**
  34237. * Gets the hosting scene
  34238. * @returns a Scene
  34239. */
  34240. getScene(): Scene;
  34241. /** Gets the internal CubeTexture used to render to */
  34242. readonly cubeTexture: RenderTargetTexture;
  34243. /** Gets the list of meshes to render */
  34244. readonly renderList: Nullable<AbstractMesh[]>;
  34245. /**
  34246. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34247. * @param mesh defines the mesh to attach to
  34248. */
  34249. attachToMesh(mesh: AbstractMesh): void;
  34250. /**
  34251. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34252. * @param renderingGroupId The rendering group id corresponding to its index
  34253. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34254. */
  34255. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34256. /**
  34257. * Clean all associated resources
  34258. */
  34259. dispose(): void;
  34260. }
  34261. }
  34262. declare module BABYLON {
  34263. /**
  34264. * Postprocess used to generate anaglyphic rendering
  34265. */
  34266. class AnaglyphPostProcess extends PostProcess {
  34267. private _passedProcess;
  34268. /**
  34269. * Creates a new AnaglyphPostProcess
  34270. * @param name defines postprocess name
  34271. * @param options defines creation options or target ratio scale
  34272. * @param rigCameras defines cameras using this postprocess
  34273. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34274. * @param engine defines hosting engine
  34275. * @param reusable defines if the postprocess will be reused multiple times per frame
  34276. */
  34277. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34278. }
  34279. }
  34280. declare module BABYLON {
  34281. /**
  34282. * Post process used to render in black and white
  34283. */
  34284. class BlackAndWhitePostProcess extends PostProcess {
  34285. /**
  34286. * Linear about to convert he result to black and white (default: 1)
  34287. */
  34288. degree: number;
  34289. /**
  34290. * Creates a black and white post process
  34291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34292. * @param name The name of the effect.
  34293. * @param options The required width/height ratio to downsize to before computing the render pass.
  34294. * @param camera The camera to apply the render pass to.
  34295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34296. * @param engine The engine which the post process will be applied. (default: current engine)
  34297. * @param reusable If the post process can be reused on the same frame. (default: false)
  34298. */
  34299. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34300. }
  34301. }
  34302. declare module BABYLON {
  34303. /**
  34304. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34305. */
  34306. class BloomEffect extends PostProcessRenderEffect {
  34307. private bloomScale;
  34308. /**
  34309. * @hidden Internal
  34310. */
  34311. _effects: Array<PostProcess>;
  34312. /**
  34313. * @hidden Internal
  34314. */
  34315. _downscale: ExtractHighlightsPostProcess;
  34316. private _blurX;
  34317. private _blurY;
  34318. private _merge;
  34319. /**
  34320. * The luminance threshold to find bright areas of the image to bloom.
  34321. */
  34322. threshold: number;
  34323. /**
  34324. * The strength of the bloom.
  34325. */
  34326. weight: number;
  34327. /**
  34328. * Specifies the size of the bloom blur kernel, relative to the final output size
  34329. */
  34330. kernel: number;
  34331. /**
  34332. * Creates a new instance of @see BloomEffect
  34333. * @param scene The scene the effect belongs to.
  34334. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34335. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34336. * @param bloomWeight The the strength of bloom.
  34337. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34338. * @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)
  34339. */
  34340. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34341. /**
  34342. * Disposes each of the internal effects for a given camera.
  34343. * @param camera The camera to dispose the effect on.
  34344. */
  34345. disposeEffects(camera: Camera): void;
  34346. /**
  34347. * @hidden Internal
  34348. */
  34349. _updateEffects(): void;
  34350. /**
  34351. * Internal
  34352. * @returns if all the contained post processes are ready.
  34353. * @hidden
  34354. */
  34355. _isReady(): boolean;
  34356. }
  34357. }
  34358. declare module BABYLON {
  34359. /**
  34360. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34361. */
  34362. class BloomMergePostProcess extends PostProcess {
  34363. /** Weight of the bloom to be added to the original input. */
  34364. weight: number;
  34365. /**
  34366. * Creates a new instance of @see BloomMergePostProcess
  34367. * @param name The name of the effect.
  34368. * @param originalFromInput Post process which's input will be used for the merge.
  34369. * @param blurred Blurred highlights post process which's output will be used.
  34370. * @param weight Weight of the bloom to be added to the original input.
  34371. * @param options The required width/height ratio to downsize to before computing the render pass.
  34372. * @param camera The camera to apply the render pass to.
  34373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34374. * @param engine The engine which the post process will be applied. (default: current engine)
  34375. * @param reusable If the post process can be reused on the same frame. (default: false)
  34376. * @param textureType Type of textures used when performing the post process. (default: 0)
  34377. * @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)
  34378. */
  34379. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34380. /** Weight of the bloom to be added to the original input. */
  34381. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34382. }
  34383. }
  34384. declare module BABYLON {
  34385. /**
  34386. * The Blur Post Process which blurs an image based on a kernel and direction.
  34387. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34388. */
  34389. class BlurPostProcess extends PostProcess {
  34390. /** The direction in which to blur the image. */
  34391. direction: Vector2;
  34392. private blockCompilation;
  34393. protected _kernel: number;
  34394. protected _idealKernel: number;
  34395. protected _packedFloat: boolean;
  34396. private _staticDefines;
  34397. /**
  34398. * Sets the length in pixels of the blur sample region
  34399. */
  34400. /**
  34401. * Gets the length in pixels of the blur sample region
  34402. */
  34403. kernel: number;
  34404. /**
  34405. * Sets wether or not the blur needs to unpack/repack floats
  34406. */
  34407. /**
  34408. * Gets wether or not the blur is unpacking/repacking floats
  34409. */
  34410. packedFloat: boolean;
  34411. /**
  34412. * Creates a new instance BlurPostProcess
  34413. * @param name The name of the effect.
  34414. * @param direction The direction in which to blur the image.
  34415. * @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.
  34416. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34417. * @param camera The camera to apply the render pass to.
  34418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34419. * @param engine The engine which the post process will be applied. (default: current engine)
  34420. * @param reusable If the post process can be reused on the same frame. (default: false)
  34421. * @param textureType Type of textures used when performing the post process. (default: 0)
  34422. * @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)
  34423. */
  34424. constructor(name: string,
  34425. /** The direction in which to blur the image. */
  34426. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34427. /**
  34428. * Updates the effect with the current post process compile time values and recompiles the shader.
  34429. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34430. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34431. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34432. * @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
  34433. * @param onCompiled Called when the shader has been compiled.
  34434. * @param onError Called if there is an error when compiling a shader.
  34435. */
  34436. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34437. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34438. /**
  34439. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34440. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34441. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34442. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34443. * The gaps between physical kernels are compensated for in the weighting of the samples
  34444. * @param idealKernel Ideal blur kernel.
  34445. * @return Nearest best kernel.
  34446. */
  34447. protected _nearestBestKernel(idealKernel: number): number;
  34448. /**
  34449. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34450. * @param x The point on the Gaussian distribution to sample.
  34451. * @return the value of the Gaussian function at x.
  34452. */
  34453. protected _gaussianWeight(x: number): number;
  34454. /**
  34455. * Generates a string that can be used as a floating point number in GLSL.
  34456. * @param x Value to print.
  34457. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34458. * @return GLSL float string.
  34459. */
  34460. protected _glslFloat(x: number, decimalFigures?: number): string;
  34461. }
  34462. }
  34463. declare module BABYLON {
  34464. /**
  34465. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34466. */
  34467. class ChromaticAberrationPostProcess extends PostProcess {
  34468. /**
  34469. * The amount of seperation of rgb channels (default: 30)
  34470. */
  34471. aberrationAmount: number;
  34472. /**
  34473. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34474. */
  34475. radialIntensity: number;
  34476. /**
  34477. * 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))
  34478. */
  34479. direction: Vector2;
  34480. /**
  34481. * 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))
  34482. */
  34483. centerPosition: Vector2;
  34484. /**
  34485. * Creates a new instance ChromaticAberrationPostProcess
  34486. * @param name The name of the effect.
  34487. * @param screenWidth The width of the screen to apply the effect on.
  34488. * @param screenHeight The height of the screen to apply the effect on.
  34489. * @param options The required width/height ratio to downsize to before computing the render pass.
  34490. * @param camera The camera to apply the render pass to.
  34491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34492. * @param engine The engine which the post process will be applied. (default: current engine)
  34493. * @param reusable If the post process can be reused on the same frame. (default: false)
  34494. * @param textureType Type of textures used when performing the post process. (default: 0)
  34495. * @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)
  34496. */
  34497. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34498. }
  34499. }
  34500. declare module BABYLON {
  34501. /**
  34502. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34503. */
  34504. class CircleOfConfusionPostProcess extends PostProcess {
  34505. /**
  34506. * 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.
  34507. */
  34508. lensSize: number;
  34509. /**
  34510. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34511. */
  34512. fStop: number;
  34513. /**
  34514. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34515. */
  34516. focusDistance: number;
  34517. /**
  34518. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34519. */
  34520. focalLength: number;
  34521. private _depthTexture;
  34522. /**
  34523. * Creates a new instance CircleOfConfusionPostProcess
  34524. * @param name The name of the effect.
  34525. * @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.
  34526. * @param options The required width/height ratio to downsize to before computing the render pass.
  34527. * @param camera The camera to apply the render pass to.
  34528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34529. * @param engine The engine which the post process will be applied. (default: current engine)
  34530. * @param reusable If the post process can be reused on the same frame. (default: false)
  34531. * @param textureType Type of textures used when performing the post process. (default: 0)
  34532. * @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)
  34533. */
  34534. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34535. /**
  34536. * 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.
  34537. */
  34538. depthTexture: RenderTargetTexture;
  34539. }
  34540. }
  34541. declare module BABYLON {
  34542. /**
  34543. *
  34544. * This post-process allows the modification of rendered colors by using
  34545. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34546. *
  34547. * The object needs to be provided an url to a texture containing the color
  34548. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34549. * Use an image editing software to tweak the LUT to match your needs.
  34550. *
  34551. * For an example of a color LUT, see here:
  34552. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34553. * For explanations on color grading, see here:
  34554. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34555. *
  34556. */
  34557. class ColorCorrectionPostProcess extends PostProcess {
  34558. private _colorTableTexture;
  34559. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34560. }
  34561. }
  34562. declare module BABYLON {
  34563. /**
  34564. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34565. * input texture to perform effects such as edge detection or sharpening
  34566. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34567. */
  34568. class ConvolutionPostProcess extends PostProcess {
  34569. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34570. kernel: number[];
  34571. /**
  34572. * Creates a new instance ConvolutionPostProcess
  34573. * @param name The name of the effect.
  34574. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34575. * @param options The required width/height ratio to downsize to before computing the render pass.
  34576. * @param camera The camera to apply the render pass to.
  34577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34578. * @param engine The engine which the post process will be applied. (default: current engine)
  34579. * @param reusable If the post process can be reused on the same frame. (default: false)
  34580. * @param textureType Type of textures used when performing the post process. (default: 0)
  34581. */
  34582. constructor(name: string,
  34583. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34584. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34585. /**
  34586. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34587. */
  34588. static EdgeDetect0Kernel: number[];
  34589. /**
  34590. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34591. */
  34592. static EdgeDetect1Kernel: number[];
  34593. /**
  34594. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34595. */
  34596. static EdgeDetect2Kernel: number[];
  34597. /**
  34598. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34599. */
  34600. static SharpenKernel: number[];
  34601. /**
  34602. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34603. */
  34604. static EmbossKernel: number[];
  34605. /**
  34606. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34607. */
  34608. static GaussianKernel: number[];
  34609. }
  34610. }
  34611. declare module BABYLON {
  34612. /**
  34613. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34614. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34615. * based on samples that have a large difference in distance than the center pixel.
  34616. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34617. */
  34618. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34619. direction: Vector2;
  34620. /**
  34621. * Creates a new instance CircleOfConfusionPostProcess
  34622. * @param name The name of the effect.
  34623. * @param scene The scene the effect belongs to.
  34624. * @param direction The direction the blur should be applied.
  34625. * @param kernel The size of the kernel used to blur.
  34626. * @param options The required width/height ratio to downsize to before computing the render pass.
  34627. * @param camera The camera to apply the render pass to.
  34628. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34629. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34631. * @param engine The engine which the post process will be applied. (default: current engine)
  34632. * @param reusable If the post process can be reused on the same frame. (default: false)
  34633. * @param textureType Type of textures used when performing the post process. (default: 0)
  34634. * @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)
  34635. */
  34636. 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);
  34637. }
  34638. }
  34639. declare module BABYLON {
  34640. /**
  34641. * Specifies the level of max blur that should be applied when using the depth of field effect
  34642. */
  34643. enum DepthOfFieldEffectBlurLevel {
  34644. /**
  34645. * Subtle blur
  34646. */
  34647. Low = 0,
  34648. /**
  34649. * Medium blur
  34650. */
  34651. Medium = 1,
  34652. /**
  34653. * Large blur
  34654. */
  34655. High = 2
  34656. }
  34657. /**
  34658. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34659. */
  34660. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34661. private _circleOfConfusion;
  34662. /**
  34663. * @hidden Internal, blurs from high to low
  34664. */
  34665. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34666. private _depthOfFieldBlurY;
  34667. private _dofMerge;
  34668. /**
  34669. * @hidden Internal post processes in depth of field effect
  34670. */
  34671. _effects: Array<PostProcess>;
  34672. /**
  34673. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34674. */
  34675. focalLength: number;
  34676. /**
  34677. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34678. */
  34679. fStop: number;
  34680. /**
  34681. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34682. */
  34683. focusDistance: number;
  34684. /**
  34685. * 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.
  34686. */
  34687. lensSize: number;
  34688. /**
  34689. * Creates a new instance DepthOfFieldEffect
  34690. * @param scene The scene the effect belongs to.
  34691. * @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.
  34692. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34693. * @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)
  34694. */
  34695. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34696. /**
  34697. * 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.
  34698. */
  34699. depthTexture: RenderTargetTexture;
  34700. /**
  34701. * Disposes each of the internal effects for a given camera.
  34702. * @param camera The camera to dispose the effect on.
  34703. */
  34704. disposeEffects(camera: Camera): void;
  34705. /**
  34706. * @hidden Internal
  34707. */
  34708. _updateEffects(): void;
  34709. /**
  34710. * Internal
  34711. * @returns if all the contained post processes are ready.
  34712. * @hidden
  34713. */
  34714. _isReady(): boolean;
  34715. }
  34716. }
  34717. declare module BABYLON {
  34718. /**
  34719. * Options to be set when merging outputs from the default pipeline.
  34720. */
  34721. class DepthOfFieldMergePostProcessOptions {
  34722. /**
  34723. * The original image to merge on top of
  34724. */
  34725. originalFromInput: PostProcess;
  34726. /**
  34727. * Parameters to perform the merge of the depth of field effect
  34728. */
  34729. depthOfField?: {
  34730. circleOfConfusion: PostProcess;
  34731. blurSteps: Array<PostProcess>;
  34732. };
  34733. /**
  34734. * Parameters to perform the merge of bloom effect
  34735. */
  34736. bloom?: {
  34737. blurred: PostProcess;
  34738. weight: number;
  34739. };
  34740. }
  34741. /**
  34742. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34743. */
  34744. class DepthOfFieldMergePostProcess extends PostProcess {
  34745. private blurSteps;
  34746. /**
  34747. * Creates a new instance of DepthOfFieldMergePostProcess
  34748. * @param name The name of the effect.
  34749. * @param originalFromInput Post process which's input will be used for the merge.
  34750. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  34751. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  34752. * @param options The required width/height ratio to downsize to before computing the render pass.
  34753. * @param camera The camera to apply the render pass to.
  34754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34755. * @param engine The engine which the post process will be applied. (default: current engine)
  34756. * @param reusable If the post process can be reused on the same frame. (default: false)
  34757. * @param textureType Type of textures used when performing the post process. (default: 0)
  34758. * @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)
  34759. */
  34760. 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);
  34761. /**
  34762. * Updates the effect with the current post process compile time values and recompiles the shader.
  34763. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34764. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34765. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34766. * @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
  34767. * @param onCompiled Called when the shader has been compiled.
  34768. * @param onError Called if there is an error when compiling a shader.
  34769. */
  34770. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34771. }
  34772. }
  34773. declare module BABYLON {
  34774. /**
  34775. * DisplayPassPostProcess which produces an output the same as it's input
  34776. */
  34777. class DisplayPassPostProcess extends PostProcess {
  34778. /**
  34779. * Creates the DisplayPassPostProcess
  34780. * @param name The name of the effect.
  34781. * @param options The required width/height ratio to downsize to before computing the render pass.
  34782. * @param camera The camera to apply the render pass to.
  34783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34784. * @param engine The engine which the post process will be applied. (default: current engine)
  34785. * @param reusable If the post process can be reused on the same frame. (default: false)
  34786. */
  34787. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34788. }
  34789. }
  34790. declare module BABYLON {
  34791. /**
  34792. * 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.
  34793. */
  34794. class ExtractHighlightsPostProcess extends PostProcess {
  34795. /**
  34796. * The luminance threshold, pixels below this value will be set to black.
  34797. */
  34798. threshold: number;
  34799. /** @hidden */
  34800. _exposure: number;
  34801. /**
  34802. * Post process which has the input texture to be used when performing highlight extraction
  34803. * @hidden
  34804. */
  34805. _inputPostProcess: Nullable<PostProcess>;
  34806. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34807. }
  34808. }
  34809. declare module BABYLON {
  34810. /**
  34811. * Applies a kernel filter to the image
  34812. */
  34813. class FilterPostProcess extends PostProcess {
  34814. /** The matrix to be applied to the image */
  34815. kernelMatrix: Matrix;
  34816. /**
  34817. *
  34818. * @param name The name of the effect.
  34819. * @param kernelMatrix The matrix to be applied to the image
  34820. * @param options The required width/height ratio to downsize to before computing the render pass.
  34821. * @param camera The camera to apply the render pass to.
  34822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34823. * @param engine The engine which the post process will be applied. (default: current engine)
  34824. * @param reusable If the post process can be reused on the same frame. (default: false)
  34825. */
  34826. constructor(name: string,
  34827. /** The matrix to be applied to the image */
  34828. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34829. }
  34830. }
  34831. declare module BABYLON {
  34832. /**
  34833. * Fxaa post process
  34834. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  34835. */
  34836. class FxaaPostProcess extends PostProcess {
  34837. /** @hidden */
  34838. texelWidth: number;
  34839. /** @hidden */
  34840. texelHeight: number;
  34841. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34842. private _getDefines;
  34843. }
  34844. }
  34845. declare module BABYLON {
  34846. /**
  34847. * The GrainPostProcess adds noise to the image at mid luminance levels
  34848. */
  34849. class GrainPostProcess extends PostProcess {
  34850. /**
  34851. * The intensity of the grain added (default: 30)
  34852. */
  34853. intensity: number;
  34854. /**
  34855. * If the grain should be randomized on every frame
  34856. */
  34857. animated: boolean;
  34858. /**
  34859. * Creates a new instance of @see GrainPostProcess
  34860. * @param name The name of the effect.
  34861. * @param options The required width/height ratio to downsize to before computing the render pass.
  34862. * @param camera The camera to apply the render pass to.
  34863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34864. * @param engine The engine which the post process will be applied. (default: current engine)
  34865. * @param reusable If the post process can be reused on the same frame. (default: false)
  34866. * @param textureType Type of textures used when performing the post process. (default: 0)
  34867. * @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)
  34868. */
  34869. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34870. }
  34871. }
  34872. declare module BABYLON {
  34873. /**
  34874. * Extracts highlights from the image
  34875. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34876. */
  34877. class HighlightsPostProcess extends PostProcess {
  34878. /**
  34879. * Extracts highlights from the image
  34880. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34881. * @param name The name of the effect.
  34882. * @param options The required width/height ratio to downsize to before computing the render pass.
  34883. * @param camera The camera to apply the render pass to.
  34884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34885. * @param engine The engine which the post process will be applied. (default: current engine)
  34886. * @param reusable If the post process can be reused on the same frame. (default: false)
  34887. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  34888. */
  34889. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34890. }
  34891. }
  34892. declare module BABYLON {
  34893. /**
  34894. * ImageProcessingPostProcess
  34895. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  34896. */
  34897. class ImageProcessingPostProcess extends PostProcess {
  34898. /**
  34899. * Default configuration related to image processing available in the PBR Material.
  34900. */
  34901. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34902. /**
  34903. * Gets the image processing configuration used either in this material.
  34904. */
  34905. /**
  34906. * Sets the Default image processing configuration used either in the this material.
  34907. *
  34908. * If sets to null, the scene one is in use.
  34909. */
  34910. imageProcessingConfiguration: ImageProcessingConfiguration;
  34911. /**
  34912. * Keep track of the image processing observer to allow dispose and replace.
  34913. */
  34914. private _imageProcessingObserver;
  34915. /**
  34916. * Attaches a new image processing configuration to the PBR Material.
  34917. * @param configuration
  34918. */
  34919. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  34920. /**
  34921. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34922. */
  34923. /**
  34924. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34925. */
  34926. colorCurves: Nullable<ColorCurves>;
  34927. /**
  34928. * Gets wether the color curves effect is enabled.
  34929. */
  34930. /**
  34931. * Sets wether the color curves effect is enabled.
  34932. */
  34933. colorCurvesEnabled: boolean;
  34934. /**
  34935. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34936. */
  34937. /**
  34938. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34939. */
  34940. colorGradingTexture: Nullable<BaseTexture>;
  34941. /**
  34942. * Gets wether the color grading effect is enabled.
  34943. */
  34944. /**
  34945. * Gets wether the color grading effect is enabled.
  34946. */
  34947. colorGradingEnabled: boolean;
  34948. /**
  34949. * Gets exposure used in the effect.
  34950. */
  34951. /**
  34952. * Sets exposure used in the effect.
  34953. */
  34954. exposure: number;
  34955. /**
  34956. * Gets wether tonemapping is enabled or not.
  34957. */
  34958. /**
  34959. * Sets wether tonemapping is enabled or not
  34960. */
  34961. toneMappingEnabled: boolean;
  34962. /**
  34963. * Gets contrast used in the effect.
  34964. */
  34965. /**
  34966. * Sets contrast used in the effect.
  34967. */
  34968. contrast: number;
  34969. /**
  34970. * Gets Vignette stretch size.
  34971. */
  34972. /**
  34973. * Sets Vignette stretch size.
  34974. */
  34975. vignetteStretch: number;
  34976. /**
  34977. * Gets Vignette centre X Offset.
  34978. */
  34979. /**
  34980. * Sets Vignette centre X Offset.
  34981. */
  34982. vignetteCentreX: number;
  34983. /**
  34984. * Gets Vignette centre Y Offset.
  34985. */
  34986. /**
  34987. * Sets Vignette centre Y Offset.
  34988. */
  34989. vignetteCentreY: number;
  34990. /**
  34991. * Gets Vignette weight or intensity of the vignette effect.
  34992. */
  34993. /**
  34994. * Sets Vignette weight or intensity of the vignette effect.
  34995. */
  34996. vignetteWeight: number;
  34997. /**
  34998. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34999. * if vignetteEnabled is set to true.
  35000. */
  35001. /**
  35002. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35003. * if vignetteEnabled is set to true.
  35004. */
  35005. vignetteColor: Color4;
  35006. /**
  35007. * Gets Camera field of view used by the Vignette effect.
  35008. */
  35009. /**
  35010. * Sets Camera field of view used by the Vignette effect.
  35011. */
  35012. vignetteCameraFov: number;
  35013. /**
  35014. * Gets the vignette blend mode allowing different kind of effect.
  35015. */
  35016. /**
  35017. * Sets the vignette blend mode allowing different kind of effect.
  35018. */
  35019. vignetteBlendMode: number;
  35020. /**
  35021. * Gets wether the vignette effect is enabled.
  35022. */
  35023. /**
  35024. * Sets wether the vignette effect is enabled.
  35025. */
  35026. vignetteEnabled: boolean;
  35027. private _fromLinearSpace;
  35028. /**
  35029. * Gets wether the input of the processing is in Gamma or Linear Space.
  35030. */
  35031. /**
  35032. * Sets wether the input of the processing is in Gamma or Linear Space.
  35033. */
  35034. fromLinearSpace: boolean;
  35035. /**
  35036. * Defines cache preventing GC.
  35037. */
  35038. private _defines;
  35039. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  35040. /**
  35041. * "ImageProcessingPostProcess"
  35042. * @returns "ImageProcessingPostProcess"
  35043. */
  35044. getClassName(): string;
  35045. protected _updateParameters(): void;
  35046. dispose(camera?: Camera): void;
  35047. }
  35048. }
  35049. declare module BABYLON {
  35050. /**
  35051. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  35052. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  35053. * As an example, all you have to do is to create the post-process:
  35054. * var mb = new BABYLON.MotionBlurPostProcess(
  35055. * 'mb', // The name of the effect.
  35056. * scene, // The scene containing the objects to blur according to their velocity.
  35057. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  35058. * camera // The camera to apply the render pass to.
  35059. * );
  35060. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  35061. */
  35062. class MotionBlurPostProcess extends PostProcess {
  35063. /**
  35064. * Defines how much the image is blurred by the movement. Default value is equal to 1
  35065. */
  35066. motionStrength: number;
  35067. /**
  35068. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  35069. */
  35070. /**
  35071. * Sets the number of iterations to be used for motion blur quality
  35072. */
  35073. motionBlurSamples: number;
  35074. private _motionBlurSamples;
  35075. private _geometryBufferRenderer;
  35076. /**
  35077. * Creates a new instance MotionBlurPostProcess
  35078. * @param name The name of the effect.
  35079. * @param scene The scene containing the objects to blur according to their velocity.
  35080. * @param options The required width/height ratio to downsize to before computing the render pass.
  35081. * @param camera The camera to apply the render pass to.
  35082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35083. * @param engine The engine which the post process will be applied. (default: current engine)
  35084. * @param reusable If the post process can be reused on the same frame. (default: false)
  35085. * @param textureType Type of textures used when performing the post process. (default: 0)
  35086. * @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)
  35087. */
  35088. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35089. /**
  35090. * Disposes the post process.
  35091. * @param camera The camera to dispose the post process on.
  35092. */
  35093. dispose(camera?: Camera): void;
  35094. }
  35095. }
  35096. declare module BABYLON {
  35097. /**
  35098. * PassPostProcess which produces an output the same as it's input
  35099. */
  35100. class PassPostProcess extends PostProcess {
  35101. /**
  35102. * Creates the PassPostProcess
  35103. * @param name The name of the effect.
  35104. * @param options The required width/height ratio to downsize to before computing the render pass.
  35105. * @param camera The camera to apply the render pass to.
  35106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35107. * @param engine The engine which the post process will be applied. (default: current engine)
  35108. * @param reusable If the post process can be reused on the same frame. (default: false)
  35109. * @param textureType The type of texture to be used when performing the post processing.
  35110. * @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)
  35111. */
  35112. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35113. }
  35114. /**
  35115. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  35116. */
  35117. class PassCubePostProcess extends PostProcess {
  35118. private _face;
  35119. /**
  35120. * Gets or sets the cube face to display.
  35121. * * 0 is +X
  35122. * * 1 is -X
  35123. * * 2 is +Y
  35124. * * 3 is -Y
  35125. * * 4 is +Z
  35126. * * 5 is -Z
  35127. */
  35128. face: number;
  35129. /**
  35130. * Creates the PassCubePostProcess
  35131. * @param name The name of the effect.
  35132. * @param options The required width/height ratio to downsize to before computing the render pass.
  35133. * @param camera The camera to apply the render pass to.
  35134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35135. * @param engine The engine which the post process will be applied. (default: current engine)
  35136. * @param reusable If the post process can be reused on the same frame. (default: false)
  35137. * @param textureType The type of texture to be used when performing the post processing.
  35138. * @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)
  35139. */
  35140. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35141. }
  35142. }
  35143. declare module BABYLON {
  35144. /**
  35145. * Size options for a post process
  35146. */
  35147. type PostProcessOptions = {
  35148. width: number;
  35149. height: number;
  35150. };
  35151. /**
  35152. * PostProcess can be used to apply a shader to a texture after it has been rendered
  35153. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35154. */
  35155. class PostProcess {
  35156. /** Name of the PostProcess. */
  35157. name: string;
  35158. /**
  35159. * Width of the texture to apply the post process on
  35160. */
  35161. width: number;
  35162. /**
  35163. * Height of the texture to apply the post process on
  35164. */
  35165. height: number;
  35166. /**
  35167. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  35168. * @hidden
  35169. */
  35170. _outputTexture: Nullable<InternalTexture>;
  35171. /**
  35172. * Sampling mode used by the shader
  35173. * See https://doc.babylonjs.com/classes/3.1/texture
  35174. */
  35175. renderTargetSamplingMode: number;
  35176. /**
  35177. * Clear color to use when screen clearing
  35178. */
  35179. clearColor: Color4;
  35180. /**
  35181. * If the buffer needs to be cleared before applying the post process. (default: true)
  35182. * Should be set to false if shader will overwrite all previous pixels.
  35183. */
  35184. autoClear: boolean;
  35185. /**
  35186. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  35187. */
  35188. alphaMode: number;
  35189. /**
  35190. * Sets the setAlphaBlendConstants of the babylon engine
  35191. */
  35192. alphaConstants: Color4;
  35193. /**
  35194. * Animations to be used for the post processing
  35195. */
  35196. animations: Animation[];
  35197. /**
  35198. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  35199. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  35200. */
  35201. enablePixelPerfectMode: boolean;
  35202. /**
  35203. * Force the postprocess to be applied without taking in account viewport
  35204. */
  35205. forceFullscreenViewport: boolean;
  35206. /**
  35207. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  35208. *
  35209. * | Value | Type | Description |
  35210. * | ----- | ----------------------------------- | ----------- |
  35211. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  35212. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  35213. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  35214. *
  35215. */
  35216. scaleMode: number;
  35217. /**
  35218. * Force textures to be a power of two (default: false)
  35219. */
  35220. alwaysForcePOT: boolean;
  35221. private _samples;
  35222. /**
  35223. * Number of sample textures (default: 1)
  35224. */
  35225. samples: number;
  35226. /**
  35227. * Modify the scale of the post process to be the same as the viewport (default: false)
  35228. */
  35229. adaptScaleToCurrentViewport: boolean;
  35230. private _camera;
  35231. private _scene;
  35232. private _engine;
  35233. private _options;
  35234. private _reusable;
  35235. private _textureType;
  35236. /**
  35237. * Smart array of input and output textures for the post process.
  35238. * @hidden
  35239. */
  35240. _textures: SmartArray<InternalTexture>;
  35241. /**
  35242. * The index in _textures that corresponds to the output texture.
  35243. * @hidden
  35244. */
  35245. _currentRenderTextureInd: number;
  35246. private _effect;
  35247. private _samplers;
  35248. private _fragmentUrl;
  35249. private _vertexUrl;
  35250. private _parameters;
  35251. private _scaleRatio;
  35252. protected _indexParameters: any;
  35253. private _shareOutputWithPostProcess;
  35254. private _texelSize;
  35255. private _forcedOutputTexture;
  35256. /**
  35257. * An event triggered when the postprocess is activated.
  35258. */
  35259. onActivateObservable: Observable<Camera>;
  35260. private _onActivateObserver;
  35261. /**
  35262. * A function that is added to the onActivateObservable
  35263. */
  35264. onActivate: Nullable<(camera: Camera) => void>;
  35265. /**
  35266. * An event triggered when the postprocess changes its size.
  35267. */
  35268. onSizeChangedObservable: Observable<PostProcess>;
  35269. private _onSizeChangedObserver;
  35270. /**
  35271. * A function that is added to the onSizeChangedObservable
  35272. */
  35273. onSizeChanged: (postProcess: PostProcess) => void;
  35274. /**
  35275. * An event triggered when the postprocess applies its effect.
  35276. */
  35277. onApplyObservable: Observable<Effect>;
  35278. private _onApplyObserver;
  35279. /**
  35280. * A function that is added to the onApplyObservable
  35281. */
  35282. onApply: (effect: Effect) => void;
  35283. /**
  35284. * An event triggered before rendering the postprocess
  35285. */
  35286. onBeforeRenderObservable: Observable<Effect>;
  35287. private _onBeforeRenderObserver;
  35288. /**
  35289. * A function that is added to the onBeforeRenderObservable
  35290. */
  35291. onBeforeRender: (effect: Effect) => void;
  35292. /**
  35293. * An event triggered after rendering the postprocess
  35294. */
  35295. onAfterRenderObservable: Observable<Effect>;
  35296. private _onAfterRenderObserver;
  35297. /**
  35298. * A function that is added to the onAfterRenderObservable
  35299. */
  35300. onAfterRender: (efect: Effect) => void;
  35301. /**
  35302. * 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
  35303. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35304. */
  35305. inputTexture: InternalTexture;
  35306. /**
  35307. * Gets the camera which post process is applied to.
  35308. * @returns The camera the post process is applied to.
  35309. */
  35310. getCamera(): Camera;
  35311. /**
  35312. * Gets the texel size of the postprocess.
  35313. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35314. */
  35315. readonly texelSize: Vector2;
  35316. /**
  35317. * Creates a new instance PostProcess
  35318. * @param name The name of the PostProcess.
  35319. * @param fragmentUrl The url of the fragment shader to be used.
  35320. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35321. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35322. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35323. * @param camera The camera to apply the render pass to.
  35324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35325. * @param engine The engine which the post process will be applied. (default: current engine)
  35326. * @param reusable If the post process can be reused on the same frame. (default: false)
  35327. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35328. * @param textureType Type of textures used when performing the post process. (default: 0)
  35329. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35330. * @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
  35331. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35332. */
  35333. constructor(
  35334. /** Name of the PostProcess. */
  35335. 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);
  35336. /**
  35337. * Gets the engine which this post process belongs to.
  35338. * @returns The engine the post process was enabled with.
  35339. */
  35340. getEngine(): Engine;
  35341. /**
  35342. * The effect that is created when initializing the post process.
  35343. * @returns The created effect corrisponding the the postprocess.
  35344. */
  35345. getEffect(): Effect;
  35346. /**
  35347. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35348. * @param postProcess The post process to share the output with.
  35349. * @returns This post process.
  35350. */
  35351. shareOutputWith(postProcess: PostProcess): PostProcess;
  35352. /**
  35353. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35354. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35355. */
  35356. useOwnOutput(): void;
  35357. /**
  35358. * Updates the effect with the current post process compile time values and recompiles the shader.
  35359. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35360. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35361. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35362. * @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
  35363. * @param onCompiled Called when the shader has been compiled.
  35364. * @param onError Called if there is an error when compiling a shader.
  35365. */
  35366. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35367. /**
  35368. * The post process is reusable if it can be used multiple times within one frame.
  35369. * @returns If the post process is reusable
  35370. */
  35371. isReusable(): boolean;
  35372. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35373. markTextureDirty(): void;
  35374. /**
  35375. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35376. * 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.
  35377. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35378. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35379. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35380. * @returns The target texture that was bound to be written to.
  35381. */
  35382. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35383. /**
  35384. * If the post process is supported.
  35385. */
  35386. readonly isSupported: boolean;
  35387. /**
  35388. * The aspect ratio of the output texture.
  35389. */
  35390. readonly aspectRatio: number;
  35391. /**
  35392. * Get a value indicating if the post-process is ready to be used
  35393. * @returns true if the post-process is ready (shader is compiled)
  35394. */
  35395. isReady(): boolean;
  35396. /**
  35397. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35398. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35399. */
  35400. apply(): Nullable<Effect>;
  35401. private _disposeTextures;
  35402. /**
  35403. * Disposes the post process.
  35404. * @param camera The camera to dispose the post process on.
  35405. */
  35406. dispose(camera?: Camera): void;
  35407. }
  35408. }
  35409. declare module BABYLON {
  35410. /**
  35411. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35412. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35413. */
  35414. class PostProcessManager {
  35415. private _scene;
  35416. private _indexBuffer;
  35417. private _vertexBuffers;
  35418. /**
  35419. * Creates a new instance PostProcess
  35420. * @param scene The scene that the post process is associated with.
  35421. */
  35422. constructor(scene: Scene);
  35423. private _prepareBuffers;
  35424. private _buildIndexBuffer;
  35425. /**
  35426. * Rebuilds the vertex buffers of the manager.
  35427. * @hidden
  35428. */
  35429. _rebuild(): void;
  35430. /**
  35431. * Prepares a frame to be run through a post process.
  35432. * @param sourceTexture The input texture to the post procesess. (default: null)
  35433. * @param postProcesses An array of post processes to be run. (default: null)
  35434. * @returns True if the post processes were able to be run.
  35435. * @hidden
  35436. */
  35437. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35438. /**
  35439. * Manually render a set of post processes to a texture.
  35440. * @param postProcesses An array of post processes to be run.
  35441. * @param targetTexture The target texture to render to.
  35442. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35443. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35444. * @param lodLevel defines which lod of the texture to render to
  35445. */
  35446. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35447. /**
  35448. * Finalize the result of the output of the postprocesses.
  35449. * @param doNotPresent If true the result will not be displayed to the screen.
  35450. * @param targetTexture The target texture to render to.
  35451. * @param faceIndex The index of the face to bind the target texture to.
  35452. * @param postProcesses The array of post processes to render.
  35453. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35454. * @hidden
  35455. */
  35456. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35457. /**
  35458. * Disposes of the post process manager.
  35459. */
  35460. dispose(): void;
  35461. }
  35462. }
  35463. declare module BABYLON {
  35464. /**
  35465. * Post process which applies a refractin texture
  35466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35467. */
  35468. class RefractionPostProcess extends PostProcess {
  35469. /** the base color of the refraction (used to taint the rendering) */
  35470. color: Color3;
  35471. /** simulated refraction depth */
  35472. depth: number;
  35473. /** the coefficient of the base color (0 to remove base color tainting) */
  35474. colorLevel: number;
  35475. private _refTexture;
  35476. private _ownRefractionTexture;
  35477. /**
  35478. * Gets or sets the refraction texture
  35479. * Please note that you are responsible for disposing the texture if you set it manually
  35480. */
  35481. refractionTexture: Texture;
  35482. /**
  35483. * Initializes the RefractionPostProcess
  35484. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35485. * @param name The name of the effect.
  35486. * @param refractionTextureUrl Url of the refraction texture to use
  35487. * @param color the base color of the refraction (used to taint the rendering)
  35488. * @param depth simulated refraction depth
  35489. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35490. * @param camera The camera to apply the render pass to.
  35491. * @param options The required width/height ratio to downsize to before computing the render pass.
  35492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35493. * @param engine The engine which the post process will be applied. (default: current engine)
  35494. * @param reusable If the post process can be reused on the same frame. (default: false)
  35495. */
  35496. constructor(name: string, refractionTextureUrl: string,
  35497. /** the base color of the refraction (used to taint the rendering) */
  35498. color: Color3,
  35499. /** simulated refraction depth */
  35500. depth: number,
  35501. /** the coefficient of the base color (0 to remove base color tainting) */
  35502. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35503. /**
  35504. * Disposes of the post process
  35505. * @param camera Camera to dispose post process on
  35506. */
  35507. dispose(camera: Camera): void;
  35508. }
  35509. }
  35510. declare module BABYLON {
  35511. /**
  35512. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35513. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35514. */
  35515. class SharpenPostProcess extends PostProcess {
  35516. /**
  35517. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35518. */
  35519. colorAmount: number;
  35520. /**
  35521. * How much sharpness should be applied (default: 0.3)
  35522. */
  35523. edgeAmount: number;
  35524. /**
  35525. * Creates a new instance ConvolutionPostProcess
  35526. * @param name The name of the effect.
  35527. * @param options The required width/height ratio to downsize to before computing the render pass.
  35528. * @param camera The camera to apply the render pass to.
  35529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35530. * @param engine The engine which the post process will be applied. (default: current engine)
  35531. * @param reusable If the post process can be reused on the same frame. (default: false)
  35532. * @param textureType Type of textures used when performing the post process. (default: 0)
  35533. * @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)
  35534. */
  35535. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35536. }
  35537. }
  35538. declare module BABYLON {
  35539. /**
  35540. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35541. */
  35542. class StereoscopicInterlacePostProcess extends PostProcess {
  35543. private _stepSize;
  35544. private _passedProcess;
  35545. /**
  35546. * Initializes a StereoscopicInterlacePostProcess
  35547. * @param name The name of the effect.
  35548. * @param rigCameras The rig cameras to be appled to the post process
  35549. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35551. * @param engine The engine which the post process will be applied. (default: current engine)
  35552. * @param reusable If the post process can be reused on the same frame. (default: false)
  35553. */
  35554. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35555. }
  35556. }
  35557. declare module BABYLON {
  35558. /** Defines operator used for tonemapping */
  35559. enum TonemappingOperator {
  35560. /** Hable */
  35561. Hable = 0,
  35562. /** Reinhard */
  35563. Reinhard = 1,
  35564. /** HejiDawson */
  35565. HejiDawson = 2,
  35566. /** Photographic */
  35567. Photographic = 3
  35568. }
  35569. /**
  35570. * Defines a post process to apply tone mapping
  35571. */
  35572. class TonemapPostProcess extends PostProcess {
  35573. private _operator;
  35574. /** Defines the required exposure adjustement */
  35575. exposureAdjustment: number;
  35576. /**
  35577. * Creates a new TonemapPostProcess
  35578. * @param name defines the name of the postprocess
  35579. * @param _operator defines the operator to use
  35580. * @param exposureAdjustment defines the required exposure adjustement
  35581. * @param camera defines the camera to use (can be null)
  35582. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35583. * @param engine defines the hosting engine (can be ignore if camera is set)
  35584. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35585. */
  35586. constructor(name: string, _operator: TonemappingOperator,
  35587. /** Defines the required exposure adjustement */
  35588. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35589. }
  35590. }
  35591. declare module BABYLON {
  35592. /**
  35593. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35594. */
  35595. class VolumetricLightScatteringPostProcess extends PostProcess {
  35596. private _volumetricLightScatteringPass;
  35597. private _volumetricLightScatteringRTT;
  35598. private _viewPort;
  35599. private _screenCoordinates;
  35600. private _cachedDefines;
  35601. /**
  35602. * If not undefined, the mesh position is computed from the attached node position
  35603. */
  35604. attachedNode: {
  35605. position: Vector3;
  35606. };
  35607. /**
  35608. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35609. */
  35610. customMeshPosition: Vector3;
  35611. /**
  35612. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35613. */
  35614. useCustomMeshPosition: boolean;
  35615. /**
  35616. * If the post-process should inverse the light scattering direction
  35617. */
  35618. invert: boolean;
  35619. /**
  35620. * The internal mesh used by the post-process
  35621. */
  35622. mesh: Mesh;
  35623. /**
  35624. * @hidden
  35625. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35626. */
  35627. useDiffuseColor: boolean;
  35628. /**
  35629. * Array containing the excluded meshes not rendered in the internal pass
  35630. */
  35631. excludedMeshes: AbstractMesh[];
  35632. /**
  35633. * Controls the overall intensity of the post-process
  35634. */
  35635. exposure: number;
  35636. /**
  35637. * Dissipates each sample's contribution in range [0, 1]
  35638. */
  35639. decay: number;
  35640. /**
  35641. * Controls the overall intensity of each sample
  35642. */
  35643. weight: number;
  35644. /**
  35645. * Controls the density of each sample
  35646. */
  35647. density: number;
  35648. /**
  35649. * @constructor
  35650. * @param name The post-process name
  35651. * @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)
  35652. * @param camera The camera that the post-process will be attached to
  35653. * @param mesh The mesh used to create the light scattering
  35654. * @param samples The post-process quality, default 100
  35655. * @param samplingModeThe post-process filtering mode
  35656. * @param engine The babylon engine
  35657. * @param reusable If the post-process is reusable
  35658. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35659. */
  35660. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35661. /**
  35662. * Returns the string "VolumetricLightScatteringPostProcess"
  35663. * @returns "VolumetricLightScatteringPostProcess"
  35664. */
  35665. getClassName(): string;
  35666. private _isReady;
  35667. /**
  35668. * Sets the new light position for light scattering effect
  35669. * @param position The new custom light position
  35670. */
  35671. setCustomMeshPosition(position: Vector3): void;
  35672. /**
  35673. * Returns the light position for light scattering effect
  35674. * @return Vector3 The custom light position
  35675. */
  35676. getCustomMeshPosition(): Vector3;
  35677. /**
  35678. * Disposes the internal assets and detaches the post-process from the camera
  35679. */
  35680. dispose(camera: Camera): void;
  35681. /**
  35682. * Returns the render target texture used by the post-process
  35683. * @return the render target texture used by the post-process
  35684. */
  35685. getPass(): RenderTargetTexture;
  35686. private _meshExcluded;
  35687. private _createPass;
  35688. private _updateMeshScreenCoordinates;
  35689. /**
  35690. * Creates a default mesh for the Volumeric Light Scattering post-process
  35691. * @param name The mesh name
  35692. * @param scene The scene where to create the mesh
  35693. * @return the default mesh
  35694. */
  35695. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35696. }
  35697. }
  35698. declare module BABYLON {
  35699. /**
  35700. * VRDistortionCorrectionPostProcess used for mobile VR
  35701. */
  35702. class VRDistortionCorrectionPostProcess extends PostProcess {
  35703. private _isRightEye;
  35704. private _distortionFactors;
  35705. private _postProcessScaleFactor;
  35706. private _lensCenterOffset;
  35707. private _scaleIn;
  35708. private _scaleFactor;
  35709. private _lensCenter;
  35710. /**
  35711. * Initializes the VRDistortionCorrectionPostProcess
  35712. * @param name The name of the effect.
  35713. * @param camera The camera to apply the render pass to.
  35714. * @param isRightEye If this is for the right eye distortion
  35715. * @param vrMetrics All the required metrics for the VR camera
  35716. */
  35717. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35718. }
  35719. }
  35720. declare module BABYLON {
  35721. interface Scene {
  35722. /** @hidden (Backing field) */
  35723. _boundingBoxRenderer: BoundingBoxRenderer;
  35724. /** @hidden (Backing field) */
  35725. _forceShowBoundingBoxes: boolean;
  35726. /**
  35727. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  35728. */
  35729. forceShowBoundingBoxes: boolean;
  35730. /**
  35731. * Gets the bounding box renderer associated with the scene
  35732. * @returns a BoundingBoxRenderer
  35733. */
  35734. getBoundingBoxRenderer(): BoundingBoxRenderer;
  35735. }
  35736. interface AbstractMesh {
  35737. /** @hidden (Backing field) */
  35738. _showBoundingBox: boolean;
  35739. /**
  35740. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  35741. */
  35742. showBoundingBox: boolean;
  35743. }
  35744. /**
  35745. * Component responsible of rendering the bounding box of the meshes in a scene.
  35746. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  35747. */
  35748. class BoundingBoxRenderer implements ISceneComponent {
  35749. /**
  35750. * The component name helpfull to identify the component in the list of scene components.
  35751. */
  35752. readonly name: string;
  35753. /**
  35754. * The scene the component belongs to.
  35755. */
  35756. scene: Scene;
  35757. /**
  35758. * Color of the bounding box lines placed in front of an object
  35759. */
  35760. frontColor: Color3;
  35761. /**
  35762. * Color of the bounding box lines placed behind an object
  35763. */
  35764. backColor: Color3;
  35765. /**
  35766. * Defines if the renderer should show the back lines or not
  35767. */
  35768. showBackLines: boolean;
  35769. /**
  35770. * @hidden
  35771. */
  35772. renderList: SmartArray<BoundingBox>;
  35773. private _colorShader;
  35774. private _vertexBuffers;
  35775. private _indexBuffer;
  35776. /**
  35777. * Instantiates a new bounding box renderer in a scene.
  35778. * @param scene the scene the renderer renders in
  35779. */
  35780. constructor(scene: Scene);
  35781. /**
  35782. * Registers the component in a given scene
  35783. */
  35784. register(): void;
  35785. private _evaluateSubMesh;
  35786. private _activeMesh;
  35787. private _prepareRessources;
  35788. private _createIndexBuffer;
  35789. /**
  35790. * Rebuilds the elements related to this component in case of
  35791. * context lost for instance.
  35792. */
  35793. rebuild(): void;
  35794. /**
  35795. * @hidden
  35796. */
  35797. reset(): void;
  35798. /**
  35799. * Render the bounding boxes of a specific rendering group
  35800. * @param renderingGroupId defines the rendering group to render
  35801. */
  35802. render(renderingGroupId: number): void;
  35803. /**
  35804. * In case of occlusion queries, we can render the occlusion bounding box through this method
  35805. * @param mesh Define the mesh to render the occlusion bounding box for
  35806. */
  35807. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  35808. /**
  35809. * Dispose and release the resources attached to this renderer.
  35810. */
  35811. dispose(): void;
  35812. }
  35813. }
  35814. declare module BABYLON {
  35815. /**
  35816. * This represents a depth renderer in Babylon.
  35817. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  35818. */
  35819. class DepthRenderer {
  35820. private _scene;
  35821. private _depthMap;
  35822. private _effect;
  35823. private _cachedDefines;
  35824. private _camera;
  35825. /**
  35826. * Specifiess that the depth renderer will only be used within
  35827. * the camera it is created for.
  35828. * This can help forcing its rendering during the camera processing.
  35829. */
  35830. useOnlyInActiveCamera: boolean;
  35831. /**
  35832. * Instantiates a depth renderer
  35833. * @param scene The scene the renderer belongs to
  35834. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  35835. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  35836. */
  35837. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  35838. /**
  35839. * Creates the depth rendering effect and checks if the effect is ready.
  35840. * @param subMesh The submesh to be used to render the depth map of
  35841. * @param useInstances If multiple world instances should be used
  35842. * @returns if the depth renderer is ready to render the depth map
  35843. */
  35844. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35845. /**
  35846. * Gets the texture which the depth map will be written to.
  35847. * @returns The depth map texture
  35848. */
  35849. getDepthMap(): RenderTargetTexture;
  35850. /**
  35851. * Disposes of the depth renderer.
  35852. */
  35853. dispose(): void;
  35854. }
  35855. }
  35856. declare module BABYLON {
  35857. interface Scene {
  35858. /** @hidden (Backing field) */
  35859. _depthRenderer: {
  35860. [id: string]: DepthRenderer;
  35861. };
  35862. /**
  35863. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  35864. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  35865. * @returns the created depth renderer
  35866. */
  35867. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  35868. /**
  35869. * Disables a depth renderer for a given camera
  35870. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  35871. */
  35872. disableDepthRenderer(camera?: Nullable<Camera>): void;
  35873. }
  35874. /**
  35875. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  35876. * in several rendering techniques.
  35877. */
  35878. class DepthRendererSceneComponent implements ISceneComponent {
  35879. /**
  35880. * The component name helpfull to identify the component in the list of scene components.
  35881. */
  35882. readonly name: string;
  35883. /**
  35884. * The scene the component belongs to.
  35885. */
  35886. scene: Scene;
  35887. /**
  35888. * Creates a new instance of the component for the given scene
  35889. * @param scene Defines the scene to register the component in
  35890. */
  35891. constructor(scene: Scene);
  35892. /**
  35893. * Registers the component in a given scene
  35894. */
  35895. register(): void;
  35896. /**
  35897. * Rebuilds the elements related to this component in case of
  35898. * context lost for instance.
  35899. */
  35900. rebuild(): void;
  35901. /**
  35902. * Disposes the component and the associated ressources
  35903. */
  35904. dispose(): void;
  35905. private _gatherRenderTargets;
  35906. private _gatherActiveCameraRenderTargets;
  35907. }
  35908. }
  35909. declare module BABYLON {
  35910. interface AbstractMesh {
  35911. /**
  35912. * Disables the mesh edge rendering mode
  35913. * @returns the currentAbstractMesh
  35914. */
  35915. disableEdgesRendering(): AbstractMesh;
  35916. /**
  35917. * Enables the edge rendering mode on the mesh.
  35918. * This mode makes the mesh edges visible
  35919. * @param epsilon defines the maximal distance between two angles to detect a face
  35920. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35921. * @returns the currentAbstractMesh
  35922. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35923. */
  35924. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35925. /**
  35926. * Gets the edgesRenderer associated with the mesh
  35927. */
  35928. edgesRenderer: Nullable<EdgesRenderer>;
  35929. }
  35930. interface LinesMesh {
  35931. /**
  35932. * Enables the edge rendering mode on the mesh.
  35933. * This mode makes the mesh edges visible
  35934. * @param epsilon defines the maximal distance between two angles to detect a face
  35935. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35936. * @returns the currentAbstractMesh
  35937. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35938. */
  35939. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35940. }
  35941. interface InstancedLinesMesh {
  35942. /**
  35943. * Enables the edge rendering mode on the mesh.
  35944. * This mode makes the mesh edges visible
  35945. * @param epsilon defines the maximal distance between two angles to detect a face
  35946. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35947. * @returns the current InstancedLinesMesh
  35948. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35949. */
  35950. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  35951. }
  35952. /**
  35953. * Defines the minimum contract an Edges renderer should follow.
  35954. */
  35955. interface IEdgesRenderer extends IDisposable {
  35956. /**
  35957. * Gets or sets a boolean indicating if the edgesRenderer is active
  35958. */
  35959. isEnabled: boolean;
  35960. /**
  35961. * Renders the edges of the attached mesh,
  35962. */
  35963. render(): void;
  35964. /**
  35965. * Checks wether or not the edges renderer is ready to render.
  35966. * @return true if ready, otherwise false.
  35967. */
  35968. isReady(): boolean;
  35969. }
  35970. /**
  35971. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  35972. */
  35973. class EdgesRenderer implements IEdgesRenderer {
  35974. /**
  35975. * Define the size of the edges with an orthographic camera
  35976. */
  35977. edgesWidthScalerForOrthographic: number;
  35978. /**
  35979. * Define the size of the edges with a perspective camera
  35980. */
  35981. edgesWidthScalerForPerspective: number;
  35982. protected _source: AbstractMesh;
  35983. protected _linesPositions: number[];
  35984. protected _linesNormals: number[];
  35985. protected _linesIndices: number[];
  35986. protected _epsilon: number;
  35987. protected _indicesCount: number;
  35988. protected _lineShader: ShaderMaterial;
  35989. protected _ib: WebGLBuffer;
  35990. protected _buffers: {
  35991. [key: string]: Nullable<VertexBuffer>;
  35992. };
  35993. protected _checkVerticesInsteadOfIndices: boolean;
  35994. private _meshRebuildObserver;
  35995. private _meshDisposeObserver;
  35996. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  35997. isEnabled: boolean;
  35998. /**
  35999. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  36000. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  36001. * @param source Mesh used to create edges
  36002. * @param epsilon sum of angles in adjacency to check for edge
  36003. * @param checkVerticesInsteadOfIndices
  36004. * @param generateEdgesLines - should generate Lines or only prepare resources.
  36005. */
  36006. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  36007. protected _prepareRessources(): void;
  36008. /** @hidden */
  36009. _rebuild(): void;
  36010. /**
  36011. * Releases the required resources for the edges renderer
  36012. */
  36013. dispose(): void;
  36014. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  36015. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  36016. /**
  36017. * Checks if the pair of p0 and p1 is en edge
  36018. * @param faceIndex
  36019. * @param edge
  36020. * @param faceNormals
  36021. * @param p0
  36022. * @param p1
  36023. * @private
  36024. */
  36025. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  36026. /**
  36027. * push line into the position, normal and index buffer
  36028. * @protected
  36029. */
  36030. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  36031. /**
  36032. * Generates lines edges from adjacencjes
  36033. * @private
  36034. */
  36035. _generateEdgesLines(): void;
  36036. /**
  36037. * Checks wether or not the edges renderer is ready to render.
  36038. * @return true if ready, otherwise false.
  36039. */
  36040. isReady(): boolean;
  36041. /**
  36042. * Renders the edges of the attached mesh,
  36043. */
  36044. render(): void;
  36045. }
  36046. }
  36047. declare module BABYLON {
  36048. /**
  36049. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  36050. */
  36051. class GeometryBufferRenderer {
  36052. /**
  36053. * Constant used to retrieve the position texture index in the G-Buffer textures array
  36054. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  36055. */
  36056. static readonly POSITION_TEXTURE_TYPE: number;
  36057. /**
  36058. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  36059. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  36060. */
  36061. static readonly VELOCITY_TEXTURE_TYPE: number;
  36062. /**
  36063. * Dictionary used to store the previous transformation matrices of each rendered mesh
  36064. * in order to compute objects velocities when enableVelocity is set to "true"
  36065. * @hidden
  36066. */
  36067. _previousTransformationMatrices: {
  36068. [index: number]: Matrix;
  36069. };
  36070. private _scene;
  36071. private _multiRenderTarget;
  36072. private _ratio;
  36073. private _enablePosition;
  36074. private _enableVelocity;
  36075. private _positionIndex;
  36076. private _velocityIndex;
  36077. protected _effect: Effect;
  36078. protected _cachedDefines: string;
  36079. /**
  36080. * Set the render list (meshes to be rendered) used in the G buffer.
  36081. */
  36082. renderList: Mesh[];
  36083. /**
  36084. * Gets wether or not G buffer are supported by the running hardware.
  36085. * This requires draw buffer supports
  36086. */
  36087. readonly isSupported: boolean;
  36088. /**
  36089. * Returns the index of the given texture type in the G-Buffer textures array
  36090. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  36091. * @returns the index of the given texture type in the G-Buffer textures array
  36092. */
  36093. getTextureIndex(textureType: number): number;
  36094. /**
  36095. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  36096. */
  36097. /**
  36098. * Sets whether or not objects positions are enabled for the G buffer.
  36099. */
  36100. enablePosition: boolean;
  36101. /**
  36102. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  36103. */
  36104. /**
  36105. * Sets wether or not objects velocities are enabled for the G buffer.
  36106. */
  36107. enableVelocity: boolean;
  36108. /**
  36109. * Gets the scene associated with the buffer.
  36110. */
  36111. readonly scene: Scene;
  36112. /**
  36113. * Gets the ratio used by the buffer during its creation.
  36114. * How big is the buffer related to the main canvas.
  36115. */
  36116. readonly ratio: number;
  36117. /**
  36118. * Creates a new G Buffer for the scene
  36119. * @param scene The scene the buffer belongs to
  36120. * @param ratio How big is the buffer related to the main canvas.
  36121. */
  36122. constructor(scene: Scene, ratio?: number);
  36123. /**
  36124. * Checks wether everything is ready to render a submesh to the G buffer.
  36125. * @param subMesh the submesh to check readiness for
  36126. * @param useInstances is the mesh drawn using instance or not
  36127. * @returns true if ready otherwise false
  36128. */
  36129. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36130. /**
  36131. * Gets the current underlying G Buffer.
  36132. * @returns the buffer
  36133. */
  36134. getGBuffer(): MultiRenderTarget;
  36135. /**
  36136. * Gets the number of samples used to render the buffer (anti aliasing).
  36137. */
  36138. /**
  36139. * Sets the number of samples used to render the buffer (anti aliasing).
  36140. */
  36141. samples: number;
  36142. /**
  36143. * Disposes the renderer and frees up associated resources.
  36144. */
  36145. dispose(): void;
  36146. protected _createRenderTargets(): void;
  36147. }
  36148. }
  36149. declare module BABYLON {
  36150. interface Scene {
  36151. /** @hidden (Backing field) */
  36152. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36153. /**
  36154. * Gets or Sets the current geometry buffer associated to the scene.
  36155. */
  36156. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36157. /**
  36158. * Enables a GeometryBufferRender and associates it with the scene
  36159. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  36160. * @returns the GeometryBufferRenderer
  36161. */
  36162. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  36163. /**
  36164. * Disables the GeometryBufferRender associated with the scene
  36165. */
  36166. disableGeometryBufferRenderer(): void;
  36167. }
  36168. /**
  36169. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  36170. * in several rendering techniques.
  36171. */
  36172. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  36173. /**
  36174. * The component name helpful to identify the component in the list of scene components.
  36175. */
  36176. readonly name: string;
  36177. /**
  36178. * The scene the component belongs to.
  36179. */
  36180. scene: Scene;
  36181. /**
  36182. * Creates a new instance of the component for the given scene
  36183. * @param scene Defines the scene to register the component in
  36184. */
  36185. constructor(scene: Scene);
  36186. /**
  36187. * Registers the component in a given scene
  36188. */
  36189. register(): void;
  36190. /**
  36191. * Rebuilds the elements related to this component in case of
  36192. * context lost for instance.
  36193. */
  36194. rebuild(): void;
  36195. /**
  36196. * Disposes the component and the associated ressources
  36197. */
  36198. dispose(): void;
  36199. private _gatherRenderTargets;
  36200. }
  36201. }
  36202. declare module BABYLON {
  36203. /**
  36204. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  36205. */
  36206. class LineEdgesRenderer extends EdgesRenderer {
  36207. /**
  36208. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  36209. * @param source LineMesh used to generate edges
  36210. * @param epsilon not important (specified angle for edge detection)
  36211. * @param checkVerticesInsteadOfIndices not important for LineMesh
  36212. */
  36213. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  36214. /**
  36215. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  36216. */
  36217. _generateEdgesLines(): void;
  36218. }
  36219. }
  36220. declare module BABYLON {
  36221. interface Scene {
  36222. /** @hidden */
  36223. _outlineRenderer: OutlineRenderer;
  36224. /**
  36225. * Gets the outline renderer associated with the scene
  36226. * @returns a OutlineRenderer
  36227. */
  36228. getOutlineRenderer(): OutlineRenderer;
  36229. }
  36230. interface AbstractMesh {
  36231. /** @hidden (Backing field) */
  36232. _renderOutline: boolean;
  36233. /**
  36234. * Gets or sets a boolean indicating if the outline must be rendered as well
  36235. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  36236. */
  36237. renderOutline: boolean;
  36238. /** @hidden (Backing field) */
  36239. _renderOverlay: boolean;
  36240. /**
  36241. * Gets or sets a boolean indicating if the overlay must be rendered as well
  36242. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  36243. */
  36244. renderOverlay: boolean;
  36245. }
  36246. /**
  36247. * This class is responsible to draw bothe outline/overlay of meshes.
  36248. * It should not be used directly but through the available method on mesh.
  36249. */
  36250. class OutlineRenderer implements ISceneComponent {
  36251. /**
  36252. * The name of the component. Each component must have a unique name.
  36253. */
  36254. name: string;
  36255. /**
  36256. * The scene the component belongs to.
  36257. */
  36258. scene: Scene;
  36259. /**
  36260. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  36261. */
  36262. zOffset: number;
  36263. private _engine;
  36264. private _effect;
  36265. private _cachedDefines;
  36266. private _savedDepthWrite;
  36267. /**
  36268. * Instantiates a new outline renderer. (There could be only one per scene).
  36269. * @param scene Defines the scene it belongs to
  36270. */
  36271. constructor(scene: Scene);
  36272. /**
  36273. * Register the component to one instance of a scene.
  36274. */
  36275. register(): void;
  36276. /**
  36277. * Rebuilds the elements related to this component in case of
  36278. * context lost for instance.
  36279. */
  36280. rebuild(): void;
  36281. /**
  36282. * Disposes the component and the associated ressources.
  36283. */
  36284. dispose(): void;
  36285. /**
  36286. * Renders the outline in the canvas.
  36287. * @param subMesh Defines the sumesh to render
  36288. * @param batch Defines the batch of meshes in case of instances
  36289. * @param useOverlay Defines if the rendering is for the overlay or the outline
  36290. */
  36291. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  36292. /**
  36293. * Returns whether or not the outline renderer is ready for a given submesh.
  36294. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  36295. * @param subMesh Defines the submesh to check readyness for
  36296. * @param useInstances Defines wheter wee are trying to render instances or not
  36297. * @returns true if ready otherwise false
  36298. */
  36299. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36300. private _beforeRenderingMesh;
  36301. private _afterRenderingMesh;
  36302. }
  36303. }
  36304. declare module BABYLON {
  36305. /**
  36306. * This represents the object necessary to create a rendering group.
  36307. * This is exclusively used and created by the rendering manager.
  36308. * To modify the behavior, you use the available helpers in your scene or meshes.
  36309. * @hidden
  36310. */
  36311. class RenderingGroup {
  36312. index: number;
  36313. private _scene;
  36314. private _opaqueSubMeshes;
  36315. private _transparentSubMeshes;
  36316. private _alphaTestSubMeshes;
  36317. private _depthOnlySubMeshes;
  36318. private _particleSystems;
  36319. private _spriteManagers;
  36320. private _opaqueSortCompareFn;
  36321. private _alphaTestSortCompareFn;
  36322. private _transparentSortCompareFn;
  36323. private _renderOpaque;
  36324. private _renderAlphaTest;
  36325. private _renderTransparent;
  36326. private _edgesRenderers;
  36327. onBeforeTransparentRendering: () => void;
  36328. /**
  36329. * Set the opaque sort comparison function.
  36330. * If null the sub meshes will be render in the order they were created
  36331. */
  36332. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36333. /**
  36334. * Set the alpha test sort comparison function.
  36335. * If null the sub meshes will be render in the order they were created
  36336. */
  36337. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36338. /**
  36339. * Set the transparent sort comparison function.
  36340. * If null the sub meshes will be render in the order they were created
  36341. */
  36342. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36343. /**
  36344. * Creates a new rendering group.
  36345. * @param index The rendering group index
  36346. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  36347. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  36348. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  36349. */
  36350. 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>);
  36351. /**
  36352. * Render all the sub meshes contained in the group.
  36353. * @param customRenderFunction Used to override the default render behaviour of the group.
  36354. * @returns true if rendered some submeshes.
  36355. */
  36356. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36357. /**
  36358. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36359. * @param subMeshes The submeshes to render
  36360. */
  36361. private renderOpaqueSorted;
  36362. /**
  36363. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36364. * @param subMeshes The submeshes to render
  36365. */
  36366. private renderAlphaTestSorted;
  36367. /**
  36368. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36369. * @param subMeshes The submeshes to render
  36370. */
  36371. private renderTransparentSorted;
  36372. /**
  36373. * Renders the submeshes in a specified order.
  36374. * @param subMeshes The submeshes to sort before render
  36375. * @param sortCompareFn The comparison function use to sort
  36376. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36377. * @param transparent Specifies to activate blending if true
  36378. */
  36379. private static renderSorted;
  36380. /**
  36381. * Renders the submeshes in the order they were dispatched (no sort applied).
  36382. * @param subMeshes The submeshes to render
  36383. */
  36384. private static renderUnsorted;
  36385. /**
  36386. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36387. * are rendered back to front if in the same alpha index.
  36388. *
  36389. * @param a The first submesh
  36390. * @param b The second submesh
  36391. * @returns The result of the comparison
  36392. */
  36393. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36394. /**
  36395. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36396. * are rendered back to front.
  36397. *
  36398. * @param a The first submesh
  36399. * @param b The second submesh
  36400. * @returns The result of the comparison
  36401. */
  36402. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36403. /**
  36404. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36405. * are rendered front to back (prevent overdraw).
  36406. *
  36407. * @param a The first submesh
  36408. * @param b The second submesh
  36409. * @returns The result of the comparison
  36410. */
  36411. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36412. /**
  36413. * Resets the different lists of submeshes to prepare a new frame.
  36414. */
  36415. prepare(): void;
  36416. dispose(): void;
  36417. /**
  36418. * Inserts the submesh in its correct queue depending on its material.
  36419. * @param subMesh The submesh to dispatch
  36420. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36421. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36422. */
  36423. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36424. dispatchSprites(spriteManager: ISpriteManager): void;
  36425. dispatchParticles(particleSystem: IParticleSystem): void;
  36426. private _renderParticles;
  36427. private _renderSprites;
  36428. }
  36429. }
  36430. declare module BABYLON {
  36431. /**
  36432. * Interface describing the different options available in the rendering manager
  36433. * regarding Auto Clear between groups.
  36434. */
  36435. interface IRenderingManagerAutoClearSetup {
  36436. /**
  36437. * Defines whether or not autoclear is enable.
  36438. */
  36439. autoClear: boolean;
  36440. /**
  36441. * Defines whether or not to autoclear the depth buffer.
  36442. */
  36443. depth: boolean;
  36444. /**
  36445. * Defines whether or not to autoclear the stencil buffer.
  36446. */
  36447. stencil: boolean;
  36448. }
  36449. /**
  36450. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36451. * It is enable to manage the different groups as well as the different necessary sort functions.
  36452. * This should not be used directly aside of the few static configurations
  36453. */
  36454. class RenderingManager {
  36455. /**
  36456. * The max id used for rendering groups (not included)
  36457. */
  36458. static MAX_RENDERINGGROUPS: number;
  36459. /**
  36460. * The min id used for rendering groups (included)
  36461. */
  36462. static MIN_RENDERINGGROUPS: number;
  36463. /**
  36464. * Used to globally prevent autoclearing scenes.
  36465. */
  36466. static AUTOCLEAR: boolean;
  36467. /**
  36468. * @hidden
  36469. */
  36470. _useSceneAutoClearSetup: boolean;
  36471. private _scene;
  36472. private _renderingGroups;
  36473. private _depthStencilBufferAlreadyCleaned;
  36474. private _autoClearDepthStencil;
  36475. private _customOpaqueSortCompareFn;
  36476. private _customAlphaTestSortCompareFn;
  36477. private _customTransparentSortCompareFn;
  36478. private _renderingGroupInfo;
  36479. /**
  36480. * Instantiates a new rendering group for a particular scene
  36481. * @param scene Defines the scene the groups belongs to
  36482. */
  36483. constructor(scene: Scene);
  36484. private _clearDepthStencilBuffer;
  36485. /**
  36486. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36487. * @hidden
  36488. */
  36489. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36490. /**
  36491. * Resets the different information of the group to prepare a new frame
  36492. * @hidden
  36493. */
  36494. reset(): void;
  36495. /**
  36496. * Dispose and release the group and its associated resources.
  36497. * @hidden
  36498. */
  36499. dispose(): void;
  36500. /**
  36501. * Clear the info related to rendering groups preventing retention points during dispose.
  36502. */
  36503. freeRenderingGroups(): void;
  36504. private _prepareRenderingGroup;
  36505. /**
  36506. * Add a sprite manager to the rendering manager in order to render it this frame.
  36507. * @param spriteManager Define the sprite manager to render
  36508. */
  36509. dispatchSprites(spriteManager: ISpriteManager): void;
  36510. /**
  36511. * Add a particle system to the rendering manager in order to render it this frame.
  36512. * @param particleSystem Define the particle system to render
  36513. */
  36514. dispatchParticles(particleSystem: IParticleSystem): void;
  36515. /**
  36516. * Add a submesh to the manager in order to render it this frame
  36517. * @param subMesh The submesh to dispatch
  36518. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36519. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36520. */
  36521. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36522. /**
  36523. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36524. * This allowed control for front to back rendering or reversly depending of the special needs.
  36525. *
  36526. * @param renderingGroupId The rendering group id corresponding to its index
  36527. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36528. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36529. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36530. */
  36531. 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;
  36532. /**
  36533. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36534. *
  36535. * @param renderingGroupId The rendering group id corresponding to its index
  36536. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36537. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36538. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36539. */
  36540. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36541. /**
  36542. * Gets the current auto clear configuration for one rendering group of the rendering
  36543. * manager.
  36544. * @param index the rendering group index to get the information for
  36545. * @returns The auto clear setup for the requested rendering group
  36546. */
  36547. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36548. }
  36549. }
  36550. declare module BABYLON {
  36551. /**
  36552. * Renders a layer on top of an existing scene
  36553. */
  36554. class UtilityLayerRenderer implements IDisposable {
  36555. /** the original scene that will be rendered on top of */
  36556. originalScene: Scene;
  36557. private _pointerCaptures;
  36558. private _lastPointerEvents;
  36559. private static _DefaultUtilityLayer;
  36560. private static _DefaultKeepDepthUtilityLayer;
  36561. /**
  36562. * 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)
  36563. */
  36564. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36565. /**
  36566. * 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)
  36567. */
  36568. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36569. /**
  36570. * The scene that is rendered on top of the original scene
  36571. */
  36572. utilityLayerScene: Scene;
  36573. /**
  36574. * If the utility layer should automatically be rendered on top of existing scene
  36575. */
  36576. shouldRender: boolean;
  36577. /**
  36578. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36579. */
  36580. onlyCheckPointerDownEvents: boolean;
  36581. /**
  36582. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36583. */
  36584. processAllEvents: boolean;
  36585. /**
  36586. * Observable raised when the pointer move from the utility layer scene to the main scene
  36587. */
  36588. onPointerOutObservable: Observable<number>;
  36589. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36590. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36591. private _afterRenderObserver;
  36592. private _sceneDisposeObserver;
  36593. private _originalPointerObserver;
  36594. /**
  36595. * Instantiates a UtilityLayerRenderer
  36596. * @param originalScene the original scene that will be rendered on top of
  36597. */
  36598. constructor(
  36599. /** the original scene that will be rendered on top of */
  36600. originalScene: Scene);
  36601. private _notifyObservers;
  36602. /**
  36603. * Renders the utility layers scene on top of the original scene
  36604. */
  36605. render(): void;
  36606. /**
  36607. * Disposes of the renderer
  36608. */
  36609. dispose(): void;
  36610. private _updateCamera;
  36611. }
  36612. }
  36613. declare module BABYLON {
  36614. /**
  36615. * Class used to represent a sprite
  36616. * @see http://doc.babylonjs.com/babylon101/sprites
  36617. */
  36618. class Sprite {
  36619. /** defines the name */
  36620. name: string;
  36621. /** Gets or sets the current world position */
  36622. position: Vector3;
  36623. /** Gets or sets the main color */
  36624. color: Color4;
  36625. /** Gets or sets the width */
  36626. width: number;
  36627. /** Gets or sets the height */
  36628. height: number;
  36629. /** Gets or sets rotation angle */
  36630. angle: number;
  36631. /** Gets or sets the cell index in the sprite sheet */
  36632. cellIndex: number;
  36633. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36634. invertU: number;
  36635. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36636. invertV: number;
  36637. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36638. disposeWhenFinishedAnimating: boolean;
  36639. /** Gets the list of attached animations */
  36640. animations: Animation[];
  36641. /** Gets or sets a boolean indicating if the sprite can be picked */
  36642. isPickable: boolean;
  36643. /**
  36644. * Gets or sets the associated action manager
  36645. */
  36646. actionManager: Nullable<ActionManager>;
  36647. private _animationStarted;
  36648. private _loopAnimation;
  36649. private _fromIndex;
  36650. private _toIndex;
  36651. private _delay;
  36652. private _direction;
  36653. private _manager;
  36654. private _time;
  36655. private _onAnimationEnd;
  36656. /**
  36657. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36658. */
  36659. isVisible: boolean;
  36660. /**
  36661. * Gets or sets the sprite size
  36662. */
  36663. size: number;
  36664. /**
  36665. * Creates a new Sprite
  36666. * @param name defines the name
  36667. * @param manager defines the manager
  36668. */
  36669. constructor(
  36670. /** defines the name */
  36671. name: string, manager: ISpriteManager);
  36672. /**
  36673. * Starts an animation
  36674. * @param from defines the initial key
  36675. * @param to defines the end key
  36676. * @param loop defines if the animation must loop
  36677. * @param delay defines the start delay (in ms)
  36678. * @param onAnimationEnd defines a callback to call when animation ends
  36679. */
  36680. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36681. /** Stops current animation (if any) */
  36682. stopAnimation(): void;
  36683. /** @hidden */
  36684. _animate(deltaTime: number): void;
  36685. /** Release associated resources */
  36686. dispose(): void;
  36687. }
  36688. }
  36689. declare module BABYLON {
  36690. /**
  36691. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36692. */
  36693. interface ISpriteManager extends IDisposable {
  36694. /**
  36695. * Restricts the camera to viewing objects with the same layerMask.
  36696. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36697. */
  36698. layerMask: number;
  36699. /**
  36700. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36701. */
  36702. isPickable: boolean;
  36703. /**
  36704. * Specifies the rendering group id for this mesh (0 by default)
  36705. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36706. */
  36707. renderingGroupId: number;
  36708. /**
  36709. * Defines the list of sprites managed by the manager.
  36710. */
  36711. sprites: Array<Sprite>;
  36712. /**
  36713. * Tests the intersection of a sprite with a specific ray.
  36714. * @param ray The ray we are sending to test the collision
  36715. * @param camera The camera space we are sending rays in
  36716. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36717. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36718. * @returns picking info or null.
  36719. */
  36720. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36721. /**
  36722. * Renders the list of sprites on screen.
  36723. */
  36724. render(): void;
  36725. }
  36726. /**
  36727. * Class used to manage multiple sprites on the same spritesheet
  36728. * @see http://doc.babylonjs.com/babylon101/sprites
  36729. */
  36730. class SpriteManager implements ISpriteManager {
  36731. /** defines the manager's name */
  36732. name: string;
  36733. /** Gets the list of sprites */
  36734. sprites: Sprite[];
  36735. /** Gets or sets the rendering group id (0 by default) */
  36736. renderingGroupId: number;
  36737. /** Gets or sets camera layer mask */
  36738. layerMask: number;
  36739. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36740. fogEnabled: boolean;
  36741. /** Gets or sets a boolean indicating if the sprites are pickable */
  36742. isPickable: boolean;
  36743. /** Defines the default width of a cell in the spritesheet */
  36744. cellWidth: number;
  36745. /** Defines the default height of a cell in the spritesheet */
  36746. cellHeight: number;
  36747. /**
  36748. * An event triggered when the manager is disposed.
  36749. */
  36750. onDisposeObservable: Observable<SpriteManager>;
  36751. private _onDisposeObserver;
  36752. /**
  36753. * Callback called when the manager is disposed
  36754. */
  36755. onDispose: () => void;
  36756. private _capacity;
  36757. private _spriteTexture;
  36758. private _epsilon;
  36759. private _scene;
  36760. private _vertexData;
  36761. private _buffer;
  36762. private _vertexBuffers;
  36763. private _indexBuffer;
  36764. private _effectBase;
  36765. private _effectFog;
  36766. /**
  36767. * Gets or sets the spritesheet texture
  36768. */
  36769. texture: Texture;
  36770. /**
  36771. * Creates a new sprite manager
  36772. * @param name defines the manager's name
  36773. * @param imgUrl defines the sprite sheet url
  36774. * @param capacity defines the maximum allowed number of sprites
  36775. * @param cellSize defines the size of a sprite cell
  36776. * @param scene defines the hosting scene
  36777. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  36778. * @param samplingMode defines the smapling mode to use with spritesheet
  36779. */
  36780. constructor(
  36781. /** defines the manager's name */
  36782. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  36783. private _appendSpriteVertex;
  36784. /**
  36785. * Intersects the sprites with a ray
  36786. * @param ray defines the ray to intersect with
  36787. * @param camera defines the current active camera
  36788. * @param predicate defines a predicate used to select candidate sprites
  36789. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  36790. * @returns null if no hit or a PickingInfo
  36791. */
  36792. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36793. /**
  36794. * Render all child sprites
  36795. */
  36796. render(): void;
  36797. /**
  36798. * Release associated resources
  36799. */
  36800. dispose(): void;
  36801. }
  36802. }
  36803. declare module BABYLON {
  36804. interface Scene {
  36805. /** @hidden */
  36806. _pointerOverSprite: Nullable<Sprite>;
  36807. /** @hidden */
  36808. _pickedDownSprite: Nullable<Sprite>;
  36809. /** @hidden */
  36810. _tempSpritePickingRay: Nullable<Ray>;
  36811. /**
  36812. * All of the sprite managers added to this scene
  36813. * @see http://doc.babylonjs.com/babylon101/sprites
  36814. */
  36815. spriteManagers: Array<ISpriteManager>;
  36816. /**
  36817. * An event triggered when sprites rendering is about to start
  36818. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36819. */
  36820. onBeforeSpritesRenderingObservable: Observable<Scene>;
  36821. /**
  36822. * An event triggered when sprites rendering is done
  36823. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36824. */
  36825. onAfterSpritesRenderingObservable: Observable<Scene>;
  36826. /** @hidden */
  36827. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36828. /** Launch a ray to try to pick a sprite in the scene
  36829. * @param x position on screen
  36830. * @param y position on screen
  36831. * @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
  36832. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36833. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36834. * @returns a PickingInfo
  36835. */
  36836. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36837. /** Use the given ray to pick a sprite in the scene
  36838. * @param ray The ray (in world space) to use to pick meshes
  36839. * @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
  36840. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36841. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  36842. * @returns a PickingInfo
  36843. */
  36844. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36845. /**
  36846. * Force the sprite under the pointer
  36847. * @param sprite defines the sprite to use
  36848. */
  36849. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  36850. /**
  36851. * Gets the sprite under the pointer
  36852. * @returns a Sprite or null if no sprite is under the pointer
  36853. */
  36854. getPointerOverSprite(): Nullable<Sprite>;
  36855. }
  36856. /**
  36857. * Defines the sprite scene component responsible to manage sprites
  36858. * in a given scene.
  36859. */
  36860. class SpriteSceneComponent implements ISceneComponent {
  36861. /**
  36862. * The component name helpfull to identify the component in the list of scene components.
  36863. */
  36864. readonly name: string;
  36865. /**
  36866. * The scene the component belongs to.
  36867. */
  36868. scene: Scene;
  36869. /** @hidden */
  36870. private _spritePredicate;
  36871. /**
  36872. * Creates a new instance of the component for the given scene
  36873. * @param scene Defines the scene to register the component in
  36874. */
  36875. constructor(scene: Scene);
  36876. /**
  36877. * Registers the component in a given scene
  36878. */
  36879. register(): void;
  36880. /**
  36881. * Rebuilds the elements related to this component in case of
  36882. * context lost for instance.
  36883. */
  36884. rebuild(): void;
  36885. /**
  36886. * Disposes the component and the associated ressources.
  36887. */
  36888. dispose(): void;
  36889. private _pickSpriteButKeepRay;
  36890. private _pointerMove;
  36891. private _pointerDown;
  36892. private _pointerUp;
  36893. }
  36894. }
  36895. declare module BABYLON {
  36896. /**
  36897. * @hidden
  36898. **/
  36899. class _AlphaState {
  36900. private _isAlphaBlendDirty;
  36901. private _isBlendFunctionParametersDirty;
  36902. private _isBlendEquationParametersDirty;
  36903. private _isBlendConstantsDirty;
  36904. private _alphaBlend;
  36905. private _blendFunctionParameters;
  36906. private _blendEquationParameters;
  36907. private _blendConstants;
  36908. /**
  36909. * Initializes the state.
  36910. */
  36911. constructor();
  36912. readonly isDirty: boolean;
  36913. alphaBlend: boolean;
  36914. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36915. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36916. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36917. reset(): void;
  36918. apply(gl: WebGLRenderingContext): void;
  36919. }
  36920. }
  36921. declare module BABYLON {
  36922. /**
  36923. * @hidden
  36924. **/
  36925. class _DepthCullingState {
  36926. private _isDepthTestDirty;
  36927. private _isDepthMaskDirty;
  36928. private _isDepthFuncDirty;
  36929. private _isCullFaceDirty;
  36930. private _isCullDirty;
  36931. private _isZOffsetDirty;
  36932. private _isFrontFaceDirty;
  36933. private _depthTest;
  36934. private _depthMask;
  36935. private _depthFunc;
  36936. private _cull;
  36937. private _cullFace;
  36938. private _zOffset;
  36939. private _frontFace;
  36940. /**
  36941. * Initializes the state.
  36942. */
  36943. constructor();
  36944. readonly isDirty: boolean;
  36945. zOffset: number;
  36946. cullFace: Nullable<number>;
  36947. cull: Nullable<boolean>;
  36948. depthFunc: Nullable<number>;
  36949. depthMask: boolean;
  36950. depthTest: boolean;
  36951. frontFace: Nullable<number>;
  36952. reset(): void;
  36953. apply(gl: WebGLRenderingContext): void;
  36954. }
  36955. }
  36956. declare module BABYLON {
  36957. /**
  36958. * @hidden
  36959. **/
  36960. class _StencilState {
  36961. private _isStencilTestDirty;
  36962. private _isStencilMaskDirty;
  36963. private _isStencilFuncDirty;
  36964. private _isStencilOpDirty;
  36965. private _stencilTest;
  36966. private _stencilMask;
  36967. private _stencilFunc;
  36968. private _stencilFuncRef;
  36969. private _stencilFuncMask;
  36970. private _stencilOpStencilFail;
  36971. private _stencilOpDepthFail;
  36972. private _stencilOpStencilDepthPass;
  36973. readonly isDirty: boolean;
  36974. stencilFunc: number;
  36975. stencilFuncRef: number;
  36976. stencilFuncMask: number;
  36977. stencilOpStencilFail: number;
  36978. stencilOpDepthFail: number;
  36979. stencilOpStencilDepthPass: number;
  36980. stencilMask: number;
  36981. stencilTest: boolean;
  36982. constructor();
  36983. reset(): void;
  36984. apply(gl: WebGLRenderingContext): void;
  36985. }
  36986. }
  36987. declare module BABYLON {
  36988. /**
  36989. * Class used to evalaute queries containing `and` and `or` operators
  36990. */
  36991. class AndOrNotEvaluator {
  36992. /**
  36993. * Evaluate a query
  36994. * @param query defines the query to evaluate
  36995. * @param evaluateCallback defines the callback used to filter result
  36996. * @returns true if the query matches
  36997. */
  36998. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  36999. private static _HandleParenthesisContent;
  37000. private static _SimplifyNegation;
  37001. }
  37002. }
  37003. declare module BABYLON {
  37004. /**
  37005. * Defines the list of states available for a task inside a AssetsManager
  37006. */
  37007. enum AssetTaskState {
  37008. /**
  37009. * Initialization
  37010. */
  37011. INIT = 0,
  37012. /**
  37013. * Running
  37014. */
  37015. RUNNING = 1,
  37016. /**
  37017. * Done
  37018. */
  37019. DONE = 2,
  37020. /**
  37021. * Error
  37022. */
  37023. ERROR = 3
  37024. }
  37025. /**
  37026. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37027. */
  37028. abstract class AbstractAssetTask {
  37029. /**
  37030. * Task name
  37031. */ name: string;
  37032. /**
  37033. * Callback called when the task is successful
  37034. */
  37035. onSuccess: (task: any) => void;
  37036. /**
  37037. * Callback called when the task is not successful
  37038. */
  37039. onError: (task: any, message?: string, exception?: any) => void;
  37040. /**
  37041. * Creates a new AssetsManager
  37042. * @param name defines the name of the task
  37043. */
  37044. constructor(
  37045. /**
  37046. * Task name
  37047. */ name: string);
  37048. private _isCompleted;
  37049. private _taskState;
  37050. private _errorObject;
  37051. /**
  37052. * Get if the task is completed
  37053. */
  37054. readonly isCompleted: boolean;
  37055. /**
  37056. * Gets the current state of the task
  37057. */
  37058. readonly taskState: AssetTaskState;
  37059. /**
  37060. * Gets the current error object (if task is in error)
  37061. */
  37062. readonly errorObject: {
  37063. message?: string;
  37064. exception?: any;
  37065. };
  37066. /**
  37067. * Internal only
  37068. * @hidden
  37069. */
  37070. _setErrorObject(message?: string, exception?: any): void;
  37071. /**
  37072. * Execute the current task
  37073. * @param scene defines the scene where you want your assets to be loaded
  37074. * @param onSuccess is a callback called when the task is successfully executed
  37075. * @param onError is a callback called if an error occurs
  37076. */
  37077. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37078. /**
  37079. * Execute the current task
  37080. * @param scene defines the scene where you want your assets to be loaded
  37081. * @param onSuccess is a callback called when the task is successfully executed
  37082. * @param onError is a callback called if an error occurs
  37083. */
  37084. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37085. /**
  37086. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37087. * This can be used with failed tasks that have the reason for failure fixed.
  37088. */
  37089. reset(): void;
  37090. private onErrorCallback;
  37091. private onDoneCallback;
  37092. }
  37093. /**
  37094. * Define the interface used by progress events raised during assets loading
  37095. */
  37096. interface IAssetsProgressEvent {
  37097. /**
  37098. * Defines the number of remaining tasks to process
  37099. */
  37100. remainingCount: number;
  37101. /**
  37102. * Defines the total number of tasks
  37103. */
  37104. totalCount: number;
  37105. /**
  37106. * Defines the task that was just processed
  37107. */
  37108. task: AbstractAssetTask;
  37109. }
  37110. /**
  37111. * Class used to share progress information about assets loading
  37112. */
  37113. class AssetsProgressEvent implements IAssetsProgressEvent {
  37114. /**
  37115. * Defines the number of remaining tasks to process
  37116. */
  37117. remainingCount: number;
  37118. /**
  37119. * Defines the total number of tasks
  37120. */
  37121. totalCount: number;
  37122. /**
  37123. * Defines the task that was just processed
  37124. */
  37125. task: AbstractAssetTask;
  37126. /**
  37127. * Creates a AssetsProgressEvent
  37128. * @param remainingCount defines the number of remaining tasks to process
  37129. * @param totalCount defines the total number of tasks
  37130. * @param task defines the task that was just processed
  37131. */
  37132. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37133. }
  37134. /**
  37135. * Define a task used by AssetsManager to load meshes
  37136. */
  37137. class MeshAssetTask extends AbstractAssetTask {
  37138. /**
  37139. * Defines the name of the task
  37140. */
  37141. name: string;
  37142. /**
  37143. * Defines the list of mesh's names you want to load
  37144. */
  37145. meshesNames: any;
  37146. /**
  37147. * Defines the root url to use as a base to load your meshes and associated resources
  37148. */
  37149. rootUrl: string;
  37150. /**
  37151. * Defines the filename of the scene to load from
  37152. */
  37153. sceneFilename: string;
  37154. /**
  37155. * Gets the list of loaded meshes
  37156. */
  37157. loadedMeshes: Array<AbstractMesh>;
  37158. /**
  37159. * Gets the list of loaded particle systems
  37160. */
  37161. loadedParticleSystems: Array<IParticleSystem>;
  37162. /**
  37163. * Gets the list of loaded skeletons
  37164. */
  37165. loadedSkeletons: Array<Skeleton>;
  37166. /**
  37167. * Callback called when the task is successful
  37168. */
  37169. onSuccess: (task: MeshAssetTask) => void;
  37170. /**
  37171. * Callback called when the task is successful
  37172. */
  37173. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37174. /**
  37175. * Creates a new MeshAssetTask
  37176. * @param name defines the name of the task
  37177. * @param meshesNames defines the list of mesh's names you want to load
  37178. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37179. * @param sceneFilename defines the filename of the scene to load from
  37180. */
  37181. constructor(
  37182. /**
  37183. * Defines the name of the task
  37184. */
  37185. name: string,
  37186. /**
  37187. * Defines the list of mesh's names you want to load
  37188. */
  37189. meshesNames: any,
  37190. /**
  37191. * Defines the root url to use as a base to load your meshes and associated resources
  37192. */
  37193. rootUrl: string,
  37194. /**
  37195. * Defines the filename of the scene to load from
  37196. */
  37197. sceneFilename: string);
  37198. /**
  37199. * Execute the current task
  37200. * @param scene defines the scene where you want your assets to be loaded
  37201. * @param onSuccess is a callback called when the task is successfully executed
  37202. * @param onError is a callback called if an error occurs
  37203. */
  37204. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37205. }
  37206. /**
  37207. * Define a task used by AssetsManager to load text content
  37208. */
  37209. class TextFileAssetTask extends AbstractAssetTask {
  37210. /**
  37211. * Defines the name of the task
  37212. */
  37213. name: string;
  37214. /**
  37215. * Defines the location of the file to load
  37216. */
  37217. url: string;
  37218. /**
  37219. * Gets the loaded text string
  37220. */
  37221. text: string;
  37222. /**
  37223. * Callback called when the task is successful
  37224. */
  37225. onSuccess: (task: TextFileAssetTask) => void;
  37226. /**
  37227. * Callback called when the task is successful
  37228. */
  37229. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37230. /**
  37231. * Creates a new TextFileAssetTask object
  37232. * @param name defines the name of the task
  37233. * @param url defines the location of the file to load
  37234. */
  37235. constructor(
  37236. /**
  37237. * Defines the name of the task
  37238. */
  37239. name: string,
  37240. /**
  37241. * Defines the location of the file to load
  37242. */
  37243. url: string);
  37244. /**
  37245. * Execute the current task
  37246. * @param scene defines the scene where you want your assets to be loaded
  37247. * @param onSuccess is a callback called when the task is successfully executed
  37248. * @param onError is a callback called if an error occurs
  37249. */
  37250. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37251. }
  37252. /**
  37253. * Define a task used by AssetsManager to load binary data
  37254. */
  37255. class BinaryFileAssetTask extends AbstractAssetTask {
  37256. /**
  37257. * Defines the name of the task
  37258. */
  37259. name: string;
  37260. /**
  37261. * Defines the location of the file to load
  37262. */
  37263. url: string;
  37264. /**
  37265. * Gets the lodaded data (as an array buffer)
  37266. */
  37267. data: ArrayBuffer;
  37268. /**
  37269. * Callback called when the task is successful
  37270. */
  37271. onSuccess: (task: BinaryFileAssetTask) => void;
  37272. /**
  37273. * Callback called when the task is successful
  37274. */
  37275. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37276. /**
  37277. * Creates a new BinaryFileAssetTask object
  37278. * @param name defines the name of the new task
  37279. * @param url defines the location of the file to load
  37280. */
  37281. constructor(
  37282. /**
  37283. * Defines the name of the task
  37284. */
  37285. name: string,
  37286. /**
  37287. * Defines the location of the file to load
  37288. */
  37289. url: string);
  37290. /**
  37291. * Execute the current task
  37292. * @param scene defines the scene where you want your assets to be loaded
  37293. * @param onSuccess is a callback called when the task is successfully executed
  37294. * @param onError is a callback called if an error occurs
  37295. */
  37296. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37297. }
  37298. /**
  37299. * Define a task used by AssetsManager to load images
  37300. */
  37301. class ImageAssetTask extends AbstractAssetTask {
  37302. /**
  37303. * Defines the name of the task
  37304. */
  37305. name: string;
  37306. /**
  37307. * Defines the location of the image to load
  37308. */
  37309. url: string;
  37310. /**
  37311. * Gets the loaded images
  37312. */
  37313. image: HTMLImageElement;
  37314. /**
  37315. * Callback called when the task is successful
  37316. */
  37317. onSuccess: (task: ImageAssetTask) => void;
  37318. /**
  37319. * Callback called when the task is successful
  37320. */
  37321. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37322. /**
  37323. * Creates a new ImageAssetTask
  37324. * @param name defines the name of the task
  37325. * @param url defines the location of the image to load
  37326. */
  37327. constructor(
  37328. /**
  37329. * Defines the name of the task
  37330. */
  37331. name: string,
  37332. /**
  37333. * Defines the location of the image to load
  37334. */
  37335. url: string);
  37336. /**
  37337. * Execute the current task
  37338. * @param scene defines the scene where you want your assets to be loaded
  37339. * @param onSuccess is a callback called when the task is successfully executed
  37340. * @param onError is a callback called if an error occurs
  37341. */
  37342. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37343. }
  37344. /**
  37345. * Defines the interface used by texture loading tasks
  37346. */
  37347. interface ITextureAssetTask<TEX extends BaseTexture> {
  37348. /**
  37349. * Gets the loaded texture
  37350. */
  37351. texture: TEX;
  37352. }
  37353. /**
  37354. * Define a task used by AssetsManager to load 2D textures
  37355. */
  37356. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37357. /**
  37358. * Defines the name of the task
  37359. */
  37360. name: string;
  37361. /**
  37362. * Defines the location of the file to load
  37363. */
  37364. url: string;
  37365. /**
  37366. * Defines if mipmap should not be generated (default is false)
  37367. */
  37368. noMipmap?: boolean | undefined;
  37369. /**
  37370. * Defines if texture must be inverted on Y axis (default is false)
  37371. */
  37372. invertY?: boolean | undefined;
  37373. /**
  37374. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37375. */
  37376. samplingMode: number;
  37377. /**
  37378. * Gets the loaded texture
  37379. */
  37380. texture: Texture;
  37381. /**
  37382. * Callback called when the task is successful
  37383. */
  37384. onSuccess: (task: TextureAssetTask) => void;
  37385. /**
  37386. * Callback called when the task is successful
  37387. */
  37388. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37389. /**
  37390. * Creates a new TextureAssetTask object
  37391. * @param name defines the name of the task
  37392. * @param url defines the location of the file to load
  37393. * @param noMipmap defines if mipmap should not be generated (default is false)
  37394. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37395. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37396. */
  37397. constructor(
  37398. /**
  37399. * Defines the name of the task
  37400. */
  37401. name: string,
  37402. /**
  37403. * Defines the location of the file to load
  37404. */
  37405. url: string,
  37406. /**
  37407. * Defines if mipmap should not be generated (default is false)
  37408. */
  37409. noMipmap?: boolean | undefined,
  37410. /**
  37411. * Defines if texture must be inverted on Y axis (default is false)
  37412. */
  37413. invertY?: boolean | undefined,
  37414. /**
  37415. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37416. */
  37417. samplingMode?: number);
  37418. /**
  37419. * Execute the current task
  37420. * @param scene defines the scene where you want your assets to be loaded
  37421. * @param onSuccess is a callback called when the task is successfully executed
  37422. * @param onError is a callback called if an error occurs
  37423. */
  37424. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37425. }
  37426. /**
  37427. * Define a task used by AssetsManager to load cube textures
  37428. */
  37429. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37430. /**
  37431. * Defines the name of the task
  37432. */
  37433. name: string;
  37434. /**
  37435. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37436. */
  37437. url: string;
  37438. /**
  37439. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37440. */
  37441. extensions?: string[] | undefined;
  37442. /**
  37443. * Defines if mipmaps should not be generated (default is false)
  37444. */
  37445. noMipmap?: boolean | undefined;
  37446. /**
  37447. * Defines the explicit list of files (undefined by default)
  37448. */
  37449. files?: string[] | undefined;
  37450. /**
  37451. * Gets the loaded texture
  37452. */
  37453. texture: CubeTexture;
  37454. /**
  37455. * Callback called when the task is successful
  37456. */
  37457. onSuccess: (task: CubeTextureAssetTask) => void;
  37458. /**
  37459. * Callback called when the task is successful
  37460. */
  37461. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37462. /**
  37463. * Creates a new CubeTextureAssetTask
  37464. * @param name defines the name of the task
  37465. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37466. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37467. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37468. * @param files defines the explicit list of files (undefined by default)
  37469. */
  37470. constructor(
  37471. /**
  37472. * Defines the name of the task
  37473. */
  37474. name: string,
  37475. /**
  37476. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37477. */
  37478. url: string,
  37479. /**
  37480. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37481. */
  37482. extensions?: string[] | undefined,
  37483. /**
  37484. * Defines if mipmaps should not be generated (default is false)
  37485. */
  37486. noMipmap?: boolean | undefined,
  37487. /**
  37488. * Defines the explicit list of files (undefined by default)
  37489. */
  37490. files?: string[] | undefined);
  37491. /**
  37492. * Execute the current task
  37493. * @param scene defines the scene where you want your assets to be loaded
  37494. * @param onSuccess is a callback called when the task is successfully executed
  37495. * @param onError is a callback called if an error occurs
  37496. */
  37497. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37498. }
  37499. /**
  37500. * Define a task used by AssetsManager to load HDR cube textures
  37501. */
  37502. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37503. /**
  37504. * Defines the name of the task
  37505. */
  37506. name: string;
  37507. /**
  37508. * Defines the location of the file to load
  37509. */
  37510. url: string;
  37511. /**
  37512. * Defines the desired size (the more it increases the longer the generation will be)
  37513. */
  37514. size: number;
  37515. /**
  37516. * Defines if mipmaps should not be generated (default is false)
  37517. */
  37518. noMipmap: boolean;
  37519. /**
  37520. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37521. */
  37522. generateHarmonics: boolean;
  37523. /**
  37524. * 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)
  37525. */
  37526. gammaSpace: boolean;
  37527. /**
  37528. * Internal Use Only
  37529. */
  37530. reserved: boolean;
  37531. /**
  37532. * Gets the loaded texture
  37533. */
  37534. texture: HDRCubeTexture;
  37535. /**
  37536. * Callback called when the task is successful
  37537. */
  37538. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37539. /**
  37540. * Callback called when the task is successful
  37541. */
  37542. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37543. /**
  37544. * Creates a new HDRCubeTextureAssetTask object
  37545. * @param name defines the name of the task
  37546. * @param url defines the location of the file to load
  37547. * @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.
  37548. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37549. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37550. * @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)
  37551. * @param reserved Internal use only
  37552. */
  37553. constructor(
  37554. /**
  37555. * Defines the name of the task
  37556. */
  37557. name: string,
  37558. /**
  37559. * Defines the location of the file to load
  37560. */
  37561. url: string,
  37562. /**
  37563. * Defines the desired size (the more it increases the longer the generation will be)
  37564. */
  37565. size: number,
  37566. /**
  37567. * Defines if mipmaps should not be generated (default is false)
  37568. */
  37569. noMipmap?: boolean,
  37570. /**
  37571. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37572. */
  37573. generateHarmonics?: boolean,
  37574. /**
  37575. * 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)
  37576. */
  37577. gammaSpace?: boolean,
  37578. /**
  37579. * Internal Use Only
  37580. */
  37581. reserved?: boolean);
  37582. /**
  37583. * Execute the current task
  37584. * @param scene defines the scene where you want your assets to be loaded
  37585. * @param onSuccess is a callback called when the task is successfully executed
  37586. * @param onError is a callback called if an error occurs
  37587. */
  37588. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37589. }
  37590. /**
  37591. * This class can be used to easily import assets into a scene
  37592. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37593. */
  37594. class AssetsManager {
  37595. private _scene;
  37596. private _isLoading;
  37597. protected _tasks: AbstractAssetTask[];
  37598. protected _waitingTasksCount: number;
  37599. protected _totalTasksCount: number;
  37600. /**
  37601. * Callback called when all tasks are processed
  37602. */
  37603. onFinish: (tasks: AbstractAssetTask[]) => void;
  37604. /**
  37605. * Callback called when a task is successful
  37606. */
  37607. onTaskSuccess: (task: AbstractAssetTask) => void;
  37608. /**
  37609. * Callback called when a task had an error
  37610. */
  37611. onTaskError: (task: AbstractAssetTask) => void;
  37612. /**
  37613. * Callback called when a task is done (whatever the result is)
  37614. */
  37615. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37616. /**
  37617. * Observable called when all tasks are processed
  37618. */
  37619. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37620. /**
  37621. * Observable called when a task had an error
  37622. */
  37623. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37624. /**
  37625. * Observable called when a task is successful
  37626. */
  37627. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37628. /**
  37629. * Observable called when a task is done (whatever the result is)
  37630. */
  37631. onProgressObservable: Observable<IAssetsProgressEvent>;
  37632. /**
  37633. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37634. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37635. */
  37636. useDefaultLoadingScreen: boolean;
  37637. /**
  37638. * Creates a new AssetsManager
  37639. * @param scene defines the scene to work on
  37640. */
  37641. constructor(scene: Scene);
  37642. /**
  37643. * Add a MeshAssetTask to the list of active tasks
  37644. * @param taskName defines the name of the new task
  37645. * @param meshesNames defines the name of meshes to load
  37646. * @param rootUrl defines the root url to use to locate files
  37647. * @param sceneFilename defines the filename of the scene file
  37648. * @returns a new MeshAssetTask object
  37649. */
  37650. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37651. /**
  37652. * Add a TextFileAssetTask to the list of active tasks
  37653. * @param taskName defines the name of the new task
  37654. * @param url defines the url of the file to load
  37655. * @returns a new TextFileAssetTask object
  37656. */
  37657. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37658. /**
  37659. * Add a BinaryFileAssetTask to the list of active tasks
  37660. * @param taskName defines the name of the new task
  37661. * @param url defines the url of the file to load
  37662. * @returns a new BinaryFileAssetTask object
  37663. */
  37664. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37665. /**
  37666. * Add a ImageAssetTask to the list of active tasks
  37667. * @param taskName defines the name of the new task
  37668. * @param url defines the url of the file to load
  37669. * @returns a new ImageAssetTask object
  37670. */
  37671. addImageTask(taskName: string, url: string): ImageAssetTask;
  37672. /**
  37673. * Add a TextureAssetTask to the list of active tasks
  37674. * @param taskName defines the name of the new task
  37675. * @param url defines the url of the file to load
  37676. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37677. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37678. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37679. * @returns a new TextureAssetTask object
  37680. */
  37681. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37682. /**
  37683. * Add a CubeTextureAssetTask to the list of active tasks
  37684. * @param taskName defines the name of the new task
  37685. * @param url defines the url of the file to load
  37686. * @param extensions defines the extension to use to load the cube map (can be null)
  37687. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37688. * @param files defines the list of files to load (can be null)
  37689. * @returns a new CubeTextureAssetTask object
  37690. */
  37691. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37692. /**
  37693. *
  37694. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37695. * @param taskName defines the name of the new task
  37696. * @param url defines the url of the file to load
  37697. * @param size defines the size you want for the cubemap (can be null)
  37698. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37699. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37700. * @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)
  37701. * @param reserved Internal use only
  37702. * @returns a new HDRCubeTextureAssetTask object
  37703. */
  37704. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37705. /**
  37706. * Remove a task from the assets manager.
  37707. * @param task the task to remove
  37708. */
  37709. removeTask(task: AbstractAssetTask): void;
  37710. private _decreaseWaitingTasksCount;
  37711. private _runTask;
  37712. /**
  37713. * Reset the AssetsManager and remove all tasks
  37714. * @return the current instance of the AssetsManager
  37715. */
  37716. reset(): AssetsManager;
  37717. /**
  37718. * Start the loading process
  37719. * @return the current instance of the AssetsManager
  37720. */
  37721. load(): AssetsManager;
  37722. }
  37723. }
  37724. declare module BABYLON {
  37725. /**
  37726. * Direct draw surface info
  37727. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37728. */
  37729. interface DDSInfo {
  37730. /**
  37731. * Width of the texture
  37732. */
  37733. width: number;
  37734. /**
  37735. * Width of the texture
  37736. */
  37737. height: number;
  37738. /**
  37739. * Number of Mipmaps for the texture
  37740. * @see https://en.wikipedia.org/wiki/Mipmap
  37741. */
  37742. mipmapCount: number;
  37743. /**
  37744. * If the textures format is a known fourCC format
  37745. * @see https://www.fourcc.org/
  37746. */
  37747. isFourCC: boolean;
  37748. /**
  37749. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37750. */
  37751. isRGB: boolean;
  37752. /**
  37753. * If the texture is a lumincance format
  37754. */
  37755. isLuminance: boolean;
  37756. /**
  37757. * If this is a cube texture
  37758. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37759. */
  37760. isCube: boolean;
  37761. /**
  37762. * If the texture is a compressed format eg. FOURCC_DXT1
  37763. */
  37764. isCompressed: boolean;
  37765. /**
  37766. * The dxgiFormat of the texture
  37767. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37768. */
  37769. dxgiFormat: number;
  37770. /**
  37771. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37772. */
  37773. textureType: number;
  37774. /**
  37775. * Sphericle polynomial created for the dds texture
  37776. */
  37777. sphericalPolynomial?: SphericalPolynomial;
  37778. }
  37779. /**
  37780. * Class used to provide DDS decompression tools
  37781. */
  37782. class DDSTools {
  37783. /**
  37784. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37785. */
  37786. static StoreLODInAlphaChannel: boolean;
  37787. /**
  37788. * Gets DDS information from an array buffer
  37789. * @param arrayBuffer defines the array buffer to read data from
  37790. * @returns the DDS information
  37791. */
  37792. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37793. private static _FloatView;
  37794. private static _Int32View;
  37795. private static _ToHalfFloat;
  37796. private static _FromHalfFloat;
  37797. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37798. private static _GetHalfFloatRGBAArrayBuffer;
  37799. private static _GetFloatRGBAArrayBuffer;
  37800. private static _GetFloatAsUIntRGBAArrayBuffer;
  37801. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37802. private static _GetRGBAArrayBuffer;
  37803. private static _ExtractLongWordOrder;
  37804. private static _GetRGBArrayBuffer;
  37805. private static _GetLuminanceArrayBuffer;
  37806. /**
  37807. * Uploads DDS Levels to a Babylon Texture
  37808. * @hidden
  37809. */
  37810. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37811. }
  37812. }
  37813. declare module BABYLON {
  37814. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37815. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37816. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37817. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37818. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37819. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37820. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37821. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37822. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37823. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37824. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37825. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37826. /**
  37827. * Decorator used to define property that can be serialized as reference to a camera
  37828. * @param sourceName defines the name of the property to decorate
  37829. */
  37830. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37831. /**
  37832. * Class used to help serialization objects
  37833. */
  37834. class SerializationHelper {
  37835. /**
  37836. * Static function used to serialized a specific entity
  37837. * @param entity defines the entity to serialize
  37838. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37839. * @returns a JSON compatible object representing the serialization of the entity
  37840. */
  37841. static Serialize<T>(entity: T, serializationObject?: any): any;
  37842. /**
  37843. * Creates a new entity from a serialization data object
  37844. * @param creationFunction defines a function used to instanciated the new entity
  37845. * @param source defines the source serialization data
  37846. * @param scene defines the hosting scene
  37847. * @param rootUrl defines the root url for resources
  37848. * @returns a new entity
  37849. */
  37850. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37851. /**
  37852. * Clones an object
  37853. * @param creationFunction defines the function used to instanciate the new object
  37854. * @param source defines the source object
  37855. * @returns the cloned object
  37856. */
  37857. static Clone<T>(creationFunction: () => T, source: T): T;
  37858. /**
  37859. * Instanciates a new object based on a source one (some data will be shared between both object)
  37860. * @param creationFunction defines the function used to instanciate the new object
  37861. * @param source defines the source object
  37862. * @returns the new object
  37863. */
  37864. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37865. }
  37866. }
  37867. declare module BABYLON {
  37868. /**
  37869. * Wrapper class for promise with external resolve and reject.
  37870. */
  37871. class Deferred<T> {
  37872. /**
  37873. * The promise associated with this deferred object.
  37874. */
  37875. readonly promise: Promise<T>;
  37876. private _resolve;
  37877. private _reject;
  37878. /**
  37879. * The resolve method of the promise associated with this deferred object.
  37880. */
  37881. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37882. /**
  37883. * The reject method of the promise associated with this deferred object.
  37884. */
  37885. readonly reject: (reason?: any) => void;
  37886. /**
  37887. * Constructor for this deferred object.
  37888. */
  37889. constructor();
  37890. }
  37891. }
  37892. declare module BABYLON {
  37893. /**
  37894. * Raw texture data and descriptor sufficient for WebGL texture upload
  37895. */
  37896. interface EnvironmentTextureInfo {
  37897. /**
  37898. * Version of the environment map
  37899. */
  37900. version: number;
  37901. /**
  37902. * Width of image
  37903. */
  37904. width: number;
  37905. /**
  37906. * Irradiance information stored in the file.
  37907. */
  37908. irradiance: any;
  37909. /**
  37910. * Specular information stored in the file.
  37911. */
  37912. specular: any;
  37913. }
  37914. /**
  37915. * Sets of helpers addressing the serialization and deserialization of environment texture
  37916. * stored in a BabylonJS env file.
  37917. * Those files are usually stored as .env files.
  37918. */
  37919. class EnvironmentTextureTools {
  37920. /**
  37921. * Magic number identifying the env file.
  37922. */
  37923. private static _MagicBytes;
  37924. /**
  37925. * Gets the environment info from an env file.
  37926. * @param data The array buffer containing the .env bytes.
  37927. * @returns the environment file info (the json header) if successfully parsed.
  37928. */
  37929. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  37930. /**
  37931. * Creates an environment texture from a loaded cube texture.
  37932. * @param texture defines the cube texture to convert in env file
  37933. * @return a promise containing the environment data if succesfull.
  37934. */
  37935. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  37936. /**
  37937. * Creates a JSON representation of the spherical data.
  37938. * @param texture defines the texture containing the polynomials
  37939. * @return the JSON representation of the spherical info
  37940. */
  37941. private static _CreateEnvTextureIrradiance;
  37942. /**
  37943. * Uploads the texture info contained in the env file to the GPU.
  37944. * @param texture defines the internal texture to upload to
  37945. * @param arrayBuffer defines the buffer cotaining the data to load
  37946. * @param info defines the texture info retrieved through the GetEnvInfo method
  37947. * @returns a promise
  37948. */
  37949. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  37950. /**
  37951. * Uploads the levels of image data to the GPU.
  37952. * @param texture defines the internal texture to upload to
  37953. * @param imageData defines the array buffer views of image data [mipmap][face]
  37954. * @returns a promise
  37955. */
  37956. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  37957. /**
  37958. * Uploads spherical polynomials information to the texture.
  37959. * @param texture defines the texture we are trying to upload the information to
  37960. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  37961. */
  37962. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  37963. }
  37964. }
  37965. declare module BABYLON {
  37966. /**
  37967. * Class used to help managing file picking and drag'n'drop
  37968. */
  37969. class FilesInput {
  37970. /**
  37971. * List of files ready to be loaded
  37972. */
  37973. static FilesToLoad: {
  37974. [key: string]: File;
  37975. };
  37976. /**
  37977. * Callback called when a file is processed
  37978. */
  37979. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  37980. private _engine;
  37981. private _currentScene;
  37982. private _sceneLoadedCallback;
  37983. private _progressCallback;
  37984. private _additionalRenderLoopLogicCallback;
  37985. private _textureLoadingCallback;
  37986. private _startingProcessingFilesCallback;
  37987. private _onReloadCallback;
  37988. private _errorCallback;
  37989. private _elementToMonitor;
  37990. private _sceneFileToLoad;
  37991. private _filesToLoad;
  37992. /**
  37993. * Creates a new FilesInput
  37994. * @param engine defines the rendering engine
  37995. * @param scene defines the hosting scene
  37996. * @param sceneLoadedCallback callback called when scene is loaded
  37997. * @param progressCallback callback called to track progress
  37998. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  37999. * @param textureLoadingCallback callback called when a texture is loading
  38000. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38001. * @param onReloadCallback callback called when a reload is requested
  38002. * @param errorCallback callback call if an error occurs
  38003. */
  38004. 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);
  38005. private _dragEnterHandler;
  38006. private _dragOverHandler;
  38007. private _dropHandler;
  38008. /**
  38009. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38010. * @param elementToMonitor defines the DOM element to track
  38011. */
  38012. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38013. /**
  38014. * Release all associated resources
  38015. */
  38016. dispose(): void;
  38017. private renderFunction;
  38018. private drag;
  38019. private drop;
  38020. private _traverseFolder;
  38021. private _processFiles;
  38022. /**
  38023. * Load files from a drop event
  38024. * @param event defines the drop event to use as source
  38025. */
  38026. loadFiles(event: any): void;
  38027. private _processReload;
  38028. /**
  38029. * Reload the current scene from the loaded files
  38030. */
  38031. reload(): void;
  38032. }
  38033. }
  38034. declare module BABYLON {
  38035. /**
  38036. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38037. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38038. */
  38039. class KhronosTextureContainer {
  38040. /** contents of the KTX container file */
  38041. arrayBuffer: any;
  38042. private static HEADER_LEN;
  38043. private static COMPRESSED_2D;
  38044. private static COMPRESSED_3D;
  38045. private static TEX_2D;
  38046. private static TEX_3D;
  38047. /**
  38048. * Gets the openGL type
  38049. */
  38050. glType: number;
  38051. /**
  38052. * Gets the openGL type size
  38053. */
  38054. glTypeSize: number;
  38055. /**
  38056. * Gets the openGL format
  38057. */
  38058. glFormat: number;
  38059. /**
  38060. * Gets the openGL internal format
  38061. */
  38062. glInternalFormat: number;
  38063. /**
  38064. * Gets the base internal format
  38065. */
  38066. glBaseInternalFormat: number;
  38067. /**
  38068. * Gets image width in pixel
  38069. */
  38070. pixelWidth: number;
  38071. /**
  38072. * Gets image height in pixel
  38073. */
  38074. pixelHeight: number;
  38075. /**
  38076. * Gets image depth in pixels
  38077. */
  38078. pixelDepth: number;
  38079. /**
  38080. * Gets the number of array elements
  38081. */
  38082. numberOfArrayElements: number;
  38083. /**
  38084. * Gets the number of faces
  38085. */
  38086. numberOfFaces: number;
  38087. /**
  38088. * Gets the number of mipmap levels
  38089. */
  38090. numberOfMipmapLevels: number;
  38091. /**
  38092. * Gets the bytes of key value data
  38093. */
  38094. bytesOfKeyValueData: number;
  38095. /**
  38096. * Gets the load type
  38097. */
  38098. loadType: number;
  38099. /**
  38100. * Creates a new KhronosTextureContainer
  38101. * @param arrayBuffer contents of the KTX container file
  38102. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38103. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38104. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38105. */
  38106. constructor(
  38107. /** contents of the KTX container file */
  38108. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38109. /**
  38110. * Revert the endianness of a value.
  38111. * Not as fast hardware based, but will probably never need to use
  38112. * @param val defines the value to convert
  38113. * @returns the new value
  38114. */
  38115. switchEndianness(val: number): number;
  38116. /**
  38117. * Uploads KTX content to a Babylon Texture.
  38118. * It is assumed that the texture has already been created & is currently bound
  38119. * @hidden
  38120. */
  38121. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38122. private _upload2DCompressedLevels;
  38123. }
  38124. }
  38125. declare module BABYLON {
  38126. /**
  38127. * A class serves as a medium between the observable and its observers
  38128. */
  38129. class EventState {
  38130. /**
  38131. * Create a new EventState
  38132. * @param mask defines the mask associated with this state
  38133. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38134. * @param target defines the original target of the state
  38135. * @param currentTarget defines the current target of the state
  38136. */
  38137. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38138. /**
  38139. * Initialize the current event state
  38140. * @param mask defines the mask associated with this state
  38141. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38142. * @param target defines the original target of the state
  38143. * @param currentTarget defines the current target of the state
  38144. * @returns the current event state
  38145. */
  38146. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38147. /**
  38148. * An Observer can set this property to true to prevent subsequent observers of being notified
  38149. */
  38150. skipNextObservers: boolean;
  38151. /**
  38152. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38153. */
  38154. mask: number;
  38155. /**
  38156. * The object that originally notified the event
  38157. */
  38158. target?: any;
  38159. /**
  38160. * The current object in the bubbling phase
  38161. */
  38162. currentTarget?: any;
  38163. /**
  38164. * This will be populated with the return value of the last function that was executed.
  38165. * If it is the first function in the callback chain it will be the event data.
  38166. */
  38167. lastReturnValue?: any;
  38168. }
  38169. /**
  38170. * Represent an Observer registered to a given Observable object.
  38171. */
  38172. class Observer<T> {
  38173. /**
  38174. * Defines the callback to call when the observer is notified
  38175. */
  38176. callback: (eventData: T, eventState: EventState) => void;
  38177. /**
  38178. * Defines the mask of the observer (used to filter notifications)
  38179. */
  38180. mask: number;
  38181. /**
  38182. * Defines the current scope used to restore the JS context
  38183. */
  38184. scope: any;
  38185. /** @hidden */
  38186. _willBeUnregistered: boolean;
  38187. /**
  38188. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38189. */
  38190. unregisterOnNextCall: boolean;
  38191. /**
  38192. * Creates a new observer
  38193. * @param callback defines the callback to call when the observer is notified
  38194. * @param mask defines the mask of the observer (used to filter notifications)
  38195. * @param scope defines the current scope used to restore the JS context
  38196. */
  38197. constructor(
  38198. /**
  38199. * Defines the callback to call when the observer is notified
  38200. */
  38201. callback: (eventData: T, eventState: EventState) => void,
  38202. /**
  38203. * Defines the mask of the observer (used to filter notifications)
  38204. */
  38205. mask: number,
  38206. /**
  38207. * Defines the current scope used to restore the JS context
  38208. */
  38209. scope?: any);
  38210. }
  38211. /**
  38212. * Represent a list of observers registered to multiple Observables object.
  38213. */
  38214. class MultiObserver<T> {
  38215. private _observers;
  38216. private _observables;
  38217. /**
  38218. * Release associated resources
  38219. */
  38220. dispose(): void;
  38221. /**
  38222. * Raise a callback when one of the observable will notify
  38223. * @param observables defines a list of observables to watch
  38224. * @param callback defines the callback to call on notification
  38225. * @param mask defines the mask used to filter notifications
  38226. * @param scope defines the current scope used to restore the JS context
  38227. * @returns the new MultiObserver
  38228. */
  38229. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38230. }
  38231. /**
  38232. * The Observable class is a simple implementation of the Observable pattern.
  38233. *
  38234. * 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.
  38235. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38236. * 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).
  38237. * 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.
  38238. */
  38239. class Observable<T> {
  38240. private _observers;
  38241. private _eventState;
  38242. private _onObserverAdded;
  38243. /**
  38244. * Creates a new observable
  38245. * @param onObserverAdded defines a callback to call when a new observer is added
  38246. */
  38247. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38248. /**
  38249. * Create a new Observer with the specified callback
  38250. * @param callback the callback that will be executed for that Observer
  38251. * @param mask the mask used to filter observers
  38252. * @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.
  38253. * @param scope optional scope for the callback to be called from
  38254. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38255. * @returns the new observer created for the callback
  38256. */
  38257. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38258. /**
  38259. * Create a new Observer with the specified callback and unregisters after the next notification
  38260. * @param callback the callback that will be executed for that Observer
  38261. * @returns the new observer created for the callback
  38262. */
  38263. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38264. /**
  38265. * Remove an Observer from the Observable object
  38266. * @param observer the instance of the Observer to remove
  38267. * @returns false if it doesn't belong to this Observable
  38268. */
  38269. remove(observer: Nullable<Observer<T>>): boolean;
  38270. /**
  38271. * Remove a callback from the Observable object
  38272. * @param callback the callback to remove
  38273. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38274. * @returns false if it doesn't belong to this Observable
  38275. */
  38276. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38277. private _deferUnregister;
  38278. private _remove;
  38279. /**
  38280. * Notify all Observers by calling their respective callback with the given data
  38281. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38282. * @param eventData defines the data to send to all observers
  38283. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38284. * @param target defines the original target of the state
  38285. * @param currentTarget defines the current target of the state
  38286. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38287. */
  38288. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38289. /**
  38290. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38291. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38292. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38293. * and it is crucial that all callbacks will be executed.
  38294. * The order of the callbacks is kept, callbacks are not executed parallel.
  38295. *
  38296. * @param eventData The data to be sent to each callback
  38297. * @param mask is used to filter observers defaults to -1
  38298. * @param target defines the callback target (see EventState)
  38299. * @param currentTarget defines he current object in the bubbling phase
  38300. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38301. */
  38302. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38303. /**
  38304. * Notify a specific observer
  38305. * @param observer defines the observer to notify
  38306. * @param eventData defines the data to be sent to each callback
  38307. * @param mask is used to filter observers defaults to -1
  38308. */
  38309. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38310. /**
  38311. * Gets a boolean indicating if the observable has at least one observer
  38312. * @returns true is the Observable has at least one Observer registered
  38313. */
  38314. hasObservers(): boolean;
  38315. /**
  38316. * Clear the list of observers
  38317. */
  38318. clear(): void;
  38319. /**
  38320. * Clone the current observable
  38321. * @returns a new observable
  38322. */
  38323. clone(): Observable<T>;
  38324. /**
  38325. * Does this observable handles observer registered with a given mask
  38326. * @param mask defines the mask to be tested
  38327. * @return whether or not one observer registered with the given mask is handeled
  38328. **/
  38329. hasSpecificMask(mask?: number): boolean;
  38330. }
  38331. }
  38332. declare module BABYLON {
  38333. /**
  38334. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38335. */
  38336. class PerformanceMonitor {
  38337. private _enabled;
  38338. private _rollingFrameTime;
  38339. private _lastFrameTimeMs;
  38340. /**
  38341. * constructor
  38342. * @param frameSampleSize The number of samples required to saturate the sliding window
  38343. */
  38344. constructor(frameSampleSize?: number);
  38345. /**
  38346. * Samples current frame
  38347. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38348. */
  38349. sampleFrame(timeMs?: number): void;
  38350. /**
  38351. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38352. */
  38353. readonly averageFrameTime: number;
  38354. /**
  38355. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38356. */
  38357. readonly averageFrameTimeVariance: number;
  38358. /**
  38359. * Returns the frame time of the most recent frame
  38360. */
  38361. readonly instantaneousFrameTime: number;
  38362. /**
  38363. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38364. */
  38365. readonly averageFPS: number;
  38366. /**
  38367. * Returns the average framerate in frames per second using the most recent frame time
  38368. */
  38369. readonly instantaneousFPS: number;
  38370. /**
  38371. * Returns true if enough samples have been taken to completely fill the sliding window
  38372. */
  38373. readonly isSaturated: boolean;
  38374. /**
  38375. * Enables contributions to the sliding window sample set
  38376. */
  38377. enable(): void;
  38378. /**
  38379. * Disables contributions to the sliding window sample set
  38380. * Samples will not be interpolated over the disabled period
  38381. */
  38382. disable(): void;
  38383. /**
  38384. * Returns true if sampling is enabled
  38385. */
  38386. readonly isEnabled: boolean;
  38387. /**
  38388. * Resets performance monitor
  38389. */
  38390. reset(): void;
  38391. }
  38392. /**
  38393. * RollingAverage
  38394. *
  38395. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38396. */
  38397. class RollingAverage {
  38398. /**
  38399. * Current average
  38400. */
  38401. average: number;
  38402. /**
  38403. * Current variance
  38404. */
  38405. variance: number;
  38406. protected _samples: Array<number>;
  38407. protected _sampleCount: number;
  38408. protected _pos: number;
  38409. protected _m2: number;
  38410. /**
  38411. * constructor
  38412. * @param length The number of samples required to saturate the sliding window
  38413. */
  38414. constructor(length: number);
  38415. /**
  38416. * Adds a sample to the sample set
  38417. * @param v The sample value
  38418. */
  38419. add(v: number): void;
  38420. /**
  38421. * Returns previously added values or null if outside of history or outside the sliding window domain
  38422. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38423. * @return Value previously recorded with add() or null if outside of range
  38424. */
  38425. history(i: number): number;
  38426. /**
  38427. * Returns true if enough samples have been taken to completely fill the sliding window
  38428. * @return true if sample-set saturated
  38429. */
  38430. isSaturated(): boolean;
  38431. /**
  38432. * Resets the rolling average (equivalent to 0 samples taken so far)
  38433. */
  38434. reset(): void;
  38435. /**
  38436. * Wraps a value around the sample range boundaries
  38437. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38438. * @return Wrapped position in sample range
  38439. */
  38440. protected _wrapPosition(i: number): number;
  38441. }
  38442. }
  38443. declare module BABYLON {
  38444. /**
  38445. * Helper class that provides a small promise polyfill
  38446. */
  38447. class PromisePolyfill {
  38448. /**
  38449. * Static function used to check if the polyfill is required
  38450. * If this is the case then the function will inject the polyfill to window.Promise
  38451. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38452. */
  38453. static Apply(force?: boolean): void;
  38454. }
  38455. }
  38456. declare module BABYLON {
  38457. /**
  38458. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38459. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38460. */
  38461. class SceneOptimization {
  38462. /**
  38463. * Defines the priority of this optimization (0 by default which means first in the list)
  38464. */
  38465. priority: number;
  38466. /**
  38467. * Gets a string describing the action executed by the current optimization
  38468. * @returns description string
  38469. */
  38470. getDescription(): string;
  38471. /**
  38472. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38473. * @param scene defines the current scene where to apply this optimization
  38474. * @param optimizer defines the current optimizer
  38475. * @returns true if everything that can be done was applied
  38476. */
  38477. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38478. /**
  38479. * Creates the SceneOptimization object
  38480. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38481. * @param desc defines the description associated with the optimization
  38482. */
  38483. constructor(
  38484. /**
  38485. * Defines the priority of this optimization (0 by default which means first in the list)
  38486. */
  38487. priority?: number);
  38488. }
  38489. /**
  38490. * Defines an optimization used to reduce the size of render target textures
  38491. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38492. */
  38493. class TextureOptimization extends SceneOptimization {
  38494. /**
  38495. * Defines the priority of this optimization (0 by default which means first in the list)
  38496. */
  38497. priority: number;
  38498. /**
  38499. * 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
  38500. */
  38501. maximumSize: number;
  38502. /**
  38503. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38504. */
  38505. step: number;
  38506. /**
  38507. * Gets a string describing the action executed by the current optimization
  38508. * @returns description string
  38509. */
  38510. getDescription(): string;
  38511. /**
  38512. * Creates the TextureOptimization object
  38513. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38514. * @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
  38515. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38516. */
  38517. constructor(
  38518. /**
  38519. * Defines the priority of this optimization (0 by default which means first in the list)
  38520. */
  38521. priority?: number,
  38522. /**
  38523. * 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
  38524. */
  38525. maximumSize?: number,
  38526. /**
  38527. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38528. */
  38529. step?: number);
  38530. /**
  38531. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38532. * @param scene defines the current scene where to apply this optimization
  38533. * @param optimizer defines the current optimizer
  38534. * @returns true if everything that can be done was applied
  38535. */
  38536. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38537. }
  38538. /**
  38539. * Defines an optimization used to increase or decrease the rendering resolution
  38540. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38541. */
  38542. class HardwareScalingOptimization extends SceneOptimization {
  38543. /**
  38544. * Defines the priority of this optimization (0 by default which means first in the list)
  38545. */
  38546. priority: number;
  38547. /**
  38548. * Defines the maximum scale to use (2 by default)
  38549. */
  38550. maximumScale: number;
  38551. /**
  38552. * Defines the step to use between two passes (0.5 by default)
  38553. */
  38554. step: number;
  38555. private _currentScale;
  38556. private _directionOffset;
  38557. /**
  38558. * Gets a string describing the action executed by the current optimization
  38559. * @return description string
  38560. */
  38561. getDescription(): string;
  38562. /**
  38563. * Creates the HardwareScalingOptimization object
  38564. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38565. * @param maximumScale defines the maximum scale to use (2 by default)
  38566. * @param step defines the step to use between two passes (0.5 by default)
  38567. */
  38568. constructor(
  38569. /**
  38570. * Defines the priority of this optimization (0 by default which means first in the list)
  38571. */
  38572. priority?: number,
  38573. /**
  38574. * Defines the maximum scale to use (2 by default)
  38575. */
  38576. maximumScale?: number,
  38577. /**
  38578. * Defines the step to use between two passes (0.5 by default)
  38579. */
  38580. step?: number);
  38581. /**
  38582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38583. * @param scene defines the current scene where to apply this optimization
  38584. * @param optimizer defines the current optimizer
  38585. * @returns true if everything that can be done was applied
  38586. */
  38587. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38588. }
  38589. /**
  38590. * Defines an optimization used to remove shadows
  38591. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38592. */
  38593. class ShadowsOptimization extends SceneOptimization {
  38594. /**
  38595. * Gets a string describing the action executed by the current optimization
  38596. * @return description string
  38597. */
  38598. getDescription(): string;
  38599. /**
  38600. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38601. * @param scene defines the current scene where to apply this optimization
  38602. * @param optimizer defines the current optimizer
  38603. * @returns true if everything that can be done was applied
  38604. */
  38605. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38606. }
  38607. /**
  38608. * Defines an optimization used to turn post-processes off
  38609. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38610. */
  38611. class PostProcessesOptimization extends SceneOptimization {
  38612. /**
  38613. * Gets a string describing the action executed by the current optimization
  38614. * @return description string
  38615. */
  38616. getDescription(): string;
  38617. /**
  38618. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38619. * @param scene defines the current scene where to apply this optimization
  38620. * @param optimizer defines the current optimizer
  38621. * @returns true if everything that can be done was applied
  38622. */
  38623. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38624. }
  38625. /**
  38626. * Defines an optimization used to turn lens flares off
  38627. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38628. */
  38629. class LensFlaresOptimization extends SceneOptimization {
  38630. /**
  38631. * Gets a string describing the action executed by the current optimization
  38632. * @return description string
  38633. */
  38634. getDescription(): string;
  38635. /**
  38636. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38637. * @param scene defines the current scene where to apply this optimization
  38638. * @param optimizer defines the current optimizer
  38639. * @returns true if everything that can be done was applied
  38640. */
  38641. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38642. }
  38643. /**
  38644. * Defines an optimization based on user defined callback.
  38645. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38646. */
  38647. class CustomOptimization extends SceneOptimization {
  38648. /**
  38649. * Callback called to apply the custom optimization.
  38650. */
  38651. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38652. /**
  38653. * Callback called to get custom description
  38654. */
  38655. onGetDescription: () => string;
  38656. /**
  38657. * Gets a string describing the action executed by the current optimization
  38658. * @returns description string
  38659. */
  38660. getDescription(): string;
  38661. /**
  38662. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38663. * @param scene defines the current scene where to apply this optimization
  38664. * @param optimizer defines the current optimizer
  38665. * @returns true if everything that can be done was applied
  38666. */
  38667. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38668. }
  38669. /**
  38670. * Defines an optimization used to turn particles off
  38671. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38672. */
  38673. class ParticlesOptimization extends SceneOptimization {
  38674. /**
  38675. * Gets a string describing the action executed by the current optimization
  38676. * @return description string
  38677. */
  38678. getDescription(): string;
  38679. /**
  38680. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38681. * @param scene defines the current scene where to apply this optimization
  38682. * @param optimizer defines the current optimizer
  38683. * @returns true if everything that can be done was applied
  38684. */
  38685. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38686. }
  38687. /**
  38688. * Defines an optimization used to turn render targets off
  38689. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38690. */
  38691. class RenderTargetsOptimization extends SceneOptimization {
  38692. /**
  38693. * Gets a string describing the action executed by the current optimization
  38694. * @return description string
  38695. */
  38696. getDescription(): string;
  38697. /**
  38698. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38699. * @param scene defines the current scene where to apply this optimization
  38700. * @param optimizer defines the current optimizer
  38701. * @returns true if everything that can be done was applied
  38702. */
  38703. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38704. }
  38705. /**
  38706. * Defines an optimization used to merge meshes with compatible materials
  38707. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38708. */
  38709. class MergeMeshesOptimization extends SceneOptimization {
  38710. private static _UpdateSelectionTree;
  38711. /**
  38712. * Gets or sets a boolean which defines if optimization octree has to be updated
  38713. */
  38714. /**
  38715. * Gets or sets a boolean which defines if optimization octree has to be updated
  38716. */
  38717. static UpdateSelectionTree: boolean;
  38718. /**
  38719. * Gets a string describing the action executed by the current optimization
  38720. * @return description string
  38721. */
  38722. getDescription(): string;
  38723. private _canBeMerged;
  38724. /**
  38725. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38726. * @param scene defines the current scene where to apply this optimization
  38727. * @param optimizer defines the current optimizer
  38728. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38729. * @returns true if everything that can be done was applied
  38730. */
  38731. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38732. }
  38733. /**
  38734. * Defines a list of options used by SceneOptimizer
  38735. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38736. */
  38737. class SceneOptimizerOptions {
  38738. /**
  38739. * Defines the target frame rate to reach (60 by default)
  38740. */
  38741. targetFrameRate: number;
  38742. /**
  38743. * Defines the interval between two checkes (2000ms by default)
  38744. */
  38745. trackerDuration: number;
  38746. /**
  38747. * Gets the list of optimizations to apply
  38748. */
  38749. optimizations: SceneOptimization[];
  38750. /**
  38751. * Creates a new list of options used by SceneOptimizer
  38752. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38753. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38754. */
  38755. constructor(
  38756. /**
  38757. * Defines the target frame rate to reach (60 by default)
  38758. */
  38759. targetFrameRate?: number,
  38760. /**
  38761. * Defines the interval between two checkes (2000ms by default)
  38762. */
  38763. trackerDuration?: number);
  38764. /**
  38765. * Add a new optimization
  38766. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38767. * @returns the current SceneOptimizerOptions
  38768. */
  38769. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38770. /**
  38771. * Add a new custom optimization
  38772. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38773. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38774. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38775. * @returns the current SceneOptimizerOptions
  38776. */
  38777. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38778. /**
  38779. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38780. * @param targetFrameRate defines the target frame rate (60 by default)
  38781. * @returns a SceneOptimizerOptions object
  38782. */
  38783. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38784. /**
  38785. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38786. * @param targetFrameRate defines the target frame rate (60 by default)
  38787. * @returns a SceneOptimizerOptions object
  38788. */
  38789. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38790. /**
  38791. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38792. * @param targetFrameRate defines the target frame rate (60 by default)
  38793. * @returns a SceneOptimizerOptions object
  38794. */
  38795. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38796. }
  38797. /**
  38798. * Class used to run optimizations in order to reach a target frame rate
  38799. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38800. */
  38801. class SceneOptimizer implements IDisposable {
  38802. private _isRunning;
  38803. private _options;
  38804. private _scene;
  38805. private _currentPriorityLevel;
  38806. private _targetFrameRate;
  38807. private _trackerDuration;
  38808. private _currentFrameRate;
  38809. private _sceneDisposeObserver;
  38810. private _improvementMode;
  38811. /**
  38812. * Defines an observable called when the optimizer reaches the target frame rate
  38813. */
  38814. onSuccessObservable: Observable<SceneOptimizer>;
  38815. /**
  38816. * Defines an observable called when the optimizer enables an optimization
  38817. */
  38818. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38819. /**
  38820. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38821. */
  38822. onFailureObservable: Observable<SceneOptimizer>;
  38823. /**
  38824. * Gets a boolean indicating if the optimizer is in improvement mode
  38825. */
  38826. readonly isInImprovementMode: boolean;
  38827. /**
  38828. * Gets the current priority level (0 at start)
  38829. */
  38830. readonly currentPriorityLevel: number;
  38831. /**
  38832. * Gets the current frame rate checked by the SceneOptimizer
  38833. */
  38834. readonly currentFrameRate: number;
  38835. /**
  38836. * Gets or sets the current target frame rate (60 by default)
  38837. */
  38838. /**
  38839. * Gets or sets the current target frame rate (60 by default)
  38840. */
  38841. targetFrameRate: number;
  38842. /**
  38843. * Gets or sets the current interval between two checks (every 2000ms by default)
  38844. */
  38845. /**
  38846. * Gets or sets the current interval between two checks (every 2000ms by default)
  38847. */
  38848. trackerDuration: number;
  38849. /**
  38850. * Gets the list of active optimizations
  38851. */
  38852. readonly optimizations: SceneOptimization[];
  38853. /**
  38854. * Creates a new SceneOptimizer
  38855. * @param scene defines the scene to work on
  38856. * @param options defines the options to use with the SceneOptimizer
  38857. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38858. * @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)
  38859. */
  38860. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38861. /**
  38862. * Stops the current optimizer
  38863. */
  38864. stop(): void;
  38865. /**
  38866. * Reset the optimizer to initial step (current priority level = 0)
  38867. */
  38868. reset(): void;
  38869. /**
  38870. * Start the optimizer. By default it will try to reach a specific framerate
  38871. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38872. */
  38873. start(): void;
  38874. private _checkCurrentState;
  38875. /**
  38876. * Release all resources
  38877. */
  38878. dispose(): void;
  38879. /**
  38880. * Helper function to create a SceneOptimizer with one single line of code
  38881. * @param scene defines the scene to work on
  38882. * @param options defines the options to use with the SceneOptimizer
  38883. * @param onSuccess defines a callback to call on success
  38884. * @param onFailure defines a callback to call on failure
  38885. * @returns the new SceneOptimizer object
  38886. */
  38887. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38888. }
  38889. }
  38890. declare module BABYLON {
  38891. /**
  38892. * Class used to serialize a scene into a string
  38893. */
  38894. class SceneSerializer {
  38895. /**
  38896. * Clear cache used by a previous serialization
  38897. */
  38898. static ClearCache(): void;
  38899. /**
  38900. * Serialize a scene into a JSON compatible object
  38901. * @param scene defines the scene to serialize
  38902. * @returns a JSON compatible object
  38903. */
  38904. static Serialize(scene: Scene): any;
  38905. /**
  38906. * Serialize a mesh into a JSON compatible object
  38907. * @param toSerialize defines the mesh to serialize
  38908. * @param withParents defines if parents must be serialized as well
  38909. * @param withChildren defines if children must be serialized as well
  38910. * @returns a JSON compatible object
  38911. */
  38912. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  38913. }
  38914. }
  38915. declare module BABYLON {
  38916. /**
  38917. * Defines an array and its length.
  38918. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  38919. */
  38920. interface ISmartArrayLike<T> {
  38921. /**
  38922. * The data of the array.
  38923. */
  38924. data: Array<T>;
  38925. /**
  38926. * The active length of the array.
  38927. */
  38928. length: number;
  38929. }
  38930. /**
  38931. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38932. */
  38933. class SmartArray<T> implements ISmartArrayLike<T> {
  38934. /**
  38935. * The full set of data from the array.
  38936. */
  38937. data: Array<T>;
  38938. /**
  38939. * The active length of the array.
  38940. */
  38941. length: number;
  38942. protected _id: number;
  38943. /**
  38944. * Instantiates a Smart Array.
  38945. * @param capacity defines the default capacity of the array.
  38946. */
  38947. constructor(capacity: number);
  38948. /**
  38949. * Pushes a value at the end of the active data.
  38950. * @param value defines the object to push in the array.
  38951. */
  38952. push(value: T): void;
  38953. /**
  38954. * Iterates over the active data and apply the lambda to them.
  38955. * @param func defines the action to apply on each value.
  38956. */
  38957. forEach(func: (content: T) => void): void;
  38958. /**
  38959. * Sorts the full sets of data.
  38960. * @param compareFn defines the comparison function to apply.
  38961. */
  38962. sort(compareFn: (a: T, b: T) => number): void;
  38963. /**
  38964. * Resets the active data to an empty array.
  38965. */
  38966. reset(): void;
  38967. /**
  38968. * Releases all the data from the array as well as the array.
  38969. */
  38970. dispose(): void;
  38971. /**
  38972. * Concats the active data with a given array.
  38973. * @param array defines the data to concatenate with.
  38974. */
  38975. concat(array: any): void;
  38976. /**
  38977. * Returns the position of a value in the active data.
  38978. * @param value defines the value to find the index for
  38979. * @returns the index if found in the active data otherwise -1
  38980. */
  38981. indexOf(value: T): number;
  38982. /**
  38983. * Returns whether an element is part of the active data.
  38984. * @param value defines the value to look for
  38985. * @returns true if found in the active data otherwise false
  38986. */
  38987. contains(value: T): boolean;
  38988. private static _GlobalId;
  38989. }
  38990. /**
  38991. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38992. * The data in this array can only be present once
  38993. */
  38994. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  38995. private _duplicateId;
  38996. /**
  38997. * Pushes a value at the end of the active data.
  38998. * THIS DOES NOT PREVENT DUPPLICATE DATA
  38999. * @param value defines the object to push in the array.
  39000. */
  39001. push(value: T): void;
  39002. /**
  39003. * Pushes a value at the end of the active data.
  39004. * If the data is already present, it won t be added again
  39005. * @param value defines the object to push in the array.
  39006. * @returns true if added false if it was already present
  39007. */
  39008. pushNoDuplicate(value: T): boolean;
  39009. /**
  39010. * Resets the active data to an empty array.
  39011. */
  39012. reset(): void;
  39013. /**
  39014. * Concats the active data with a given array.
  39015. * This ensures no dupplicate will be present in the result.
  39016. * @param array defines the data to concatenate with.
  39017. */
  39018. concatWithNoDuplicate(array: any): void;
  39019. }
  39020. }
  39021. declare module BABYLON {
  39022. /**
  39023. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39024. * The underlying implementation relies on an associative array to ensure the best performances.
  39025. * The value can be anything including 'null' but except 'undefined'
  39026. */
  39027. class StringDictionary<T> {
  39028. /**
  39029. * This will clear this dictionary and copy the content from the 'source' one.
  39030. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39031. * @param source the dictionary to take the content from and copy to this dictionary
  39032. */
  39033. copyFrom(source: StringDictionary<T>): void;
  39034. /**
  39035. * Get a value based from its key
  39036. * @param key the given key to get the matching value from
  39037. * @return the value if found, otherwise undefined is returned
  39038. */
  39039. get(key: string): T | undefined;
  39040. /**
  39041. * Get a value from its key or add it if it doesn't exist.
  39042. * This method will ensure you that a given key/data will be present in the dictionary.
  39043. * @param key the given key to get the matching value from
  39044. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39045. * The factory will only be invoked if there's no data for the given key.
  39046. * @return the value corresponding to the key.
  39047. */
  39048. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39049. /**
  39050. * Get a value from its key if present in the dictionary otherwise add it
  39051. * @param key the key to get the value from
  39052. * @param val if there's no such key/value pair in the dictionary add it with this value
  39053. * @return the value corresponding to the key
  39054. */
  39055. getOrAdd(key: string, val: T): T;
  39056. /**
  39057. * Check if there's a given key in the dictionary
  39058. * @param key the key to check for
  39059. * @return true if the key is present, false otherwise
  39060. */
  39061. contains(key: string): boolean;
  39062. /**
  39063. * Add a new key and its corresponding value
  39064. * @param key the key to add
  39065. * @param value the value corresponding to the key
  39066. * @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
  39067. */
  39068. add(key: string, value: T): boolean;
  39069. /**
  39070. * Update a specific value associated to a key
  39071. * @param key defines the key to use
  39072. * @param value defines the value to store
  39073. * @returns true if the value was updated (or false if the key was not found)
  39074. */
  39075. set(key: string, value: T): boolean;
  39076. /**
  39077. * Get the element of the given key and remove it from the dictionary
  39078. * @param key defines the key to search
  39079. * @returns the value associated with the key or null if not found
  39080. */
  39081. getAndRemove(key: string): Nullable<T>;
  39082. /**
  39083. * Remove a key/value from the dictionary.
  39084. * @param key the key to remove
  39085. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39086. */
  39087. remove(key: string): boolean;
  39088. /**
  39089. * Clear the whole content of the dictionary
  39090. */
  39091. clear(): void;
  39092. /**
  39093. * Gets the current count
  39094. */
  39095. readonly count: number;
  39096. /**
  39097. * Execute a callback on each key/val of the dictionary.
  39098. * Note that you can remove any element in this dictionary in the callback implementation
  39099. * @param callback the callback to execute on a given key/value pair
  39100. */
  39101. forEach(callback: (key: string, val: T) => void): void;
  39102. /**
  39103. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39104. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39105. * Note that you can remove any element in this dictionary in the callback implementation
  39106. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39107. * @returns the first item
  39108. */
  39109. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39110. private _count;
  39111. private _data;
  39112. }
  39113. }
  39114. declare module BABYLON {
  39115. /**
  39116. * Class used to store custom tags
  39117. */
  39118. class Tags {
  39119. /**
  39120. * Adds support for tags on the given object
  39121. * @param obj defines the object to use
  39122. */
  39123. static EnableFor(obj: any): void;
  39124. /**
  39125. * Removes tags support
  39126. * @param obj defines the object to use
  39127. */
  39128. static DisableFor(obj: any): void;
  39129. /**
  39130. * Gets a boolean indicating if the given object has tags
  39131. * @param obj defines the object to use
  39132. * @returns a boolean
  39133. */
  39134. static HasTags(obj: any): boolean;
  39135. /**
  39136. * Gets the tags available on a given object
  39137. * @param obj defines the object to use
  39138. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39139. * @returns the tags
  39140. */
  39141. static GetTags(obj: any, asString?: boolean): any;
  39142. /**
  39143. * Adds tags to an object
  39144. * @param obj defines the object to use
  39145. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39146. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39147. */
  39148. static AddTagsTo(obj: any, tagsString: string): void;
  39149. /**
  39150. * @hidden
  39151. */
  39152. static _AddTagTo(obj: any, tag: string): void;
  39153. /**
  39154. * Removes specific tags from a specific object
  39155. * @param obj defines the object to use
  39156. * @param tagsString defines the tags to remove
  39157. */
  39158. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39159. /**
  39160. * @hidden
  39161. */
  39162. static _RemoveTagFrom(obj: any, tag: string): void;
  39163. /**
  39164. * Defines if tags hosted on an object match a given query
  39165. * @param obj defines the object to use
  39166. * @param tagsQuery defines the tag query
  39167. * @returns a boolean
  39168. */
  39169. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39170. }
  39171. }
  39172. declare module BABYLON {
  39173. /**
  39174. * Class used to host texture specific utilities
  39175. */
  39176. class TextureTools {
  39177. /**
  39178. * Uses the GPU to create a copy texture rescaled at a given size
  39179. * @param texture Texture to copy from
  39180. * @param width defines the desired width
  39181. * @param height defines the desired height
  39182. * @param useBilinearMode defines if bilinear mode has to be used
  39183. * @return the generated texture
  39184. */
  39185. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39186. /**
  39187. * Gets an environment BRDF texture for a given scene
  39188. * @param scene defines the hosting scene
  39189. * @returns the environment BRDF texture
  39190. */
  39191. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39192. private static _environmentBRDFBase64Texture;
  39193. }
  39194. }
  39195. declare module BABYLON {
  39196. /**
  39197. * Based on jsTGALoader - Javascript loader for TGA file
  39198. * By Vincent Thibault
  39199. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39200. */
  39201. class TGATools {
  39202. private static _TYPE_INDEXED;
  39203. private static _TYPE_RGB;
  39204. private static _TYPE_GREY;
  39205. private static _TYPE_RLE_INDEXED;
  39206. private static _TYPE_RLE_RGB;
  39207. private static _TYPE_RLE_GREY;
  39208. private static _ORIGIN_MASK;
  39209. private static _ORIGIN_SHIFT;
  39210. private static _ORIGIN_BL;
  39211. private static _ORIGIN_BR;
  39212. private static _ORIGIN_UL;
  39213. private static _ORIGIN_UR;
  39214. /**
  39215. * Gets the header of a TGA file
  39216. * @param data defines the TGA data
  39217. * @returns the header
  39218. */
  39219. static GetTGAHeader(data: Uint8Array): any;
  39220. /**
  39221. * Uploads TGA content to a Babylon Texture
  39222. * @hidden
  39223. */
  39224. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39225. /** @hidden */
  39226. 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;
  39227. /** @hidden */
  39228. 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;
  39229. /** @hidden */
  39230. 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;
  39231. /** @hidden */
  39232. 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;
  39233. /** @hidden */
  39234. 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;
  39235. /** @hidden */
  39236. 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;
  39237. }
  39238. }
  39239. declare module BABYLON {
  39240. /**
  39241. * Interface for any object that can request an animation frame
  39242. */
  39243. interface ICustomAnimationFrameRequester {
  39244. /**
  39245. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39246. */
  39247. renderFunction?: Function;
  39248. /**
  39249. * Called to request the next frame to render to
  39250. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39251. */
  39252. requestAnimationFrame: Function;
  39253. /**
  39254. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39255. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39256. */
  39257. requestID?: number;
  39258. }
  39259. /**
  39260. * Interface containing an array of animations
  39261. */
  39262. interface IAnimatable {
  39263. /**
  39264. * Array of animations
  39265. */
  39266. animations: Array<Animation>;
  39267. }
  39268. /** Interface used by value gradients (color, factor, ...) */
  39269. interface IValueGradient {
  39270. /**
  39271. * Gets or sets the gradient value (between 0 and 1)
  39272. */
  39273. gradient: number;
  39274. }
  39275. /** Class used to store color4 gradient */
  39276. class ColorGradient implements IValueGradient {
  39277. /**
  39278. * Gets or sets the gradient value (between 0 and 1)
  39279. */
  39280. gradient: number;
  39281. /**
  39282. * Gets or sets first associated color
  39283. */
  39284. color1: Color4;
  39285. /**
  39286. * Gets or sets second associated color
  39287. */
  39288. color2?: Color4;
  39289. /**
  39290. * Will get a color picked randomly between color1 and color2.
  39291. * If color2 is undefined then color1 will be used
  39292. * @param result defines the target Color4 to store the result in
  39293. */
  39294. getColorToRef(result: Color4): void;
  39295. }
  39296. /** Class used to store color 3 gradient */
  39297. class Color3Gradient implements IValueGradient {
  39298. /**
  39299. * Gets or sets the gradient value (between 0 and 1)
  39300. */
  39301. gradient: number;
  39302. /**
  39303. * Gets or sets the associated color
  39304. */
  39305. color: Color3;
  39306. }
  39307. /** Class used to store factor gradient */
  39308. class FactorGradient implements IValueGradient {
  39309. /**
  39310. * Gets or sets the gradient value (between 0 and 1)
  39311. */
  39312. gradient: number;
  39313. /**
  39314. * Gets or sets first associated factor
  39315. */
  39316. factor1: number;
  39317. /**
  39318. * Gets or sets second associated factor
  39319. */
  39320. factor2?: number;
  39321. /**
  39322. * Will get a number picked randomly between factor1 and factor2.
  39323. * If factor2 is undefined then factor1 will be used
  39324. * @returns the picked number
  39325. */
  39326. getFactor(): number;
  39327. }
  39328. /**
  39329. * @ignore
  39330. * Application error to support additional information when loading a file
  39331. */
  39332. class LoadFileError extends Error {
  39333. /** defines the optional XHR request */
  39334. request?: XMLHttpRequest | undefined;
  39335. private static _setPrototypeOf;
  39336. /**
  39337. * Creates a new LoadFileError
  39338. * @param message defines the message of the error
  39339. * @param request defines the optional XHR request
  39340. */
  39341. constructor(message: string,
  39342. /** defines the optional XHR request */
  39343. request?: XMLHttpRequest | undefined);
  39344. }
  39345. /**
  39346. * Class used to define a retry strategy when error happens while loading assets
  39347. */
  39348. class RetryStrategy {
  39349. /**
  39350. * Function used to defines an exponential back off strategy
  39351. * @param maxRetries defines the maximum number of retries (3 by default)
  39352. * @param baseInterval defines the interval between retries
  39353. * @returns the strategy function to use
  39354. */
  39355. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39356. }
  39357. /**
  39358. * File request interface
  39359. */
  39360. interface IFileRequest {
  39361. /**
  39362. * Raised when the request is complete (success or error).
  39363. */
  39364. onCompleteObservable: Observable<IFileRequest>;
  39365. /**
  39366. * Aborts the request for a file.
  39367. */
  39368. abort: () => void;
  39369. }
  39370. /**
  39371. * Class containing a set of static utilities functions
  39372. */
  39373. class Tools {
  39374. /**
  39375. * Gets or sets the base URL to use to load assets
  39376. */
  39377. static BaseUrl: string;
  39378. /**
  39379. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39380. */
  39381. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39382. /**
  39383. * Default behaviour for cors in the application.
  39384. * It can be a string if the expected behavior is identical in the entire app.
  39385. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39386. */
  39387. static CorsBehavior: string | ((url: string | string[]) => string);
  39388. /**
  39389. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39390. * @ignorenaming
  39391. */
  39392. static UseFallbackTexture: boolean;
  39393. /**
  39394. * Use this object to register external classes like custom textures or material
  39395. * to allow the laoders to instantiate them
  39396. */
  39397. static RegisteredExternalClasses: {
  39398. [key: string]: Object;
  39399. };
  39400. /**
  39401. * Texture content used if a texture cannot loaded
  39402. * @ignorenaming
  39403. */
  39404. static fallbackTexture: string;
  39405. /**
  39406. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39407. * @param u defines the coordinate on X axis
  39408. * @param v defines the coordinate on Y axis
  39409. * @param width defines the width of the source data
  39410. * @param height defines the height of the source data
  39411. * @param pixels defines the source byte array
  39412. * @param color defines the output color
  39413. */
  39414. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39415. /**
  39416. * Interpolates between a and b via alpha
  39417. * @param a The lower value (returned when alpha = 0)
  39418. * @param b The upper value (returned when alpha = 1)
  39419. * @param alpha The interpolation-factor
  39420. * @return The mixed value
  39421. */
  39422. static Mix(a: number, b: number, alpha: number): number;
  39423. /**
  39424. * Tries to instantiate a new object from a given class name
  39425. * @param className defines the class name to instantiate
  39426. * @returns the new object or null if the system was not able to do the instantiation
  39427. */
  39428. static Instantiate(className: string): any;
  39429. /**
  39430. * Provides a slice function that will work even on IE
  39431. * @param data defines the array to slice
  39432. * @param start defines the start of the data (optional)
  39433. * @param end defines the end of the data (optional)
  39434. * @returns the new sliced array
  39435. */
  39436. static Slice<T>(data: T, start?: number, end?: number): T;
  39437. /**
  39438. * Polyfill for setImmediate
  39439. * @param action defines the action to execute after the current execution block
  39440. */
  39441. static SetImmediate(action: () => void): void;
  39442. /**
  39443. * Function indicating if a number is an exponent of 2
  39444. * @param value defines the value to test
  39445. * @returns true if the value is an exponent of 2
  39446. */
  39447. static IsExponentOfTwo(value: number): boolean;
  39448. private static _tmpFloatArray;
  39449. /**
  39450. * Returns the nearest 32-bit single precision float representation of a Number
  39451. * @param value A Number. If the parameter is of a different type, it will get converted
  39452. * to a number or to NaN if it cannot be converted
  39453. * @returns number
  39454. */
  39455. static FloatRound(value: number): number;
  39456. /**
  39457. * Find the next highest power of two.
  39458. * @param x Number to start search from.
  39459. * @return Next highest power of two.
  39460. */
  39461. static CeilingPOT(x: number): number;
  39462. /**
  39463. * Find the next lowest power of two.
  39464. * @param x Number to start search from.
  39465. * @return Next lowest power of two.
  39466. */
  39467. static FloorPOT(x: number): number;
  39468. /**
  39469. * Find the nearest power of two.
  39470. * @param x Number to start search from.
  39471. * @return Next nearest power of two.
  39472. */
  39473. static NearestPOT(x: number): number;
  39474. /**
  39475. * Get the closest exponent of two
  39476. * @param value defines the value to approximate
  39477. * @param max defines the maximum value to return
  39478. * @param mode defines how to define the closest value
  39479. * @returns closest exponent of two of the given value
  39480. */
  39481. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39482. /**
  39483. * Extracts the filename from a path
  39484. * @param path defines the path to use
  39485. * @returns the filename
  39486. */
  39487. static GetFilename(path: string): string;
  39488. /**
  39489. * Extracts the "folder" part of a path (everything before the filename).
  39490. * @param uri The URI to extract the info from
  39491. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39492. * @returns The "folder" part of the path
  39493. */
  39494. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39495. /**
  39496. * Extracts text content from a DOM element hierarchy
  39497. * @param element defines the root element
  39498. * @returns a string
  39499. */
  39500. static GetDOMTextContent(element: HTMLElement): string;
  39501. /**
  39502. * Convert an angle in radians to degrees
  39503. * @param angle defines the angle to convert
  39504. * @returns the angle in degrees
  39505. */
  39506. static ToDegrees(angle: number): number;
  39507. /**
  39508. * Convert an angle in degrees to radians
  39509. * @param angle defines the angle to convert
  39510. * @returns the angle in radians
  39511. */
  39512. static ToRadians(angle: number): number;
  39513. /**
  39514. * Encode a buffer to a base64 string
  39515. * @param buffer defines the buffer to encode
  39516. * @returns the encoded string
  39517. */
  39518. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39519. /**
  39520. * Extracts minimum and maximum values from a list of indexed positions
  39521. * @param positions defines the positions to use
  39522. * @param indices defines the indices to the positions
  39523. * @param indexStart defines the start index
  39524. * @param indexCount defines the end index
  39525. * @param bias defines bias value to add to the result
  39526. * @return minimum and maximum values
  39527. */
  39528. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39529. minimum: Vector3;
  39530. maximum: Vector3;
  39531. };
  39532. /**
  39533. * Extracts minimum and maximum values from a list of positions
  39534. * @param positions defines the positions to use
  39535. * @param start defines the start index in the positions array
  39536. * @param count defines the number of positions to handle
  39537. * @param bias defines bias value to add to the result
  39538. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39539. * @return minimum and maximum values
  39540. */
  39541. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39542. minimum: Vector3;
  39543. maximum: Vector3;
  39544. };
  39545. /**
  39546. * Returns an array if obj is not an array
  39547. * @param obj defines the object to evaluate as an array
  39548. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39549. * @returns either obj directly if obj is an array or a new array containing obj
  39550. */
  39551. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39552. /**
  39553. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39554. * @param size the number of element to construct and put in the array
  39555. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39556. * @returns a new array filled with new objects
  39557. */
  39558. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39559. /**
  39560. * Gets the pointer prefix to use
  39561. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39562. */
  39563. static GetPointerPrefix(): string;
  39564. /**
  39565. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39566. * @param func - the function to be called
  39567. * @param requester - the object that will request the next frame. Falls back to window.
  39568. * @returns frame number
  39569. */
  39570. static QueueNewFrame(func: () => void, requester?: any): number;
  39571. /**
  39572. * Ask the browser to promote the current element to fullscreen rendering mode
  39573. * @param element defines the DOM element to promote
  39574. */
  39575. static RequestFullscreen(element: HTMLElement): void;
  39576. /**
  39577. * Asks the browser to exit fullscreen mode
  39578. */
  39579. static ExitFullscreen(): void;
  39580. /**
  39581. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39582. * @param url define the url we are trying
  39583. * @param element define the dom element where to configure the cors policy
  39584. */
  39585. static SetCorsBehavior(url: string | string[], element: {
  39586. crossOrigin: string | null;
  39587. }): void;
  39588. /**
  39589. * Removes unwanted characters from an url
  39590. * @param url defines the url to clean
  39591. * @returns the cleaned url
  39592. */
  39593. static CleanUrl(url: string): string;
  39594. /**
  39595. * Gets or sets a function used to pre-process url before using them to load assets
  39596. */
  39597. static PreprocessUrl: (url: string) => string;
  39598. /**
  39599. * Loads an image as an HTMLImageElement.
  39600. * @param input url string, ArrayBuffer, or Blob to load
  39601. * @param onLoad callback called when the image successfully loads
  39602. * @param onError callback called when the image fails to load
  39603. * @param offlineProvider offline provider for caching
  39604. * @returns the HTMLImageElement of the loaded image
  39605. */
  39606. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39607. /**
  39608. * Loads a file
  39609. * @param url url string, ArrayBuffer, or Blob to load
  39610. * @param onSuccess callback called when the file successfully loads
  39611. * @param onProgress callback called while file is loading (if the server supports this mode)
  39612. * @param offlineProvider defines the offline provider for caching
  39613. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39614. * @param onError callback called when the file fails to load
  39615. * @returns a file request object
  39616. */
  39617. 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;
  39618. /**
  39619. * Load a script (identified by an url). When the url returns, the
  39620. * content of this file is added into a new script element, attached to the DOM (body element)
  39621. * @param scriptUrl defines the url of the script to laod
  39622. * @param onSuccess defines the callback called when the script is loaded
  39623. * @param onError defines the callback to call if an error occurs
  39624. */
  39625. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39626. /**
  39627. * Loads a file from a blob
  39628. * @param fileToLoad defines the blob to use
  39629. * @param callback defines the callback to call when data is loaded
  39630. * @param progressCallback defines the callback to call during loading process
  39631. * @returns a file request object
  39632. */
  39633. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39634. /**
  39635. * Loads a file
  39636. * @param fileToLoad defines the file to load
  39637. * @param callback defines the callback to call when data is loaded
  39638. * @param progressCallBack defines the callback to call during loading process
  39639. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39640. * @returns a file request object
  39641. */
  39642. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39643. /**
  39644. * Creates a data url from a given string content
  39645. * @param content defines the content to convert
  39646. * @returns the new data url link
  39647. */
  39648. static FileAsURL(content: string): string;
  39649. /**
  39650. * Format the given number to a specific decimal format
  39651. * @param value defines the number to format
  39652. * @param decimals defines the number of decimals to use
  39653. * @returns the formatted string
  39654. */
  39655. static Format(value: number, decimals?: number): string;
  39656. /**
  39657. * Checks if a given vector is inside a specific range
  39658. * @param v defines the vector to test
  39659. * @param min defines the minimum range
  39660. * @param max defines the maximum range
  39661. */
  39662. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39663. /**
  39664. * Tries to copy an object by duplicating every property
  39665. * @param source defines the source object
  39666. * @param destination defines the target object
  39667. * @param doNotCopyList defines a list of properties to avoid
  39668. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39669. */
  39670. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39671. /**
  39672. * Gets a boolean indicating if the given object has no own property
  39673. * @param obj defines the object to test
  39674. * @returns true if object has no own property
  39675. */
  39676. static IsEmpty(obj: any): boolean;
  39677. /**
  39678. * Function used to register events at window level
  39679. * @param events defines the events to register
  39680. */
  39681. static RegisterTopRootEvents(events: {
  39682. name: string;
  39683. handler: Nullable<(e: FocusEvent) => any>;
  39684. }[]): void;
  39685. /**
  39686. * Function used to unregister events from window level
  39687. * @param events defines the events to unregister
  39688. */
  39689. static UnregisterTopRootEvents(events: {
  39690. name: string;
  39691. handler: Nullable<(e: FocusEvent) => any>;
  39692. }[]): void;
  39693. /**
  39694. * Dumps the current bound framebuffer
  39695. * @param width defines the rendering width
  39696. * @param height defines the rendering height
  39697. * @param engine defines the hosting engine
  39698. * @param successCallback defines the callback triggered once the data are available
  39699. * @param mimeType defines the mime type of the result
  39700. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39701. */
  39702. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39703. /**
  39704. * Converts the canvas data to blob.
  39705. * This acts as a polyfill for browsers not supporting the to blob function.
  39706. * @param canvas Defines the canvas to extract the data from
  39707. * @param successCallback Defines the callback triggered once the data are available
  39708. * @param mimeType Defines the mime type of the result
  39709. */
  39710. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39711. /**
  39712. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39713. * @param successCallback defines the callback triggered once the data are available
  39714. * @param mimeType defines the mime type of the result
  39715. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39716. */
  39717. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39718. /**
  39719. * Downloads a blob in the browser
  39720. * @param blob defines the blob to download
  39721. * @param fileName defines the name of the downloaded file
  39722. */
  39723. static Download(blob: Blob, fileName: string): void;
  39724. /**
  39725. * Captures a screenshot of the current rendering
  39726. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39727. * @param engine defines the rendering engine
  39728. * @param camera defines the source camera
  39729. * @param size This parameter can be set to a single number or to an object with the
  39730. * following (optional) properties: precision, width, height. If a single number is passed,
  39731. * it will be used for both width and height. If an object is passed, the screenshot size
  39732. * will be derived from the parameters. The precision property is a multiplier allowing
  39733. * rendering at a higher or lower resolution
  39734. * @param successCallback defines the callback receives a single parameter which contains the
  39735. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39736. * src parameter of an <img> to display it
  39737. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39738. * Check your browser for supported MIME types
  39739. */
  39740. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39741. /**
  39742. * Generates an image screenshot from the specified camera.
  39743. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39744. * @param engine The engine to use for rendering
  39745. * @param camera The camera to use for rendering
  39746. * @param size This parameter can be set to a single number or to an object with the
  39747. * following (optional) properties: precision, width, height. If a single number is passed,
  39748. * it will be used for both width and height. If an object is passed, the screenshot size
  39749. * will be derived from the parameters. The precision property is a multiplier allowing
  39750. * rendering at a higher or lower resolution
  39751. * @param successCallback The callback receives a single parameter which contains the
  39752. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39753. * src parameter of an <img> to display it
  39754. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39755. * Check your browser for supported MIME types
  39756. * @param samples Texture samples (default: 1)
  39757. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39758. * @param fileName A name for for the downloaded file.
  39759. */
  39760. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39761. /**
  39762. * Validates if xhr data is correct
  39763. * @param xhr defines the request to validate
  39764. * @param dataType defines the expected data type
  39765. * @returns true if data is correct
  39766. */
  39767. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39768. /**
  39769. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39770. * Be aware Math.random() could cause collisions, but:
  39771. * "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"
  39772. * @returns a pseudo random id
  39773. */
  39774. static RandomId(): string;
  39775. /**
  39776. * Test if the given uri is a base64 string
  39777. * @param uri The uri to test
  39778. * @return True if the uri is a base64 string or false otherwise
  39779. */
  39780. static IsBase64(uri: string): boolean;
  39781. /**
  39782. * Decode the given base64 uri.
  39783. * @param uri The uri to decode
  39784. * @return The decoded base64 data.
  39785. */
  39786. static DecodeBase64(uri: string): ArrayBuffer;
  39787. /**
  39788. * No log
  39789. */
  39790. static readonly NoneLogLevel: number;
  39791. /**
  39792. * Only message logs
  39793. */
  39794. static readonly MessageLogLevel: number;
  39795. /**
  39796. * Only warning logs
  39797. */
  39798. static readonly WarningLogLevel: number;
  39799. /**
  39800. * Only error logs
  39801. */
  39802. static readonly ErrorLogLevel: number;
  39803. /**
  39804. * All logs
  39805. */
  39806. static readonly AllLogLevel: number;
  39807. private static _LogCache;
  39808. /**
  39809. * Gets a value indicating the number of loading errors
  39810. * @ignorenaming
  39811. */
  39812. static errorsCount: number;
  39813. /**
  39814. * Callback called when a new log is added
  39815. */
  39816. static OnNewCacheEntry: (entry: string) => void;
  39817. private static _AddLogEntry;
  39818. private static _FormatMessage;
  39819. private static _LogDisabled;
  39820. private static _LogEnabled;
  39821. private static _WarnDisabled;
  39822. private static _WarnEnabled;
  39823. private static _ErrorDisabled;
  39824. private static _ErrorEnabled;
  39825. /**
  39826. * Log a message to the console
  39827. */
  39828. static Log: (message: string) => void;
  39829. /**
  39830. * Write a warning message to the console
  39831. */
  39832. static Warn: (message: string) => void;
  39833. /**
  39834. * Write an error message to the console
  39835. */
  39836. static Error: (message: string) => void;
  39837. /**
  39838. * Gets current log cache (list of logs)
  39839. */
  39840. static readonly LogCache: string;
  39841. /**
  39842. * Clears the log cache
  39843. */
  39844. static ClearLogCache(): void;
  39845. /**
  39846. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39847. */
  39848. static LogLevels: number;
  39849. /**
  39850. * Checks if the loaded document was accessed via `file:`-Protocol.
  39851. * @returns boolean
  39852. */
  39853. static IsFileURL(): boolean;
  39854. /**
  39855. * Checks if the window object exists
  39856. * @returns true if the window object exists
  39857. */
  39858. static IsWindowObjectExist(): boolean;
  39859. /**
  39860. * No performance log
  39861. */
  39862. static readonly PerformanceNoneLogLevel: number;
  39863. /**
  39864. * Use user marks to log performance
  39865. */
  39866. static readonly PerformanceUserMarkLogLevel: number;
  39867. /**
  39868. * Log performance to the console
  39869. */
  39870. static readonly PerformanceConsoleLogLevel: number;
  39871. private static _performance;
  39872. /**
  39873. * Sets the current performance log level
  39874. */
  39875. static PerformanceLogLevel: number;
  39876. private static _StartPerformanceCounterDisabled;
  39877. private static _EndPerformanceCounterDisabled;
  39878. private static _StartUserMark;
  39879. private static _EndUserMark;
  39880. private static _StartPerformanceConsole;
  39881. private static _EndPerformanceConsole;
  39882. /**
  39883. * Starts a performance counter
  39884. */
  39885. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39886. /**
  39887. * Ends a specific performance coutner
  39888. */
  39889. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39890. /**
  39891. * Gets either window.performance.now() if supported or Date.now() else
  39892. */
  39893. static readonly Now: number;
  39894. /**
  39895. * This method will return the name of the class used to create the instance of the given object.
  39896. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39897. * @param object the object to get the class name from
  39898. * @param isType defines if the object is actually a type
  39899. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39900. */
  39901. static GetClassName(object: any, isType?: boolean): string;
  39902. /**
  39903. * Gets the first element of an array satisfying a given predicate
  39904. * @param array defines the array to browse
  39905. * @param predicate defines the predicate to use
  39906. * @returns null if not found or the element
  39907. */
  39908. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39909. /**
  39910. * This method will return the name of the full name of the class, including its owning module (if any).
  39911. * 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).
  39912. * @param object the object to get the class name from
  39913. * @param isType defines if the object is actually a type
  39914. * @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.
  39915. * @ignorenaming
  39916. */
  39917. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39918. /**
  39919. * Returns a promise that resolves after the given amount of time.
  39920. * @param delay Number of milliseconds to delay
  39921. * @returns Promise that resolves after the given amount of time
  39922. */
  39923. static DelayAsync(delay: number): Promise<void>;
  39924. /**
  39925. * Gets the current gradient from an array of IValueGradient
  39926. * @param ratio defines the current ratio to get
  39927. * @param gradients defines the array of IValueGradient
  39928. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  39929. */
  39930. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  39931. }
  39932. /**
  39933. * This class is used to track a performance counter which is number based.
  39934. * The user has access to many properties which give statistics of different nature.
  39935. *
  39936. * The implementer can track two kinds of Performance Counter: time and count.
  39937. * 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.
  39938. * 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.
  39939. */
  39940. class PerfCounter {
  39941. /**
  39942. * Gets or sets a global boolean to turn on and off all the counters
  39943. */
  39944. static Enabled: boolean;
  39945. /**
  39946. * Returns the smallest value ever
  39947. */
  39948. readonly min: number;
  39949. /**
  39950. * Returns the biggest value ever
  39951. */
  39952. readonly max: number;
  39953. /**
  39954. * Returns the average value since the performance counter is running
  39955. */
  39956. readonly average: number;
  39957. /**
  39958. * Returns the average value of the last second the counter was monitored
  39959. */
  39960. readonly lastSecAverage: number;
  39961. /**
  39962. * Returns the current value
  39963. */
  39964. readonly current: number;
  39965. /**
  39966. * Gets the accumulated total
  39967. */
  39968. readonly total: number;
  39969. /**
  39970. * Gets the total value count
  39971. */
  39972. readonly count: number;
  39973. /**
  39974. * Creates a new counter
  39975. */
  39976. constructor();
  39977. /**
  39978. * Call this method to start monitoring a new frame.
  39979. * 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.
  39980. */
  39981. fetchNewFrame(): void;
  39982. /**
  39983. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  39984. * @param newCount the count value to add to the monitored count
  39985. * @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.
  39986. */
  39987. addCount(newCount: number, fetchResult: boolean): void;
  39988. /**
  39989. * Start monitoring this performance counter
  39990. */
  39991. beginMonitoring(): void;
  39992. /**
  39993. * Compute the time lapsed since the previous beginMonitoring() call.
  39994. * @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
  39995. */
  39996. endMonitoring(newFrame?: boolean): void;
  39997. private _fetchResult;
  39998. private _startMonitoringTime;
  39999. private _min;
  40000. private _max;
  40001. private _average;
  40002. private _current;
  40003. private _totalValueCount;
  40004. private _totalAccumulated;
  40005. private _lastSecAverage;
  40006. private _lastSecAccumulated;
  40007. private _lastSecTime;
  40008. private _lastSecValueCount;
  40009. }
  40010. /**
  40011. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40012. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40013. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40014. * @param name The name of the class, case should be preserved
  40015. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40016. */
  40017. function className(name: string, module?: string): (target: Object) => void;
  40018. /**
  40019. * An implementation of a loop for asynchronous functions.
  40020. */
  40021. class AsyncLoop {
  40022. /**
  40023. * Defines the number of iterations for the loop
  40024. */
  40025. iterations: number;
  40026. /**
  40027. * Defines the current index of the loop.
  40028. */
  40029. index: number;
  40030. private _done;
  40031. private _fn;
  40032. private _successCallback;
  40033. /**
  40034. * Constructor.
  40035. * @param iterations the number of iterations.
  40036. * @param func the function to run each iteration
  40037. * @param successCallback the callback that will be called upon succesful execution
  40038. * @param offset starting offset.
  40039. */
  40040. constructor(
  40041. /**
  40042. * Defines the number of iterations for the loop
  40043. */
  40044. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40045. /**
  40046. * Execute the next iteration. Must be called after the last iteration was finished.
  40047. */
  40048. executeNext(): void;
  40049. /**
  40050. * Break the loop and run the success callback.
  40051. */
  40052. breakLoop(): void;
  40053. /**
  40054. * Create and run an async loop.
  40055. * @param iterations the number of iterations.
  40056. * @param fn the function to run each iteration
  40057. * @param successCallback the callback that will be called upon succesful execution
  40058. * @param offset starting offset.
  40059. * @returns the created async loop object
  40060. */
  40061. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40062. /**
  40063. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40064. * @param iterations total number of iterations
  40065. * @param syncedIterations number of synchronous iterations in each async iteration.
  40066. * @param fn the function to call each iteration.
  40067. * @param callback a success call back that will be called when iterating stops.
  40068. * @param breakFunction a break condition (optional)
  40069. * @param timeout timeout settings for the setTimeout function. default - 0.
  40070. * @returns the created async loop object
  40071. */
  40072. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40073. }
  40074. }
  40075. interface HTMLCanvasElement {
  40076. /** Track wether a record is in progress */
  40077. isRecording: boolean;
  40078. /** Capture Stream method defined by some browsers */
  40079. captureStream(fps?: number): MediaStream;
  40080. }
  40081. interface MediaRecorder {
  40082. /** Starts recording */
  40083. start(timeSlice: number): void;
  40084. /** Stops recording */
  40085. stop(): void;
  40086. /** Event raised when an error arised. */
  40087. onerror: (event: ErrorEvent) => void;
  40088. /** Event raised when the recording stops. */
  40089. onstop: (event: Event) => void;
  40090. /** Event raised when a new chunk of data is available and should be tracked. */
  40091. ondataavailable: (event: Event) => void;
  40092. }
  40093. interface MediaRecorderOptions {
  40094. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40095. mimeType?: string;
  40096. /** The chosen bitrate for the audio component of the media. */
  40097. audioBitsPerSecond?: number;
  40098. /** The chosen bitrate for the video component of the media. */
  40099. videoBitsPerSecond?: number;
  40100. /** 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. */
  40101. bitsPerSecond?: number;
  40102. }
  40103. interface MediaRecorderConstructor {
  40104. /**
  40105. * A reference to the prototype.
  40106. */
  40107. readonly prototype: MediaRecorder;
  40108. /**
  40109. * Creates a new MediaRecorder.
  40110. * @param stream Defines the stream to record.
  40111. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40112. */
  40113. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40114. }
  40115. /**
  40116. * MediaRecoreder object available in some browsers.
  40117. */
  40118. declare var MediaRecorder: MediaRecorderConstructor;
  40119. declare module BABYLON {
  40120. /**
  40121. * This represents the different options avilable for the video capture.
  40122. */
  40123. interface VideoRecorderOptions {
  40124. /** Defines the mime type of the video */
  40125. mimeType: string;
  40126. /** Defines the video the video should be recorded at */
  40127. fps: number;
  40128. /** Defines the chunk size for the recording data */
  40129. recordChunckSize: number;
  40130. }
  40131. /**
  40132. * This can helps recording videos from BabylonJS.
  40133. * This is based on the available WebRTC functionalities of the browser.
  40134. *
  40135. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40136. */
  40137. class VideoRecorder {
  40138. private static readonly _defaultOptions;
  40139. /**
  40140. * Returns wehther or not the VideoRecorder is available in your browser.
  40141. * @param engine Defines the Babylon Engine to check the support for
  40142. * @returns true if supported otherwise false
  40143. */
  40144. static IsSupported(engine: Engine): boolean;
  40145. private readonly _options;
  40146. private _canvas;
  40147. private _mediaRecorder;
  40148. private _recordedChunks;
  40149. private _fileName;
  40150. private _resolve;
  40151. private _reject;
  40152. /**
  40153. * True wether a recording is already in progress.
  40154. */
  40155. readonly isRecording: boolean;
  40156. /**
  40157. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40158. * a video file.
  40159. * @param engine Defines the BabylonJS Engine you wish to record
  40160. * @param options Defines options that can be used to customized the capture
  40161. */
  40162. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40163. /**
  40164. * Stops the current recording before the default capture timeout passed in the startRecording
  40165. * functions.
  40166. */
  40167. stopRecording(): void;
  40168. /**
  40169. * Starts recording the canvas for a max duration specified in parameters.
  40170. * @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.
  40171. * @param maxDuration Defines the maximum recording time in seconds.
  40172. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40173. * @return a promise callback at the end of the recording with the video data in Blob.
  40174. */
  40175. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40176. /**
  40177. * Releases internal resources used during the recording.
  40178. */
  40179. dispose(): void;
  40180. private _handleDataAvailable;
  40181. private _handleError;
  40182. private _handleStop;
  40183. }
  40184. }
  40185. declare module BABYLON {
  40186. /**
  40187. * Defines the potential axis of a Joystick
  40188. */
  40189. enum JoystickAxis {
  40190. /** X axis */
  40191. X = 0,
  40192. /** Y axis */
  40193. Y = 1,
  40194. /** Z axis */
  40195. Z = 2
  40196. }
  40197. /**
  40198. * Class used to define virtual joystick (used in touch mode)
  40199. */
  40200. class VirtualJoystick {
  40201. /**
  40202. * Gets or sets a boolean indicating that left and right values must be inverted
  40203. */
  40204. reverseLeftRight: boolean;
  40205. /**
  40206. * Gets or sets a boolean indicating that up and down values must be inverted
  40207. */
  40208. reverseUpDown: boolean;
  40209. /**
  40210. * Gets the offset value for the position (ie. the change of the position value)
  40211. */
  40212. deltaPosition: Vector3;
  40213. /**
  40214. * Gets a boolean indicating if the virtual joystick was pressed
  40215. */
  40216. pressed: boolean;
  40217. private static _globalJoystickIndex;
  40218. private static vjCanvas;
  40219. private static vjCanvasContext;
  40220. private static vjCanvasWidth;
  40221. private static vjCanvasHeight;
  40222. private static halfWidth;
  40223. private _action;
  40224. private _axisTargetedByLeftAndRight;
  40225. private _axisTargetedByUpAndDown;
  40226. private _joystickSensibility;
  40227. private _inversedSensibility;
  40228. private _joystickPointerID;
  40229. private _joystickColor;
  40230. private _joystickPointerPos;
  40231. private _joystickPreviousPointerPos;
  40232. private _joystickPointerStartPos;
  40233. private _deltaJoystickVector;
  40234. private _leftJoystick;
  40235. private _touches;
  40236. private _onPointerDownHandlerRef;
  40237. private _onPointerMoveHandlerRef;
  40238. private _onPointerUpHandlerRef;
  40239. private _onResize;
  40240. /**
  40241. * Creates a new virtual joystick
  40242. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40243. */
  40244. constructor(leftJoystick?: boolean);
  40245. /**
  40246. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40247. * @param newJoystickSensibility defines the new sensibility
  40248. */
  40249. setJoystickSensibility(newJoystickSensibility: number): void;
  40250. private _onPointerDown;
  40251. private _onPointerMove;
  40252. private _onPointerUp;
  40253. /**
  40254. * Change the color of the virtual joystick
  40255. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40256. */
  40257. setJoystickColor(newColor: string): void;
  40258. /**
  40259. * Defines a callback to call when the joystick is touched
  40260. * @param action defines the callback
  40261. */
  40262. setActionOnTouch(action: () => any): void;
  40263. /**
  40264. * Defines which axis you'd like to control for left & right
  40265. * @param axis defines the axis to use
  40266. */
  40267. setAxisForLeftRight(axis: JoystickAxis): void;
  40268. /**
  40269. * Defines which axis you'd like to control for up & down
  40270. * @param axis defines the axis to use
  40271. */
  40272. setAxisForUpDown(axis: JoystickAxis): void;
  40273. private _drawVirtualJoystick;
  40274. /**
  40275. * Release internal HTML canvas
  40276. */
  40277. releaseCanvas(): void;
  40278. }
  40279. }
  40280. declare module BABYLON {
  40281. /**
  40282. * Helper class to push actions to a pool of workers.
  40283. */
  40284. class WorkerPool implements IDisposable {
  40285. private _workerInfos;
  40286. private _pendingActions;
  40287. /**
  40288. * Constructor
  40289. * @param workers Array of workers to use for actions
  40290. */
  40291. constructor(workers: Array<Worker>);
  40292. /**
  40293. * Terminates all workers and clears any pending actions.
  40294. */
  40295. dispose(): void;
  40296. /**
  40297. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40298. * pended until a worker has completed its action.
  40299. * @param action The action to perform. Call onComplete when the action is complete.
  40300. */
  40301. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40302. private _execute;
  40303. }
  40304. }
  40305. declare module BABYLON {
  40306. /**
  40307. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40309. */
  40310. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40311. /**
  40312. * Gets the name of the behavior.
  40313. */
  40314. readonly name: string;
  40315. private _zoomStopsAnimation;
  40316. private _idleRotationSpeed;
  40317. private _idleRotationWaitTime;
  40318. private _idleRotationSpinupTime;
  40319. /**
  40320. * Sets the flag that indicates if user zooming should stop animation.
  40321. */
  40322. /**
  40323. * Gets the flag that indicates if user zooming should stop animation.
  40324. */
  40325. zoomStopsAnimation: boolean;
  40326. /**
  40327. * Sets the default speed at which the camera rotates around the model.
  40328. */
  40329. /**
  40330. * Gets the default speed at which the camera rotates around the model.
  40331. */
  40332. idleRotationSpeed: number;
  40333. /**
  40334. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40335. */
  40336. /**
  40337. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40338. */
  40339. idleRotationWaitTime: number;
  40340. /**
  40341. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40342. */
  40343. /**
  40344. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40345. */
  40346. idleRotationSpinupTime: number;
  40347. /**
  40348. * Gets a value indicating if the camera is currently rotating because of this behavior
  40349. */
  40350. readonly rotationInProgress: boolean;
  40351. private _onPrePointerObservableObserver;
  40352. private _onAfterCheckInputsObserver;
  40353. private _attachedCamera;
  40354. private _isPointerDown;
  40355. private _lastFrameTime;
  40356. private _lastInteractionTime;
  40357. private _cameraRotationSpeed;
  40358. /**
  40359. * Initializes the behavior.
  40360. */
  40361. init(): void;
  40362. /**
  40363. * Attaches the behavior to its arc rotate camera.
  40364. * @param camera Defines the camera to attach the behavior to
  40365. */
  40366. attach(camera: ArcRotateCamera): void;
  40367. /**
  40368. * Detaches the behavior from its current arc rotate camera.
  40369. */
  40370. detach(): void;
  40371. /**
  40372. * Returns true if user is scrolling.
  40373. * @return true if user is scrolling.
  40374. */
  40375. private _userIsZooming;
  40376. private _lastFrameRadius;
  40377. private _shouldAnimationStopForInteraction;
  40378. /**
  40379. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40380. */
  40381. private _applyUserInteraction;
  40382. private _userIsMoving;
  40383. }
  40384. }
  40385. declare module BABYLON {
  40386. /**
  40387. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40388. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40389. */
  40390. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40391. /**
  40392. * Gets the name of the behavior.
  40393. */
  40394. readonly name: string;
  40395. /**
  40396. * The easing function used by animations
  40397. */
  40398. static EasingFunction: BackEase;
  40399. /**
  40400. * The easing mode used by animations
  40401. */
  40402. static EasingMode: number;
  40403. /**
  40404. * The duration of the animation, in milliseconds
  40405. */
  40406. transitionDuration: number;
  40407. /**
  40408. * Length of the distance animated by the transition when lower radius is reached
  40409. */
  40410. lowerRadiusTransitionRange: number;
  40411. /**
  40412. * Length of the distance animated by the transition when upper radius is reached
  40413. */
  40414. upperRadiusTransitionRange: number;
  40415. private _autoTransitionRange;
  40416. /**
  40417. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40418. */
  40419. /**
  40420. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40421. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40422. */
  40423. autoTransitionRange: boolean;
  40424. private _attachedCamera;
  40425. private _onAfterCheckInputsObserver;
  40426. private _onMeshTargetChangedObserver;
  40427. /**
  40428. * Initializes the behavior.
  40429. */
  40430. init(): void;
  40431. /**
  40432. * Attaches the behavior to its arc rotate camera.
  40433. * @param camera Defines the camera to attach the behavior to
  40434. */
  40435. attach(camera: ArcRotateCamera): void;
  40436. /**
  40437. * Detaches the behavior from its current arc rotate camera.
  40438. */
  40439. detach(): void;
  40440. private _radiusIsAnimating;
  40441. private _radiusBounceTransition;
  40442. private _animatables;
  40443. private _cachedWheelPrecision;
  40444. /**
  40445. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40446. * @param radiusLimit The limit to check against.
  40447. * @return Bool to indicate if at limit.
  40448. */
  40449. private _isRadiusAtLimit;
  40450. /**
  40451. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40452. * @param radiusDelta The delta by which to animate to. Can be negative.
  40453. */
  40454. private _applyBoundRadiusAnimation;
  40455. /**
  40456. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40457. */
  40458. protected _clearAnimationLocks(): void;
  40459. /**
  40460. * Stops and removes all animations that have been applied to the camera
  40461. */
  40462. stopAllAnimations(): void;
  40463. }
  40464. }
  40465. declare module BABYLON {
  40466. /**
  40467. * 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.
  40468. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40469. */
  40470. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40471. /**
  40472. * Gets the name of the behavior.
  40473. */
  40474. readonly name: string;
  40475. private _mode;
  40476. private _radiusScale;
  40477. private _positionScale;
  40478. private _defaultElevation;
  40479. private _elevationReturnTime;
  40480. private _elevationReturnWaitTime;
  40481. private _zoomStopsAnimation;
  40482. private _framingTime;
  40483. /**
  40484. * The easing function used by animations
  40485. */
  40486. static EasingFunction: ExponentialEase;
  40487. /**
  40488. * The easing mode used by animations
  40489. */
  40490. static EasingMode: number;
  40491. /**
  40492. * Sets the current mode used by the behavior
  40493. */
  40494. /**
  40495. * Gets current mode used by the behavior.
  40496. */
  40497. mode: number;
  40498. /**
  40499. * Sets the scale applied to the radius (1 by default)
  40500. */
  40501. /**
  40502. * Gets the scale applied to the radius
  40503. */
  40504. radiusScale: number;
  40505. /**
  40506. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40507. */
  40508. /**
  40509. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40510. */
  40511. positionScale: number;
  40512. /**
  40513. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40514. * behaviour is triggered, in radians.
  40515. */
  40516. /**
  40517. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40518. * behaviour is triggered, in radians.
  40519. */
  40520. defaultElevation: number;
  40521. /**
  40522. * Sets the time (in milliseconds) taken to return to the default beta position.
  40523. * Negative value indicates camera should not return to default.
  40524. */
  40525. /**
  40526. * Gets the time (in milliseconds) taken to return to the default beta position.
  40527. * Negative value indicates camera should not return to default.
  40528. */
  40529. elevationReturnTime: number;
  40530. /**
  40531. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40532. */
  40533. /**
  40534. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40535. */
  40536. elevationReturnWaitTime: number;
  40537. /**
  40538. * Sets the flag that indicates if user zooming should stop animation.
  40539. */
  40540. /**
  40541. * Gets the flag that indicates if user zooming should stop animation.
  40542. */
  40543. zoomStopsAnimation: boolean;
  40544. /**
  40545. * Sets the transition time when framing the mesh, in milliseconds
  40546. */
  40547. /**
  40548. * Gets the transition time when framing the mesh, in milliseconds
  40549. */
  40550. framingTime: number;
  40551. /**
  40552. * Define if the behavior should automatically change the configured
  40553. * camera limits and sensibilities.
  40554. */
  40555. autoCorrectCameraLimitsAndSensibility: boolean;
  40556. private _onPrePointerObservableObserver;
  40557. private _onAfterCheckInputsObserver;
  40558. private _onMeshTargetChangedObserver;
  40559. private _attachedCamera;
  40560. private _isPointerDown;
  40561. private _lastInteractionTime;
  40562. /**
  40563. * Initializes the behavior.
  40564. */
  40565. init(): void;
  40566. /**
  40567. * Attaches the behavior to its arc rotate camera.
  40568. * @param camera Defines the camera to attach the behavior to
  40569. */
  40570. attach(camera: ArcRotateCamera): void;
  40571. /**
  40572. * Detaches the behavior from its current arc rotate camera.
  40573. */
  40574. detach(): void;
  40575. private _animatables;
  40576. private _betaIsAnimating;
  40577. private _betaTransition;
  40578. private _radiusTransition;
  40579. private _vectorTransition;
  40580. /**
  40581. * Targets the given mesh and updates zoom level accordingly.
  40582. * @param mesh The mesh to target.
  40583. * @param radius Optional. If a cached radius position already exists, overrides default.
  40584. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40585. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40586. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40587. */
  40588. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40589. /**
  40590. * Targets the given mesh with its children and updates zoom level accordingly.
  40591. * @param mesh The mesh to target.
  40592. * @param radius Optional. If a cached radius position already exists, overrides default.
  40593. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40594. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40595. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40596. */
  40597. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40598. /**
  40599. * Targets the given meshes with their children and updates zoom level accordingly.
  40600. * @param meshes The mesh to target.
  40601. * @param radius Optional. If a cached radius position already exists, overrides default.
  40602. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40603. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40604. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40605. */
  40606. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40607. /**
  40608. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40609. * @param minimumWorld Determines the smaller position of the bounding box extend
  40610. * @param maximumWorld Determines the bigger position of the bounding box extend
  40611. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40612. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40613. */
  40614. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40615. /**
  40616. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40617. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40618. * frustum width.
  40619. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40620. * to fully enclose the mesh in the viewing frustum.
  40621. */
  40622. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40623. /**
  40624. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40625. * is automatically returned to its default position (expected to be above ground plane).
  40626. */
  40627. private _maintainCameraAboveGround;
  40628. /**
  40629. * Returns the frustum slope based on the canvas ratio and camera FOV
  40630. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40631. */
  40632. private _getFrustumSlope;
  40633. /**
  40634. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40635. */
  40636. private _clearAnimationLocks;
  40637. /**
  40638. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40639. */
  40640. private _applyUserInteraction;
  40641. /**
  40642. * Stops and removes all animations that have been applied to the camera
  40643. */
  40644. stopAllAnimations(): void;
  40645. /**
  40646. * Gets a value indicating if the user is moving the camera
  40647. */
  40648. readonly isUserIsMoving: boolean;
  40649. /**
  40650. * The camera can move all the way towards the mesh.
  40651. */
  40652. static IgnoreBoundsSizeMode: number;
  40653. /**
  40654. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40655. */
  40656. static FitFrustumSidesMode: number;
  40657. }
  40658. }
  40659. declare module BABYLON {
  40660. /**
  40661. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40662. */
  40663. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40664. private ui;
  40665. /**
  40666. * The name of the behavior
  40667. */
  40668. name: string;
  40669. /**
  40670. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40671. */
  40672. distanceAwayFromFace: number;
  40673. /**
  40674. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40675. */
  40676. distanceAwayFromBottomOfFace: number;
  40677. private _faceVectors;
  40678. private _target;
  40679. private _scene;
  40680. private _onRenderObserver;
  40681. private _tmpMatrix;
  40682. private _tmpVector;
  40683. /**
  40684. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40685. * @param ui The transform node that should be attched to the mesh
  40686. */
  40687. constructor(ui: BABYLON.TransformNode);
  40688. /**
  40689. * Initializes the behavior
  40690. */
  40691. init(): void;
  40692. private _closestFace;
  40693. private _zeroVector;
  40694. private _lookAtTmpMatrix;
  40695. private _lookAtToRef;
  40696. /**
  40697. * Attaches the AttachToBoxBehavior to the passed in mesh
  40698. * @param target The mesh that the specified node will be attached to
  40699. */
  40700. attach(target: BABYLON.Mesh): void;
  40701. /**
  40702. * Detaches the behavior from the mesh
  40703. */
  40704. detach(): void;
  40705. }
  40706. }
  40707. declare module BABYLON {
  40708. /**
  40709. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40710. */
  40711. class FadeInOutBehavior implements Behavior<Mesh> {
  40712. /**
  40713. * Time in milliseconds to delay before fading in (Default: 0)
  40714. */
  40715. delay: number;
  40716. /**
  40717. * Time in milliseconds for the mesh to fade in (Default: 300)
  40718. */
  40719. fadeInTime: number;
  40720. private _millisecondsPerFrame;
  40721. private _hovered;
  40722. private _hoverValue;
  40723. private _ownerNode;
  40724. /**
  40725. * Instatiates the FadeInOutBehavior
  40726. */
  40727. constructor();
  40728. /**
  40729. * The name of the behavior
  40730. */
  40731. readonly name: string;
  40732. /**
  40733. * Initializes the behavior
  40734. */
  40735. init(): void;
  40736. /**
  40737. * Attaches the fade behavior on the passed in mesh
  40738. * @param ownerNode The mesh that will be faded in/out once attached
  40739. */
  40740. attach(ownerNode: Mesh): void;
  40741. /**
  40742. * Detaches the behavior from the mesh
  40743. */
  40744. detach(): void;
  40745. /**
  40746. * Triggers the mesh to begin fading in or out
  40747. * @param value if the object should fade in or out (true to fade in)
  40748. */
  40749. fadeIn(value: boolean): void;
  40750. private _update;
  40751. private _setAllVisibility;
  40752. }
  40753. }
  40754. declare module BABYLON {
  40755. /**
  40756. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40757. */
  40758. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40759. private _dragBehaviorA;
  40760. private _dragBehaviorB;
  40761. private _startDistance;
  40762. private _initialScale;
  40763. private _targetScale;
  40764. private _ownerNode;
  40765. private _sceneRenderObserver;
  40766. /**
  40767. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40768. */
  40769. constructor();
  40770. /**
  40771. * The name of the behavior
  40772. */
  40773. readonly name: string;
  40774. /**
  40775. * Initializes the behavior
  40776. */
  40777. init(): void;
  40778. private _getCurrentDistance;
  40779. /**
  40780. * Attaches the scale behavior the passed in mesh
  40781. * @param ownerNode The mesh that will be scaled around once attached
  40782. */
  40783. attach(ownerNode: Mesh): void;
  40784. /**
  40785. * Detaches the behavior from the mesh
  40786. */
  40787. detach(): void;
  40788. }
  40789. }
  40790. declare module BABYLON {
  40791. /**
  40792. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40793. */
  40794. class PointerDragBehavior implements Behavior<Mesh> {
  40795. private static _AnyMouseID;
  40796. private _attachedNode;
  40797. private _dragPlane;
  40798. private _scene;
  40799. private _pointerObserver;
  40800. private _beforeRenderObserver;
  40801. private static _planeScene;
  40802. /**
  40803. * 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)
  40804. */
  40805. maxDragAngle: number;
  40806. /**
  40807. * @hidden
  40808. */
  40809. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40810. /**
  40811. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40812. */
  40813. currentDraggingPointerID: number;
  40814. /**
  40815. * The last position where the pointer hit the drag plane in world space
  40816. */
  40817. lastDragPosition: Vector3;
  40818. /**
  40819. * If the behavior is currently in a dragging state
  40820. */
  40821. dragging: boolean;
  40822. /**
  40823. * 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)
  40824. */
  40825. dragDeltaRatio: number;
  40826. /**
  40827. * If the drag plane orientation should be updated during the dragging (Default: true)
  40828. */
  40829. updateDragPlane: boolean;
  40830. private _debugMode;
  40831. private _moving;
  40832. /**
  40833. * Fires each time the attached mesh is dragged with the pointer
  40834. * * delta between last drag position and current drag position in world space
  40835. * * dragDistance along the drag axis
  40836. * * dragPlaneNormal normal of the current drag plane used during the drag
  40837. * * dragPlanePoint in world space where the drag intersects the drag plane
  40838. */
  40839. onDragObservable: Observable<{
  40840. delta: Vector3;
  40841. dragPlanePoint: Vector3;
  40842. dragPlaneNormal: Vector3;
  40843. dragDistance: number;
  40844. pointerId: number;
  40845. }>;
  40846. /**
  40847. * Fires each time a drag begins (eg. mouse down on mesh)
  40848. */
  40849. onDragStartObservable: Observable<{
  40850. dragPlanePoint: Vector3;
  40851. pointerId: number;
  40852. }>;
  40853. /**
  40854. * Fires each time a drag ends (eg. mouse release after drag)
  40855. */
  40856. onDragEndObservable: Observable<{
  40857. dragPlanePoint: Vector3;
  40858. pointerId: number;
  40859. }>;
  40860. /**
  40861. * If the attached mesh should be moved when dragged
  40862. */
  40863. moveAttached: boolean;
  40864. /**
  40865. * If the drag behavior will react to drag events (Default: true)
  40866. */
  40867. enabled: boolean;
  40868. /**
  40869. * If camera controls should be detached during the drag
  40870. */
  40871. detachCameraControls: boolean;
  40872. /**
  40873. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40874. */
  40875. useObjectOrienationForDragging: boolean;
  40876. private _options;
  40877. /**
  40878. * Creates a pointer drag behavior that can be attached to a mesh
  40879. * @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)
  40880. */
  40881. constructor(options?: {
  40882. dragAxis?: Vector3;
  40883. dragPlaneNormal?: Vector3;
  40884. });
  40885. /**
  40886. * The name of the behavior
  40887. */
  40888. readonly name: string;
  40889. /**
  40890. * Initializes the behavior
  40891. */
  40892. init(): void;
  40893. private _tmpVector;
  40894. private _alternatePickedPoint;
  40895. private _worldDragAxis;
  40896. private _targetPosition;
  40897. private _attachedElement;
  40898. /**
  40899. * Attaches the drag behavior the passed in mesh
  40900. * @param ownerNode The mesh that will be dragged around once attached
  40901. */
  40902. attach(ownerNode: Mesh): void;
  40903. /**
  40904. * Force relase the drag action by code.
  40905. */
  40906. releaseDrag(): void;
  40907. private _startDragRay;
  40908. private _lastPointerRay;
  40909. /**
  40910. * Simulates the start of a pointer drag event on the behavior
  40911. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40912. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40913. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40914. */
  40915. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40916. private _startDrag;
  40917. private _dragDelta;
  40918. private _moveDrag;
  40919. private _pickWithRayOnDragPlane;
  40920. private _pointA;
  40921. private _pointB;
  40922. private _pointC;
  40923. private _lineA;
  40924. private _lineB;
  40925. private _localAxis;
  40926. private _lookAt;
  40927. private _updateDragPlanePosition;
  40928. /**
  40929. * Detaches the behavior from the mesh
  40930. */
  40931. detach(): void;
  40932. }
  40933. }
  40934. declare module BABYLON {
  40935. /**
  40936. * 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
  40937. */
  40938. class SixDofDragBehavior implements Behavior<Mesh> {
  40939. private static _virtualScene;
  40940. private _ownerNode;
  40941. private _sceneRenderObserver;
  40942. private _scene;
  40943. private _targetPosition;
  40944. private _virtualOriginMesh;
  40945. private _virtualDragMesh;
  40946. private _pointerObserver;
  40947. private _moving;
  40948. private _startingOrientation;
  40949. /**
  40950. * 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)
  40951. */
  40952. private zDragFactor;
  40953. /**
  40954. * If the behavior is currently in a dragging state
  40955. */
  40956. dragging: boolean;
  40957. /**
  40958. * 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)
  40959. */
  40960. dragDeltaRatio: number;
  40961. /**
  40962. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40963. */
  40964. currentDraggingPointerID: number;
  40965. /**
  40966. * If camera controls should be detached during the drag
  40967. */
  40968. detachCameraControls: boolean;
  40969. /**
  40970. * Fires each time a drag starts
  40971. */
  40972. onDragStartObservable: Observable<{}>;
  40973. /**
  40974. * Fires each time a drag ends (eg. mouse release after drag)
  40975. */
  40976. onDragEndObservable: Observable<{}>;
  40977. /**
  40978. * 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
  40979. */
  40980. constructor();
  40981. /**
  40982. * The name of the behavior
  40983. */
  40984. readonly name: string;
  40985. /**
  40986. * Initializes the behavior
  40987. */
  40988. init(): void;
  40989. /**
  40990. * Attaches the scale behavior the passed in mesh
  40991. * @param ownerNode The mesh that will be scaled around once attached
  40992. */
  40993. attach(ownerNode: Mesh): void;
  40994. /**
  40995. * Detaches the behavior from the mesh
  40996. */
  40997. detach(): void;
  40998. }
  40999. }
  41000. declare module BABYLON {
  41001. /**
  41002. * Contains an array of blocks representing the octree
  41003. */
  41004. interface IOctreeContainer<T> {
  41005. /**
  41006. * Blocks within the octree
  41007. */
  41008. blocks: Array<OctreeBlock<T>>;
  41009. }
  41010. /**
  41011. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41012. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41013. */
  41014. class Octree<T> {
  41015. /** 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.) */
  41016. maxDepth: number;
  41017. /**
  41018. * Blocks within the octree containing objects
  41019. */
  41020. blocks: Array<OctreeBlock<T>>;
  41021. /**
  41022. * Content stored in the octree
  41023. */
  41024. dynamicContent: T[];
  41025. private _maxBlockCapacity;
  41026. private _selectionContent;
  41027. private _creationFunc;
  41028. /**
  41029. * Creates a octree
  41030. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41031. * @param creationFunc function to be used to instatiate the octree
  41032. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41033. * @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.)
  41034. */
  41035. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41036. /** 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.) */
  41037. maxDepth?: number);
  41038. /**
  41039. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41040. * @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);
  41041. * @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);
  41042. * @param entries meshes to be added to the octree blocks
  41043. */
  41044. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41045. /**
  41046. * Adds a mesh to the octree
  41047. * @param entry Mesh to add to the octree
  41048. */
  41049. addMesh(entry: T): void;
  41050. /**
  41051. * Selects an array of meshes within the frustum
  41052. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41053. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41054. * @returns array of meshes within the frustum
  41055. */
  41056. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41057. /**
  41058. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41059. * @param sphereCenter defines the bounding sphere center
  41060. * @param sphereRadius defines the bounding sphere radius
  41061. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41062. * @returns an array of objects that intersect the sphere
  41063. */
  41064. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41065. /**
  41066. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41067. * @param ray defines the ray to test with
  41068. * @returns array of intersected objects
  41069. */
  41070. intersectsRay(ray: Ray): SmartArray<T>;
  41071. /**
  41072. * @hidden
  41073. */
  41074. 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;
  41075. /**
  41076. * Adds a mesh into the octree block if it intersects the block
  41077. */
  41078. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41079. /**
  41080. * Adds a submesh into the octree block if it intersects the block
  41081. */
  41082. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41083. }
  41084. }
  41085. declare module BABYLON {
  41086. /**
  41087. * Class used to store a cell in an octree
  41088. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41089. */
  41090. class OctreeBlock<T> {
  41091. /**
  41092. * Gets the content of the current block
  41093. */
  41094. entries: T[];
  41095. /**
  41096. * Gets the list of block children
  41097. */
  41098. blocks: Array<OctreeBlock<T>>;
  41099. private _depth;
  41100. private _maxDepth;
  41101. private _capacity;
  41102. private _minPoint;
  41103. private _maxPoint;
  41104. private _boundingVectors;
  41105. private _creationFunc;
  41106. /**
  41107. * Creates a new block
  41108. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41109. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41110. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41111. * @param depth defines the current depth of this block in the octree
  41112. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41113. * @param creationFunc defines a callback to call when an element is added to the block
  41114. */
  41115. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41116. /**
  41117. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41118. */
  41119. readonly capacity: number;
  41120. /**
  41121. * Gets the minimum vector (in world space) of the block's bounding box
  41122. */
  41123. readonly minPoint: Vector3;
  41124. /**
  41125. * Gets the maximum vector (in world space) of the block's bounding box
  41126. */
  41127. readonly maxPoint: Vector3;
  41128. /**
  41129. * Add a new element to this block
  41130. * @param entry defines the element to add
  41131. */
  41132. addEntry(entry: T): void;
  41133. /**
  41134. * Add an array of elements to this block
  41135. * @param entries defines the array of elements to add
  41136. */
  41137. addEntries(entries: T[]): void;
  41138. /**
  41139. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41140. * @param frustumPlanes defines the frustum planes to test
  41141. * @param selection defines the array to store current content if selection is positive
  41142. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41143. */
  41144. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41145. /**
  41146. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41147. * @param sphereCenter defines the bounding sphere center
  41148. * @param sphereRadius defines the bounding sphere radius
  41149. * @param selection defines the array to store current content if selection is positive
  41150. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41151. */
  41152. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41153. /**
  41154. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41155. * @param ray defines the ray to test with
  41156. * @param selection defines the array to store current content if selection is positive
  41157. */
  41158. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41159. /**
  41160. * Subdivide the content into child blocks (this block will then be empty)
  41161. */
  41162. createInnerBlocks(): void;
  41163. }
  41164. }
  41165. declare module BABYLON {
  41166. interface Scene {
  41167. /**
  41168. * @hidden
  41169. * Backing Filed
  41170. */
  41171. _selectionOctree: Octree<AbstractMesh>;
  41172. /**
  41173. * Gets the octree used to boost mesh selection (picking)
  41174. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41175. */
  41176. selectionOctree: Octree<AbstractMesh>;
  41177. /**
  41178. * Creates or updates the octree used to boost selection (picking)
  41179. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41180. * @param maxCapacity defines the maximum capacity per leaf
  41181. * @param maxDepth defines the maximum depth of the octree
  41182. * @returns an octree of AbstractMesh
  41183. */
  41184. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41185. }
  41186. interface AbstractMesh {
  41187. /**
  41188. * @hidden
  41189. * Backing Field
  41190. */
  41191. _submeshesOctree: Octree<SubMesh>;
  41192. /**
  41193. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41194. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41195. * @param maxCapacity defines the maximum size of each block (64 by default)
  41196. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41197. * @returns the new octree
  41198. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41200. */
  41201. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41202. }
  41203. /**
  41204. * Defines the octree scene component responsible to manage any octrees
  41205. * in a given scene.
  41206. */
  41207. class OctreeSceneComponent {
  41208. /**
  41209. * The component name helpfull to identify the component in the list of scene components.
  41210. */
  41211. readonly name: string;
  41212. /**
  41213. * The scene the component belongs to.
  41214. */
  41215. scene: Scene;
  41216. /**
  41217. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41218. */
  41219. readonly checksIsEnabled: boolean;
  41220. /**
  41221. * Creates a new instance of the component for the given scene
  41222. * @param scene Defines the scene to register the component in
  41223. */
  41224. constructor(scene: Scene);
  41225. /**
  41226. * Registers the component in a given scene
  41227. */
  41228. register(): void;
  41229. /**
  41230. * Return the list of active meshes
  41231. * @returns the list of active meshes
  41232. */
  41233. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41234. /**
  41235. * Return the list of active sub meshes
  41236. * @param mesh The mesh to get the candidates sub meshes from
  41237. * @returns the list of active sub meshes
  41238. */
  41239. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41240. private _tempRay;
  41241. /**
  41242. * Return the list of sub meshes intersecting with a given local ray
  41243. * @param mesh defines the mesh to find the submesh for
  41244. * @param localRay defines the ray in local space
  41245. * @returns the list of intersecting sub meshes
  41246. */
  41247. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41248. /**
  41249. * Return the list of sub meshes colliding with a collider
  41250. * @param mesh defines the mesh to find the submesh for
  41251. * @param collider defines the collider to evaluate the collision against
  41252. * @returns the list of colliding sub meshes
  41253. */
  41254. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41255. /**
  41256. * Rebuilds the elements related to this component in case of
  41257. * context lost for instance.
  41258. */
  41259. rebuild(): void;
  41260. /**
  41261. * Disposes the component and the associated ressources.
  41262. */
  41263. dispose(): void;
  41264. }
  41265. }
  41266. declare module BABYLON {
  41267. /**
  41268. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41269. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41270. */
  41271. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41272. /**
  41273. * Creates a new AnaglyphArcRotateCamera
  41274. * @param name defines camera name
  41275. * @param alpha defines alpha angle (in radians)
  41276. * @param beta defines beta angle (in radians)
  41277. * @param radius defines radius
  41278. * @param target defines camera target
  41279. * @param interaxialDistance defines distance between each color axis
  41280. * @param scene defines the hosting scene
  41281. */
  41282. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41283. /**
  41284. * Gets camera class name
  41285. * @returns AnaglyphArcRotateCamera
  41286. */
  41287. getClassName(): string;
  41288. }
  41289. }
  41290. declare module BABYLON {
  41291. /**
  41292. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41293. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41294. */
  41295. class AnaglyphFreeCamera extends FreeCamera {
  41296. /**
  41297. * Creates a new AnaglyphFreeCamera
  41298. * @param name defines camera name
  41299. * @param position defines initial position
  41300. * @param interaxialDistance defines distance between each color axis
  41301. * @param scene defines the hosting scene
  41302. */
  41303. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41304. /**
  41305. * Gets camera class name
  41306. * @returns AnaglyphFreeCamera
  41307. */
  41308. getClassName(): string;
  41309. }
  41310. }
  41311. declare module BABYLON {
  41312. /**
  41313. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41314. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41315. */
  41316. class AnaglyphGamepadCamera extends GamepadCamera {
  41317. /**
  41318. * Creates a new AnaglyphGamepadCamera
  41319. * @param name defines camera name
  41320. * @param position defines initial position
  41321. * @param interaxialDistance defines distance between each color axis
  41322. * @param scene defines the hosting scene
  41323. */
  41324. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41325. /**
  41326. * Gets camera class name
  41327. * @returns AnaglyphGamepadCamera
  41328. */
  41329. getClassName(): string;
  41330. }
  41331. }
  41332. declare module BABYLON {
  41333. /**
  41334. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41335. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41336. */
  41337. class AnaglyphUniversalCamera extends UniversalCamera {
  41338. /**
  41339. * Creates a new AnaglyphUniversalCamera
  41340. * @param name defines camera name
  41341. * @param position defines initial position
  41342. * @param interaxialDistance defines distance between each color axis
  41343. * @param scene defines the hosting scene
  41344. */
  41345. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41346. /**
  41347. * Gets camera class name
  41348. * @returns AnaglyphUniversalCamera
  41349. */
  41350. getClassName(): string;
  41351. }
  41352. }
  41353. declare module BABYLON {
  41354. /**
  41355. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41356. * @see http://doc.babylonjs.com/features/cameras
  41357. */
  41358. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41359. /**
  41360. * Creates a new StereoscopicArcRotateCamera
  41361. * @param name defines camera name
  41362. * @param alpha defines alpha angle (in radians)
  41363. * @param beta defines beta angle (in radians)
  41364. * @param radius defines radius
  41365. * @param target defines camera target
  41366. * @param interaxialDistance defines distance between each color axis
  41367. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41368. * @param scene defines the hosting scene
  41369. */
  41370. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41371. /**
  41372. * Gets camera class name
  41373. * @returns StereoscopicArcRotateCamera
  41374. */
  41375. getClassName(): string;
  41376. }
  41377. }
  41378. declare module BABYLON {
  41379. /**
  41380. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41381. * @see http://doc.babylonjs.com/features/cameras
  41382. */
  41383. class StereoscopicFreeCamera extends FreeCamera {
  41384. /**
  41385. * Creates a new StereoscopicFreeCamera
  41386. * @param name defines camera name
  41387. * @param position defines initial position
  41388. * @param interaxialDistance defines distance between each color axis
  41389. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41390. * @param scene defines the hosting scene
  41391. */
  41392. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41393. /**
  41394. * Gets camera class name
  41395. * @returns StereoscopicFreeCamera
  41396. */
  41397. getClassName(): string;
  41398. }
  41399. }
  41400. declare module BABYLON {
  41401. /**
  41402. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41403. * @see http://doc.babylonjs.com/features/cameras
  41404. */
  41405. class StereoscopicGamepadCamera extends GamepadCamera {
  41406. /**
  41407. * Creates a new StereoscopicGamepadCamera
  41408. * @param name defines camera name
  41409. * @param position defines initial position
  41410. * @param interaxialDistance defines distance between each color axis
  41411. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41412. * @param scene defines the hosting scene
  41413. */
  41414. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41415. /**
  41416. * Gets camera class name
  41417. * @returns StereoscopicGamepadCamera
  41418. */
  41419. getClassName(): string;
  41420. }
  41421. }
  41422. declare module BABYLON {
  41423. /**
  41424. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41425. * @see http://doc.babylonjs.com/features/cameras
  41426. */
  41427. class StereoscopicUniversalCamera extends UniversalCamera {
  41428. /**
  41429. * Creates a new StereoscopicUniversalCamera
  41430. * @param name defines camera name
  41431. * @param position defines initial position
  41432. * @param interaxialDistance defines distance between each color axis
  41433. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41434. * @param scene defines the hosting scene
  41435. */
  41436. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41437. /**
  41438. * Gets camera class name
  41439. * @returns StereoscopicUniversalCamera
  41440. */
  41441. getClassName(): string;
  41442. }
  41443. }
  41444. declare module BABYLON {
  41445. /**
  41446. * This represents all the required metrics to create a VR camera.
  41447. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41448. */
  41449. class VRCameraMetrics {
  41450. /**
  41451. * Define the horizontal resolution off the screen.
  41452. */
  41453. hResolution: number;
  41454. /**
  41455. * Define the vertical resolution off the screen.
  41456. */
  41457. vResolution: number;
  41458. /**
  41459. * Define the horizontal screen size.
  41460. */
  41461. hScreenSize: number;
  41462. /**
  41463. * Define the vertical screen size.
  41464. */
  41465. vScreenSize: number;
  41466. /**
  41467. * Define the vertical screen center position.
  41468. */
  41469. vScreenCenter: number;
  41470. /**
  41471. * Define the distance of the eyes to the screen.
  41472. */
  41473. eyeToScreenDistance: number;
  41474. /**
  41475. * Define the distance between both lenses
  41476. */
  41477. lensSeparationDistance: number;
  41478. /**
  41479. * Define the distance between both viewer's eyes.
  41480. */
  41481. interpupillaryDistance: number;
  41482. /**
  41483. * Define the distortion factor of the VR postprocess.
  41484. * Please, touch with care.
  41485. */
  41486. distortionK: number[];
  41487. /**
  41488. * Define the chromatic aberration correction factors for the VR post process.
  41489. */
  41490. chromaAbCorrection: number[];
  41491. /**
  41492. * Define the scale factor of the post process.
  41493. * The smaller the better but the slower.
  41494. */
  41495. postProcessScaleFactor: number;
  41496. /**
  41497. * Define an offset for the lens center.
  41498. */
  41499. lensCenterOffset: number;
  41500. /**
  41501. * Define if the current vr camera should compensate the distortion of the lense or not.
  41502. */
  41503. compensateDistortion: boolean;
  41504. /**
  41505. * Gets the rendering aspect ratio based on the provided resolutions.
  41506. */
  41507. readonly aspectRatio: number;
  41508. /**
  41509. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41510. */
  41511. readonly aspectRatioFov: number;
  41512. /**
  41513. * @hidden
  41514. */
  41515. readonly leftHMatrix: Matrix;
  41516. /**
  41517. * @hidden
  41518. */
  41519. readonly rightHMatrix: Matrix;
  41520. /**
  41521. * @hidden
  41522. */
  41523. readonly leftPreViewMatrix: Matrix;
  41524. /**
  41525. * @hidden
  41526. */
  41527. readonly rightPreViewMatrix: Matrix;
  41528. /**
  41529. * Get the default VRMetrics based on the most generic setup.
  41530. * @returns the default vr metrics
  41531. */
  41532. static GetDefault(): VRCameraMetrics;
  41533. }
  41534. }
  41535. declare module BABYLON {
  41536. /**
  41537. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41538. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41539. */
  41540. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41541. /**
  41542. * Creates a new VRDeviceOrientationArcRotateCamera
  41543. * @param name defines camera name
  41544. * @param alpha defines the camera rotation along the logitudinal axis
  41545. * @param beta defines the camera rotation along the latitudinal axis
  41546. * @param radius defines the camera distance from its target
  41547. * @param target defines the camera target
  41548. * @param scene defines the scene the camera belongs to
  41549. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41550. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41551. */
  41552. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41553. /**
  41554. * Gets camera class name
  41555. * @returns VRDeviceOrientationArcRotateCamera
  41556. */
  41557. getClassName(): string;
  41558. }
  41559. }
  41560. declare module BABYLON {
  41561. /**
  41562. * Camera used to simulate VR rendering (based on FreeCamera)
  41563. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41564. */
  41565. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41566. /**
  41567. * Creates a new VRDeviceOrientationFreeCamera
  41568. * @param name defines camera name
  41569. * @param position defines the start position of the camera
  41570. * @param scene defines the scene the camera belongs to
  41571. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41572. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41573. */
  41574. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41575. /**
  41576. * Gets camera class name
  41577. * @returns VRDeviceOrientationFreeCamera
  41578. */
  41579. getClassName(): string;
  41580. }
  41581. }
  41582. declare module BABYLON {
  41583. /**
  41584. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41585. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41586. */
  41587. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41588. /**
  41589. * Creates a new VRDeviceOrientationGamepadCamera
  41590. * @param name defines camera name
  41591. * @param position defines the start position of the camera
  41592. * @param scene defines the scene the camera belongs to
  41593. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41594. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41595. */
  41596. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41597. /**
  41598. * Gets camera class name
  41599. * @returns VRDeviceOrientationGamepadCamera
  41600. */
  41601. getClassName(): string;
  41602. }
  41603. }
  41604. declare module BABYLON {
  41605. /**
  41606. * Options to modify the vr teleportation behavior.
  41607. */
  41608. interface VRTeleportationOptions {
  41609. /**
  41610. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41611. */
  41612. floorMeshName?: string;
  41613. /**
  41614. * A list of meshes to be used as the teleportation floor. (default: empty)
  41615. */
  41616. floorMeshes?: Mesh[];
  41617. }
  41618. /**
  41619. * Options to modify the vr experience helper's behavior.
  41620. */
  41621. interface VRExperienceHelperOptions extends WebVROptions {
  41622. /**
  41623. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41624. */
  41625. createDeviceOrientationCamera?: boolean;
  41626. /**
  41627. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41628. */
  41629. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41630. /**
  41631. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41632. */
  41633. laserToggle?: boolean;
  41634. /**
  41635. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41636. */
  41637. floorMeshes?: Mesh[];
  41638. }
  41639. /**
  41640. * Helps to quickly add VR support to an existing scene.
  41641. * See http://doc.babylonjs.com/how_to/webvr_helper
  41642. */
  41643. class VRExperienceHelper {
  41644. /** Options to modify the vr experience helper's behavior. */
  41645. webVROptions: VRExperienceHelperOptions;
  41646. private _scene;
  41647. private _position;
  41648. private _btnVR;
  41649. private _btnVRDisplayed;
  41650. private _webVRsupported;
  41651. private _webVRready;
  41652. private _webVRrequesting;
  41653. private _webVRpresenting;
  41654. private _hasEnteredVR;
  41655. private _fullscreenVRpresenting;
  41656. private _canvas;
  41657. private _webVRCamera;
  41658. private _vrDeviceOrientationCamera;
  41659. private _deviceOrientationCamera;
  41660. private _existingCamera;
  41661. private _onKeyDown;
  41662. private _onVrDisplayPresentChange;
  41663. private _onVRDisplayChanged;
  41664. private _onVRRequestPresentStart;
  41665. private _onVRRequestPresentComplete;
  41666. /**
  41667. * Observable raised when entering VR.
  41668. */
  41669. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41670. /**
  41671. * Observable raised when exiting VR.
  41672. */
  41673. onExitingVRObservable: Observable<VRExperienceHelper>;
  41674. /**
  41675. * Observable raised when controller mesh is loaded.
  41676. */
  41677. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41678. /** Return this.onEnteringVRObservable
  41679. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41680. */
  41681. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41682. /** Return this.onExitingVRObservable
  41683. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41684. */
  41685. readonly onExitingVR: Observable<VRExperienceHelper>;
  41686. /** Return this.onControllerMeshLoadedObservable
  41687. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41688. */
  41689. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41690. private _rayLength;
  41691. private _useCustomVRButton;
  41692. private _teleportationRequested;
  41693. private _teleportActive;
  41694. private _floorMeshName;
  41695. private _floorMeshesCollection;
  41696. private _rotationAllowed;
  41697. private _teleportBackwardsVector;
  41698. private _teleportationTarget;
  41699. private _isDefaultTeleportationTarget;
  41700. private _postProcessMove;
  41701. private _teleportationFillColor;
  41702. private _teleportationBorderColor;
  41703. private _rotationAngle;
  41704. private _haloCenter;
  41705. private _cameraGazer;
  41706. private _padSensibilityUp;
  41707. private _padSensibilityDown;
  41708. private _leftController;
  41709. private _rightController;
  41710. /**
  41711. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41712. */
  41713. onNewMeshSelected: Observable<AbstractMesh>;
  41714. /**
  41715. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41716. */
  41717. onNewMeshPicked: Observable<PickingInfo>;
  41718. private _circleEase;
  41719. /**
  41720. * Observable raised before camera teleportation
  41721. */
  41722. onBeforeCameraTeleport: Observable<Vector3>;
  41723. /**
  41724. * Observable raised after camera teleportation
  41725. */
  41726. onAfterCameraTeleport: Observable<Vector3>;
  41727. /**
  41728. * Observable raised when current selected mesh gets unselected
  41729. */
  41730. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41731. private _raySelectionPredicate;
  41732. /**
  41733. * To be optionaly changed by user to define custom ray selection
  41734. */
  41735. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41736. /**
  41737. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41738. */
  41739. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41740. /**
  41741. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41742. */
  41743. teleportationEnabled: boolean;
  41744. private _defaultHeight;
  41745. private _teleportationInitialized;
  41746. private _interactionsEnabled;
  41747. private _interactionsRequested;
  41748. private _displayGaze;
  41749. private _displayLaserPointer;
  41750. /**
  41751. * The mesh used to display where the user is going to teleport.
  41752. */
  41753. /**
  41754. * Sets the mesh to be used to display where the user is going to teleport.
  41755. */
  41756. teleportationTarget: Mesh;
  41757. /**
  41758. * 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
  41759. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41760. * See http://doc.babylonjs.com/resources/baking_transformations
  41761. */
  41762. gazeTrackerMesh: Mesh;
  41763. /**
  41764. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41765. */
  41766. updateGazeTrackerScale: boolean;
  41767. /**
  41768. * The gaze tracking mesh corresponding to the left controller
  41769. */
  41770. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41771. /**
  41772. * The gaze tracking mesh corresponding to the right controller
  41773. */
  41774. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41775. /**
  41776. * If the ray of the gaze should be displayed.
  41777. */
  41778. /**
  41779. * Sets if the ray of the gaze should be displayed.
  41780. */
  41781. displayGaze: boolean;
  41782. /**
  41783. * If the ray of the LaserPointer should be displayed.
  41784. */
  41785. /**
  41786. * Sets if the ray of the LaserPointer should be displayed.
  41787. */
  41788. displayLaserPointer: boolean;
  41789. /**
  41790. * The deviceOrientationCamera used as the camera when not in VR.
  41791. */
  41792. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41793. /**
  41794. * Based on the current WebVR support, returns the current VR camera used.
  41795. */
  41796. readonly currentVRCamera: Nullable<Camera>;
  41797. /**
  41798. * The webVRCamera which is used when in VR.
  41799. */
  41800. readonly webVRCamera: WebVRFreeCamera;
  41801. /**
  41802. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41803. */
  41804. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41805. private readonly _teleportationRequestInitiated;
  41806. /**
  41807. * Instantiates a VRExperienceHelper.
  41808. * Helps to quickly add VR support to an existing scene.
  41809. * @param scene The scene the VRExperienceHelper belongs to.
  41810. * @param webVROptions Options to modify the vr experience helper's behavior.
  41811. */
  41812. constructor(scene: Scene,
  41813. /** Options to modify the vr experience helper's behavior. */
  41814. webVROptions?: VRExperienceHelperOptions);
  41815. private _onDefaultMeshLoaded;
  41816. private _onResize;
  41817. private _onFullscreenChange;
  41818. /**
  41819. * Gets a value indicating if we are currently in VR mode.
  41820. */
  41821. readonly isInVRMode: boolean;
  41822. private onVrDisplayPresentChange;
  41823. private onVRDisplayChanged;
  41824. private moveButtonToBottomRight;
  41825. private displayVRButton;
  41826. private updateButtonVisibility;
  41827. private _cachedAngularSensibility;
  41828. /**
  41829. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41830. * Otherwise, will use the fullscreen API.
  41831. */
  41832. enterVR(): void;
  41833. /**
  41834. * Attempt to exit VR, or fullscreen.
  41835. */
  41836. exitVR(): void;
  41837. /**
  41838. * The position of the vr experience helper.
  41839. */
  41840. /**
  41841. * Sets the position of the vr experience helper.
  41842. */
  41843. position: Vector3;
  41844. /**
  41845. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41846. */
  41847. enableInteractions(): void;
  41848. private readonly _noControllerIsActive;
  41849. private beforeRender;
  41850. private _isTeleportationFloor;
  41851. /**
  41852. * Adds a floor mesh to be used for teleportation.
  41853. * @param floorMesh the mesh to be used for teleportation.
  41854. */
  41855. addFloorMesh(floorMesh: Mesh): void;
  41856. /**
  41857. * Removes a floor mesh from being used for teleportation.
  41858. * @param floorMesh the mesh to be removed.
  41859. */
  41860. removeFloorMesh(floorMesh: Mesh): void;
  41861. /**
  41862. * Enables interactions and teleportation using the VR controllers and gaze.
  41863. * @param vrTeleportationOptions options to modify teleportation behavior.
  41864. */
  41865. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41866. private _onNewGamepadConnected;
  41867. private _tryEnableInteractionOnController;
  41868. private _onNewGamepadDisconnected;
  41869. private _enableInteractionOnController;
  41870. private _checkTeleportWithRay;
  41871. private _checkRotate;
  41872. private _checkTeleportBackwards;
  41873. private _enableTeleportationOnController;
  41874. private _createTeleportationCircles;
  41875. private _displayTeleportationTarget;
  41876. private _hideTeleportationTarget;
  41877. private _rotateCamera;
  41878. private _moveTeleportationSelectorTo;
  41879. private _workingVector;
  41880. private _workingQuaternion;
  41881. private _workingMatrix;
  41882. /**
  41883. * Teleports the users feet to the desired location
  41884. * @param location The location where the user's feet should be placed
  41885. */
  41886. teleportCamera(location: Vector3): void;
  41887. private _convertNormalToDirectionOfRay;
  41888. private _castRayAndSelectObject;
  41889. private _notifySelectedMeshUnselected;
  41890. /**
  41891. * Sets the color of the laser ray from the vr controllers.
  41892. * @param color new color for the ray.
  41893. */
  41894. changeLaserColor(color: Color3): void;
  41895. /**
  41896. * Sets the color of the ray from the vr headsets gaze.
  41897. * @param color new color for the ray.
  41898. */
  41899. changeGazeColor(color: Color3): void;
  41900. /**
  41901. * Exits VR and disposes of the vr experience helper
  41902. */
  41903. dispose(): void;
  41904. /**
  41905. * Gets the name of the VRExperienceHelper class
  41906. * @returns "VRExperienceHelper"
  41907. */
  41908. getClassName(): string;
  41909. }
  41910. }
  41911. declare module BABYLON {
  41912. /**
  41913. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  41914. * IMPORTANT!! The data is right-hand data.
  41915. * @export
  41916. * @interface DevicePose
  41917. */
  41918. interface DevicePose {
  41919. /**
  41920. * The position of the device, values in array are [x,y,z].
  41921. */
  41922. readonly position: Nullable<Float32Array>;
  41923. /**
  41924. * The linearVelocity of the device, values in array are [x,y,z].
  41925. */
  41926. readonly linearVelocity: Nullable<Float32Array>;
  41927. /**
  41928. * The linearAcceleration of the device, values in array are [x,y,z].
  41929. */
  41930. readonly linearAcceleration: Nullable<Float32Array>;
  41931. /**
  41932. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  41933. */
  41934. readonly orientation: Nullable<Float32Array>;
  41935. /**
  41936. * The angularVelocity of the device, values in array are [x,y,z].
  41937. */
  41938. readonly angularVelocity: Nullable<Float32Array>;
  41939. /**
  41940. * The angularAcceleration of the device, values in array are [x,y,z].
  41941. */
  41942. readonly angularAcceleration: Nullable<Float32Array>;
  41943. }
  41944. /**
  41945. * Interface representing a pose controlled object in Babylon.
  41946. * A pose controlled object has both regular pose values as well as pose values
  41947. * from an external device such as a VR head mounted display
  41948. */
  41949. interface PoseControlled {
  41950. /**
  41951. * The position of the object in babylon space.
  41952. */
  41953. position: Vector3;
  41954. /**
  41955. * The rotation quaternion of the object in babylon space.
  41956. */
  41957. rotationQuaternion: Quaternion;
  41958. /**
  41959. * The position of the device in babylon space.
  41960. */
  41961. devicePosition?: Vector3;
  41962. /**
  41963. * The rotation quaternion of the device in babylon space.
  41964. */
  41965. deviceRotationQuaternion: Quaternion;
  41966. /**
  41967. * The raw pose coming from the device.
  41968. */
  41969. rawPose: Nullable<DevicePose>;
  41970. /**
  41971. * The scale of the device to be used when translating from device space to babylon space.
  41972. */
  41973. deviceScaleFactor: number;
  41974. /**
  41975. * Updates the poseControlled values based on the input device pose.
  41976. * @param poseData the pose data to update the object with
  41977. */
  41978. updateFromDevice(poseData: DevicePose): void;
  41979. }
  41980. /**
  41981. * Set of options to customize the webVRCamera
  41982. */
  41983. interface WebVROptions {
  41984. /**
  41985. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  41986. */
  41987. trackPosition?: boolean;
  41988. /**
  41989. * Sets the scale of the vrDevice in babylon space. (default: 1)
  41990. */
  41991. positionScale?: number;
  41992. /**
  41993. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  41994. */
  41995. displayName?: string;
  41996. /**
  41997. * Should the native controller meshes be initialized. (default: true)
  41998. */
  41999. controllerMeshes?: boolean;
  42000. /**
  42001. * Creating a default HemiLight only on controllers. (default: true)
  42002. */
  42003. defaultLightingOnControllers?: boolean;
  42004. /**
  42005. * If you don't want to use the default VR button of the helper. (default: false)
  42006. */
  42007. useCustomVRButton?: boolean;
  42008. /**
  42009. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42010. */
  42011. customVRButton?: HTMLButtonElement;
  42012. /**
  42013. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42014. */
  42015. rayLength?: number;
  42016. /**
  42017. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42018. */
  42019. defaultHeight?: number;
  42020. }
  42021. /**
  42022. * This represents a WebVR camera.
  42023. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42024. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42025. */
  42026. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42027. private webVROptions;
  42028. /**
  42029. * @hidden
  42030. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42031. */
  42032. _vrDevice: any;
  42033. /**
  42034. * The rawPose of the vrDevice.
  42035. */
  42036. rawPose: Nullable<DevicePose>;
  42037. private _onVREnabled;
  42038. private _specsVersion;
  42039. private _attached;
  42040. private _frameData;
  42041. protected _descendants: Array<Node>;
  42042. private _deviceRoomPosition;
  42043. /** @hidden */
  42044. _deviceRoomRotationQuaternion: Quaternion;
  42045. private _standingMatrix;
  42046. /**
  42047. * Represents device position in babylon space.
  42048. */
  42049. devicePosition: Vector3;
  42050. /**
  42051. * Represents device rotation in babylon space.
  42052. */
  42053. deviceRotationQuaternion: Quaternion;
  42054. /**
  42055. * The scale of the device to be used when translating from device space to babylon space.
  42056. */
  42057. deviceScaleFactor: number;
  42058. private _deviceToWorld;
  42059. private _worldToDevice;
  42060. /**
  42061. * References to the webVR controllers for the vrDevice.
  42062. */
  42063. controllers: Array<WebVRController>;
  42064. /**
  42065. * Emits an event when a controller is attached.
  42066. */
  42067. onControllersAttachedObservable: Observable<WebVRController[]>;
  42068. /**
  42069. * Emits an event when a controller's mesh has been loaded;
  42070. */
  42071. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42072. /**
  42073. * Emits an event when the HMD's pose has been updated.
  42074. */
  42075. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42076. private _poseSet;
  42077. /**
  42078. * If the rig cameras be used as parent instead of this camera.
  42079. */
  42080. rigParenting: boolean;
  42081. private _lightOnControllers;
  42082. private _defaultHeight?;
  42083. /**
  42084. * Instantiates a WebVRFreeCamera.
  42085. * @param name The name of the WebVRFreeCamera
  42086. * @param position The starting anchor position for the camera
  42087. * @param scene The scene the camera belongs to
  42088. * @param webVROptions a set of customizable options for the webVRCamera
  42089. */
  42090. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42091. /**
  42092. * Gets the device distance from the ground in meters.
  42093. * @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.
  42094. */
  42095. deviceDistanceToRoomGround(): number;
  42096. /**
  42097. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42098. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42099. */
  42100. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42101. /**
  42102. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42103. * @returns A promise with a boolean set to if the standing matrix is supported.
  42104. */
  42105. useStandingMatrixAsync(): Promise<boolean>;
  42106. /**
  42107. * Disposes the camera
  42108. */
  42109. dispose(): void;
  42110. /**
  42111. * Gets a vrController by name.
  42112. * @param name The name of the controller to retreive
  42113. * @returns the controller matching the name specified or null if not found
  42114. */
  42115. getControllerByName(name: string): Nullable<WebVRController>;
  42116. private _leftController;
  42117. /**
  42118. * The controller corrisponding to the users left hand.
  42119. */
  42120. readonly leftController: Nullable<WebVRController>;
  42121. private _rightController;
  42122. /**
  42123. * The controller corrisponding to the users right hand.
  42124. */
  42125. readonly rightController: Nullable<WebVRController>;
  42126. /**
  42127. * Casts a ray forward from the vrCamera's gaze.
  42128. * @param length Length of the ray (default: 100)
  42129. * @returns the ray corrisponding to the gaze
  42130. */
  42131. getForwardRay(length?: number): Ray;
  42132. /**
  42133. * @hidden
  42134. * Updates the camera based on device's frame data
  42135. */
  42136. _checkInputs(): void;
  42137. /**
  42138. * Updates the poseControlled values based on the input device pose.
  42139. * @param poseData Pose coming from the device
  42140. */
  42141. updateFromDevice(poseData: DevicePose): void;
  42142. private _htmlElementAttached;
  42143. private _detachIfAttached;
  42144. /**
  42145. * WebVR's attach control will start broadcasting frames to the device.
  42146. * Note that in certain browsers (chrome for example) this function must be called
  42147. * within a user-interaction callback. Example:
  42148. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42149. *
  42150. * @param element html element to attach the vrDevice to
  42151. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42152. */
  42153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42154. /**
  42155. * Detaches the camera from the html element and disables VR
  42156. *
  42157. * @param element html element to detach from
  42158. */
  42159. detachControl(element: HTMLElement): void;
  42160. /**
  42161. * @returns the name of this class
  42162. */
  42163. getClassName(): string;
  42164. /**
  42165. * Calls resetPose on the vrDisplay
  42166. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42167. */
  42168. resetToCurrentRotation(): void;
  42169. /**
  42170. * @hidden
  42171. * Updates the rig cameras (left and right eye)
  42172. */
  42173. _updateRigCameras(): void;
  42174. private _workingVector;
  42175. private _oneVector;
  42176. private _workingMatrix;
  42177. private updateCacheCalled;
  42178. private _correctPositionIfNotTrackPosition;
  42179. /**
  42180. * @hidden
  42181. * Updates the cached values of the camera
  42182. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42183. */
  42184. _updateCache(ignoreParentClass?: boolean): void;
  42185. /**
  42186. * @hidden
  42187. * Get current device position in babylon world
  42188. */
  42189. _computeDevicePosition(): void;
  42190. /**
  42191. * Updates the current device position and rotation in the babylon world
  42192. */
  42193. update(): void;
  42194. /**
  42195. * @hidden
  42196. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  42197. * @returns an identity matrix
  42198. */
  42199. _getViewMatrix(): Matrix;
  42200. private _tmpMatrix;
  42201. /**
  42202. * This function is called by the two RIG cameras.
  42203. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  42204. */
  42205. protected _getWebVRViewMatrix(): Matrix;
  42206. protected _getWebVRProjectionMatrix(): Matrix;
  42207. private _onGamepadConnectedObserver;
  42208. private _onGamepadDisconnectedObserver;
  42209. private _updateCacheWhenTrackingDisabledObserver;
  42210. /**
  42211. * Initializes the controllers and their meshes
  42212. */
  42213. initControllers(): void;
  42214. }
  42215. }
  42216. declare module BABYLON {
  42217. /**
  42218. * WebXR Camera which holds the views for the xrSession
  42219. * @see https://doc.babylonjs.com/how_to/webxr
  42220. */
  42221. class WebXRCamera extends FreeCamera {
  42222. private static _TmpMatrix;
  42223. /**
  42224. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42225. * @param name the name of the camera
  42226. * @param scene the scene to add the camera to
  42227. */
  42228. constructor(name: string, scene: BABYLON.Scene);
  42229. private _updateNumberOfRigCameras;
  42230. /** @hidden */
  42231. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42232. /**
  42233. * Updates the cameras position from the current pose information of the XR session
  42234. * @param xrSessionManager the session containing pose information
  42235. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42236. */
  42237. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42238. }
  42239. }
  42240. declare module BABYLON {
  42241. /**
  42242. * Button which can be used to enter a different mode of XR
  42243. */
  42244. class WebXREnterExitUIButton {
  42245. /** button element */
  42246. element: HTMLElement;
  42247. /** XR initialization options for the button */
  42248. initializationOptions: XRSessionCreationOptions;
  42249. /**
  42250. * Creates a WebXREnterExitUIButton
  42251. * @param element button element
  42252. * @param initializationOptions XR initialization options for the button
  42253. */
  42254. constructor(
  42255. /** button element */
  42256. element: HTMLElement,
  42257. /** XR initialization options for the button */
  42258. initializationOptions: XRSessionCreationOptions);
  42259. /**
  42260. * Overwritable function which can be used to update the button's visuals when the state changes
  42261. * @param activeButton the current active button in the UI
  42262. */
  42263. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42264. }
  42265. /**
  42266. * Options to create the webXR UI
  42267. */
  42268. class WebXREnterExitUIOptions {
  42269. /**
  42270. * Context to enter xr with
  42271. */
  42272. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42273. /**
  42274. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42275. */
  42276. customButtons?: Array<WebXREnterExitUIButton>;
  42277. }
  42278. /**
  42279. * UI to allow the user to enter/exit XR mode
  42280. */
  42281. class WebXREnterExitUI implements IDisposable {
  42282. private scene;
  42283. private _overlay;
  42284. private _buttons;
  42285. private _activeButton;
  42286. /**
  42287. * Fired every time the active button is changed.
  42288. *
  42289. * When xr is entered via a button that launches xr that button will be the callback parameter
  42290. *
  42291. * When exiting xr the callback parameter will be null)
  42292. */
  42293. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42294. /**
  42295. * Creates UI to allow the user to enter/exit XR mode
  42296. * @param scene the scene to add the ui to
  42297. * @param helper the xr experience helper to enter/exit xr with
  42298. * @param options options to configure the UI
  42299. * @returns the created ui
  42300. */
  42301. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42302. private constructor();
  42303. private _updateButtons;
  42304. /**
  42305. * Disposes of the object
  42306. */
  42307. dispose(): void;
  42308. }
  42309. }
  42310. declare module BABYLON {
  42311. /**
  42312. * States of the webXR experience
  42313. */
  42314. enum WebXRState {
  42315. /**
  42316. * Transitioning to being in XR mode
  42317. */
  42318. ENTERING_XR = 0,
  42319. /**
  42320. * Transitioning to non XR mode
  42321. */
  42322. EXITING_XR = 1,
  42323. /**
  42324. * In XR mode and presenting
  42325. */
  42326. IN_XR = 2,
  42327. /**
  42328. * Not entered XR mode
  42329. */
  42330. NOT_IN_XR = 3
  42331. }
  42332. /**
  42333. * Helper class used to enable XR
  42334. * @see https://doc.babylonjs.com/how_to/webxr
  42335. */
  42336. class WebXRExperienceHelper implements IDisposable {
  42337. private scene;
  42338. /**
  42339. * 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
  42340. */
  42341. container: AbstractMesh;
  42342. /**
  42343. * Camera used to render xr content
  42344. */
  42345. camera: WebXRCamera;
  42346. /**
  42347. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42348. */
  42349. state: WebXRState;
  42350. private _setState;
  42351. private static _TmpVector;
  42352. /**
  42353. * Fires when the state of the experience helper has changed
  42354. */
  42355. onStateChangedObservable: Observable<WebXRState>;
  42356. /** @hidden */
  42357. _sessionManager: WebXRSessionManager;
  42358. private _nonVRCamera;
  42359. private _originalSceneAutoClear;
  42360. private _supported;
  42361. /**
  42362. * Creates the experience helper
  42363. * @param scene the scene to attach the experience helper to
  42364. * @returns a promise for the experience helper
  42365. */
  42366. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  42367. /**
  42368. * Creates a WebXRExperienceHelper
  42369. * @param scene The scene the helper should be created in
  42370. */
  42371. private constructor();
  42372. /**
  42373. * Exits XR mode and returns the scene to its original state
  42374. * @returns promise that resolves after xr mode has exited
  42375. */
  42376. exitXRAsync(): Promise<void>;
  42377. /**
  42378. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42379. * @param sessionCreationOptions options for the XR session
  42380. * @param frameOfReference frame of reference of the XR session
  42381. * @returns promise that resolves after xr mode has entered
  42382. */
  42383. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  42384. /**
  42385. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42386. * @param ray ray to cast into the environment
  42387. * @returns Promise which resolves with a collision point in the environment if it exists
  42388. */
  42389. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  42390. /**
  42391. * Updates the global position of the camera by moving the camera's container
  42392. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42393. * @param position The desired global position of the camera
  42394. */
  42395. setPositionOfCameraUsingContainer(position: Vector3): void;
  42396. /**
  42397. * Rotates the xr camera by rotating the camera's container around the camera's position
  42398. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42399. * @param rotation the desired quaternion rotation to apply to the camera
  42400. */
  42401. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42402. /**
  42403. * Checks if the creation options are supported by the xr session
  42404. * @param options creation options
  42405. * @returns true if supported
  42406. */
  42407. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42408. /**
  42409. * Disposes of the experience helper
  42410. */
  42411. dispose(): void;
  42412. }
  42413. }
  42414. declare module BABYLON {
  42415. /**
  42416. * Represents an XR input
  42417. */
  42418. class WebXRController {
  42419. /**
  42420. * 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
  42421. */
  42422. grip?: BABYLON.AbstractMesh;
  42423. /**
  42424. * Pointer which can be used to select objects or attach a visible laser to
  42425. */
  42426. pointer: BABYLON.AbstractMesh;
  42427. /**
  42428. * Creates the controller
  42429. * @see https://doc.babylonjs.com/how_to/webxr
  42430. * @param scene the scene which the controller should be associated to
  42431. */
  42432. constructor(scene: BABYLON.Scene);
  42433. /**
  42434. * Disposes of the object
  42435. */
  42436. dispose(): void;
  42437. }
  42438. /**
  42439. * XR input used to track XR inputs such as controllers/rays
  42440. */
  42441. class WebXRInput implements IDisposable {
  42442. private helper;
  42443. /**
  42444. * XR controllers being tracked
  42445. */
  42446. controllers: Array<WebXRController>;
  42447. private _tmpMatrix;
  42448. private _frameObserver;
  42449. /**
  42450. * Initializes the WebXRInput
  42451. * @param helper experience helper which the input should be created for
  42452. */
  42453. constructor(helper: WebXRExperienceHelper);
  42454. /**
  42455. * Disposes of the object
  42456. */
  42457. dispose(): void;
  42458. }
  42459. }
  42460. declare module BABYLON {
  42461. /**
  42462. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42463. */
  42464. class WebXRManagedOutputCanvas implements IDisposable {
  42465. private _canvas;
  42466. /**
  42467. * xrpresent context of the canvas which can be used to display/mirror xr content
  42468. */
  42469. canvasContext: Nullable<WebGLRenderingContext>;
  42470. /**
  42471. * Initializes the canvas to be added/removed upon entering/exiting xr
  42472. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42473. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42474. */
  42475. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42476. /**
  42477. * Disposes of the object
  42478. */
  42479. dispose(): void;
  42480. private _setManagedOutputCanvas;
  42481. private _addCanvas;
  42482. private _removeCanvas;
  42483. }
  42484. }
  42485. declare module BABYLON {
  42486. /**
  42487. * Manages an XRSession
  42488. * @see https://doc.babylonjs.com/how_to/webxr
  42489. */
  42490. class WebXRSessionManager implements IDisposable {
  42491. private scene;
  42492. /**
  42493. * Fires every time a new xrFrame arrives which can be used to update the camera
  42494. */
  42495. onXRFrameObservable: Observable<any>;
  42496. /**
  42497. * Fires when the xr session is ended either by the device or manually done
  42498. */
  42499. onXRSessionEnded: Observable<any>;
  42500. /** @hidden */
  42501. _xrSession: XRSession;
  42502. /** @hidden */
  42503. _frameOfReference: XRFrameOfReference;
  42504. /** @hidden */
  42505. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42506. /** @hidden */
  42507. _currentXRFrame: Nullable<XRFrame>;
  42508. private _xrNavigator;
  42509. private _xrDevice;
  42510. private _tmpMatrix;
  42511. /**
  42512. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42513. * @param scene The scene which the session should be created for
  42514. */
  42515. constructor(scene: BABYLON.Scene);
  42516. /**
  42517. * Initializes the manager
  42518. * After initialization enterXR can be called to start an XR session
  42519. * @returns Promise which resolves after it is initialized
  42520. */
  42521. initializeAsync(): Promise<void>;
  42522. /**
  42523. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  42524. * @param sessionCreationOptions xr options to create the session with
  42525. * @param frameOfReferenceType option to configure how the xr pose is expressed
  42526. * @returns Promise which resolves after it enters XR
  42527. */
  42528. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  42529. /**
  42530. * Stops the xrSession and restores the renderloop
  42531. * @returns Promise which resolves after it exits XR
  42532. */
  42533. exitXRAsync(): Promise<void>;
  42534. /**
  42535. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42536. * @param ray ray to cast into the environment
  42537. * @returns Promise which resolves with a collision point in the environment if it exists
  42538. */
  42539. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  42540. /**
  42541. * Checks if a session would be supported for the creation options specified
  42542. * @param options creation options to check if they are supported
  42543. * @returns true if supported
  42544. */
  42545. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42546. /**
  42547. * @hidden
  42548. * Converts the render layer of xrSession to a render target
  42549. * @param session session to create render target for
  42550. * @param scene scene the new render target should be created for
  42551. */
  42552. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  42553. /**
  42554. * Disposes of the session manager
  42555. */
  42556. dispose(): void;
  42557. }
  42558. }
  42559. declare module BABYLON {
  42560. /**
  42561. * Manage the gamepad inputs to control an arc rotate camera.
  42562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42563. */
  42564. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42565. /**
  42566. * Defines the camera the input is attached to.
  42567. */
  42568. camera: ArcRotateCamera;
  42569. /**
  42570. * Defines the gamepad the input is gathering event from.
  42571. */
  42572. gamepad: Nullable<Gamepad>;
  42573. /**
  42574. * Defines the gamepad rotation sensiblity.
  42575. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42576. */
  42577. gamepadRotationSensibility: number;
  42578. /**
  42579. * Defines the gamepad move sensiblity.
  42580. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42581. */
  42582. gamepadMoveSensibility: number;
  42583. private _onGamepadConnectedObserver;
  42584. private _onGamepadDisconnectedObserver;
  42585. /**
  42586. * Attach the input controls to a specific dom element to get the input from.
  42587. * @param element Defines the element the controls should be listened from
  42588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42589. */
  42590. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42591. /**
  42592. * Detach the current controls from the specified dom element.
  42593. * @param element Defines the element to stop listening the inputs from
  42594. */
  42595. detachControl(element: Nullable<HTMLElement>): void;
  42596. /**
  42597. * Update the current camera state depending on the inputs that have been used this frame.
  42598. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42599. */
  42600. checkInputs(): void;
  42601. /**
  42602. * Gets the class name of the current intput.
  42603. * @returns the class name
  42604. */
  42605. getClassName(): string;
  42606. /**
  42607. * Get the friendly name associated with the input class.
  42608. * @returns the input friendly name
  42609. */
  42610. getSimpleName(): string;
  42611. }
  42612. }
  42613. declare module BABYLON {
  42614. /**
  42615. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42617. */
  42618. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42619. /**
  42620. * Defines the camera the input is attached to.
  42621. */
  42622. camera: ArcRotateCamera;
  42623. /**
  42624. * Defines the list of key codes associated with the up action (increase alpha)
  42625. */
  42626. keysUp: number[];
  42627. /**
  42628. * Defines the list of key codes associated with the down action (decrease alpha)
  42629. */
  42630. keysDown: number[];
  42631. /**
  42632. * Defines the list of key codes associated with the left action (increase beta)
  42633. */
  42634. keysLeft: number[];
  42635. /**
  42636. * Defines the list of key codes associated with the right action (decrease beta)
  42637. */
  42638. keysRight: number[];
  42639. /**
  42640. * Defines the list of key codes associated with the reset action.
  42641. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42642. */
  42643. keysReset: number[];
  42644. /**
  42645. * Defines the panning sensibility of the inputs.
  42646. * (How fast is the camera paning)
  42647. */
  42648. panningSensibility: number;
  42649. /**
  42650. * Defines the zooming sensibility of the inputs.
  42651. * (How fast is the camera zooming)
  42652. */
  42653. zoomingSensibility: number;
  42654. /**
  42655. * Defines wether maintaining the alt key down switch the movement mode from
  42656. * orientation to zoom.
  42657. */
  42658. useAltToZoom: boolean;
  42659. /**
  42660. * Rotation speed of the camera
  42661. */
  42662. angularSpeed: number;
  42663. private _keys;
  42664. private _ctrlPressed;
  42665. private _altPressed;
  42666. private _onCanvasBlurObserver;
  42667. private _onKeyboardObserver;
  42668. private _engine;
  42669. private _scene;
  42670. /**
  42671. * Attach the input controls to a specific dom element to get the input from.
  42672. * @param element Defines the element the controls should be listened from
  42673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42674. */
  42675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42676. /**
  42677. * Detach the current controls from the specified dom element.
  42678. * @param element Defines the element to stop listening the inputs from
  42679. */
  42680. detachControl(element: Nullable<HTMLElement>): void;
  42681. /**
  42682. * Update the current camera state depending on the inputs that have been used this frame.
  42683. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42684. */
  42685. checkInputs(): void;
  42686. /**
  42687. * Gets the class name of the current intput.
  42688. * @returns the class name
  42689. */
  42690. getClassName(): string;
  42691. /**
  42692. * Get the friendly name associated with the input class.
  42693. * @returns the input friendly name
  42694. */
  42695. getSimpleName(): string;
  42696. }
  42697. }
  42698. declare module BABYLON {
  42699. /**
  42700. * Manage the mouse wheel inputs to control an arc rotate camera.
  42701. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42702. */
  42703. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42704. /**
  42705. * Defines the camera the input is attached to.
  42706. */
  42707. camera: ArcRotateCamera;
  42708. /**
  42709. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42710. */
  42711. wheelPrecision: number;
  42712. /**
  42713. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42714. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42715. */
  42716. wheelDeltaPercentage: number;
  42717. private _wheel;
  42718. private _observer;
  42719. /**
  42720. * Attach the input controls to a specific dom element to get the input from.
  42721. * @param element Defines the element the controls should be listened from
  42722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42723. */
  42724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42725. /**
  42726. * Detach the current controls from the specified dom element.
  42727. * @param element Defines the element to stop listening the inputs from
  42728. */
  42729. detachControl(element: Nullable<HTMLElement>): void;
  42730. /**
  42731. * Gets the class name of the current intput.
  42732. * @returns the class name
  42733. */
  42734. getClassName(): string;
  42735. /**
  42736. * Get the friendly name associated with the input class.
  42737. * @returns the input friendly name
  42738. */
  42739. getSimpleName(): string;
  42740. }
  42741. }
  42742. declare module BABYLON {
  42743. /**
  42744. * Manage the pointers inputs to control an arc rotate camera.
  42745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42746. */
  42747. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  42748. /**
  42749. * Defines the camera the input is attached to.
  42750. */
  42751. camera: ArcRotateCamera;
  42752. /**
  42753. * Defines the buttons associated with the input to handle camera move.
  42754. */
  42755. buttons: number[];
  42756. /**
  42757. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42758. */
  42759. angularSensibilityX: number;
  42760. /**
  42761. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42762. */
  42763. angularSensibilityY: number;
  42764. /**
  42765. * Defines the pointer pinch precision or how fast is the camera zooming.
  42766. */
  42767. pinchPrecision: number;
  42768. /**
  42769. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  42770. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42771. */
  42772. pinchDeltaPercentage: number;
  42773. /**
  42774. * Defines the pointer panning sensibility or how fast is the camera moving.
  42775. */
  42776. panningSensibility: number;
  42777. /**
  42778. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42779. */
  42780. multiTouchPanning: boolean;
  42781. /**
  42782. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  42783. */
  42784. multiTouchPanAndZoom: boolean;
  42785. /**
  42786. * Revers pinch action direction.
  42787. */
  42788. pinchInwards: boolean;
  42789. private _isPanClick;
  42790. private _pointerInput;
  42791. private _observer;
  42792. private _onMouseMove;
  42793. private _onGestureStart;
  42794. private _onGesture;
  42795. private _MSGestureHandler;
  42796. private _onLostFocus;
  42797. private _onContextMenu;
  42798. /**
  42799. * Attach the input controls to a specific dom element to get the input from.
  42800. * @param element Defines the element the controls should be listened from
  42801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42802. */
  42803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42804. /**
  42805. * Detach the current controls from the specified dom element.
  42806. * @param element Defines the element to stop listening the inputs from
  42807. */
  42808. detachControl(element: Nullable<HTMLElement>): void;
  42809. /**
  42810. * Gets the class name of the current intput.
  42811. * @returns the class name
  42812. */
  42813. getClassName(): string;
  42814. /**
  42815. * Get the friendly name associated with the input class.
  42816. * @returns the input friendly name
  42817. */
  42818. getSimpleName(): string;
  42819. }
  42820. }
  42821. declare module BABYLON {
  42822. /**
  42823. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42825. */
  42826. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42827. /**
  42828. * Defines the camera the input is attached to.
  42829. */
  42830. camera: ArcRotateCamera;
  42831. /**
  42832. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42833. */
  42834. alphaCorrection: number;
  42835. /**
  42836. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42837. */
  42838. gammaCorrection: number;
  42839. private _alpha;
  42840. private _gamma;
  42841. private _dirty;
  42842. private _deviceOrientationHandler;
  42843. /**
  42844. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42845. */
  42846. constructor();
  42847. /**
  42848. * Attach the input controls to a specific dom element to get the input from.
  42849. * @param element Defines the element the controls should be listened from
  42850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42851. */
  42852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42853. /** @hidden */
  42854. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42855. /**
  42856. * Update the current camera state depending on the inputs that have been used this frame.
  42857. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42858. */
  42859. checkInputs(): void;
  42860. /**
  42861. * Detach the current controls from the specified dom element.
  42862. * @param element Defines the element to stop listening the inputs from
  42863. */
  42864. detachControl(element: Nullable<HTMLElement>): void;
  42865. /**
  42866. * Gets the class name of the current intput.
  42867. * @returns the class name
  42868. */
  42869. getClassName(): string;
  42870. /**
  42871. * Get the friendly name associated with the input class.
  42872. * @returns the input friendly name
  42873. */
  42874. getSimpleName(): string;
  42875. }
  42876. }
  42877. declare module BABYLON {
  42878. /**
  42879. * Listen to keyboard events to control the camera.
  42880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42881. */
  42882. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  42883. /**
  42884. * Defines the camera the input is attached to.
  42885. */
  42886. camera: FlyCamera;
  42887. /**
  42888. * The list of keyboard keys used to control the forward move of the camera.
  42889. */
  42890. keysForward: number[];
  42891. /**
  42892. * The list of keyboard keys used to control the backward move of the camera.
  42893. */
  42894. keysBackward: number[];
  42895. /**
  42896. * The list of keyboard keys used to control the forward move of the camera.
  42897. */
  42898. keysUp: number[];
  42899. /**
  42900. * The list of keyboard keys used to control the backward move of the camera.
  42901. */
  42902. keysDown: number[];
  42903. /**
  42904. * The list of keyboard keys used to control the right strafe move of the camera.
  42905. */
  42906. keysRight: number[];
  42907. /**
  42908. * The list of keyboard keys used to control the left strafe move of the camera.
  42909. */
  42910. keysLeft: number[];
  42911. private _keys;
  42912. private _onCanvasBlurObserver;
  42913. private _onKeyboardObserver;
  42914. private _engine;
  42915. private _scene;
  42916. /**
  42917. * Attach the input controls to a specific dom element to get the input from.
  42918. * @param element Defines the element the controls should be listened from
  42919. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42920. */
  42921. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42922. /**
  42923. * Detach the current controls from the specified dom element.
  42924. * @param element Defines the element to stop listening the inputs from
  42925. */
  42926. detachControl(element: Nullable<HTMLElement>): void;
  42927. /**
  42928. * Gets the class name of the current intput.
  42929. * @returns the class name
  42930. */
  42931. getClassName(): string;
  42932. /** @hidden */
  42933. _onLostFocus(e: FocusEvent): void;
  42934. /**
  42935. * Get the friendly name associated with the input class.
  42936. * @returns the input friendly name
  42937. */
  42938. getSimpleName(): string;
  42939. /**
  42940. * Update the current camera state depending on the inputs that have been used this frame.
  42941. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42942. */
  42943. checkInputs(): void;
  42944. }
  42945. }
  42946. declare module BABYLON {
  42947. /**
  42948. * Listen to mouse events to control the camera.
  42949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42950. */
  42951. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42952. /**
  42953. * Defines the camera the input is attached to.
  42954. */
  42955. camera: FlyCamera;
  42956. /**
  42957. * Defines if touch is enabled. (Default is true.)
  42958. */
  42959. touchEnabled: boolean;
  42960. /**
  42961. * Defines the buttons associated with the input to handle camera rotation.
  42962. */
  42963. buttons: number[];
  42964. /**
  42965. * Assign buttons for Yaw control.
  42966. */
  42967. buttonsYaw: number[];
  42968. /**
  42969. * Assign buttons for Pitch control.
  42970. */
  42971. buttonsPitch: number[];
  42972. /**
  42973. * Assign buttons for Roll control.
  42974. */
  42975. buttonsRoll: number[];
  42976. /**
  42977. * Detect if any button is being pressed while mouse is moved.
  42978. * -1 = Mouse locked.
  42979. * 0 = Left button.
  42980. * 1 = Middle Button.
  42981. * 2 = Right Button.
  42982. */
  42983. activeButton: number;
  42984. /**
  42985. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42986. * Higher values reduce its sensitivity.
  42987. */
  42988. angularSensibility: number;
  42989. private _mousemoveCallback;
  42990. private _observer;
  42991. private _rollObserver;
  42992. private previousPosition;
  42993. private noPreventDefault;
  42994. private element;
  42995. /**
  42996. * Listen to mouse events to control the camera.
  42997. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42999. */
  43000. constructor(touchEnabled?: boolean);
  43001. /**
  43002. * Attach the mouse control to the HTML DOM element.
  43003. * @param element Defines the element that listens to the input events.
  43004. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43005. */
  43006. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43007. /**
  43008. * Detach the current controls from the specified dom element.
  43009. * @param element Defines the element to stop listening the inputs from
  43010. */
  43011. detachControl(element: Nullable<HTMLElement>): void;
  43012. /**
  43013. * Gets the class name of the current input.
  43014. * @returns the class name.
  43015. */
  43016. getClassName(): string;
  43017. /**
  43018. * Get the friendly name associated with the input class.
  43019. * @returns the input's friendly name.
  43020. */
  43021. getSimpleName(): string;
  43022. private _pointerInput;
  43023. private _onMouseMove;
  43024. /**
  43025. * Rotate camera by mouse offset.
  43026. */
  43027. private rotateCamera;
  43028. }
  43029. }
  43030. declare module BABYLON {
  43031. /**
  43032. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43033. * Screen rotation is taken into account.
  43034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43035. */
  43036. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43037. private _camera;
  43038. private _screenOrientationAngle;
  43039. private _constantTranform;
  43040. private _screenQuaternion;
  43041. private _alpha;
  43042. private _beta;
  43043. private _gamma;
  43044. /**
  43045. * Instantiates a new input
  43046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43047. */
  43048. constructor();
  43049. /**
  43050. * Define the camera controlled by the input.
  43051. */
  43052. camera: FreeCamera;
  43053. /**
  43054. * Attach the input controls to a specific dom element to get the input from.
  43055. * @param element Defines the element the controls should be listened from
  43056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43057. */
  43058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43059. private _orientationChanged;
  43060. private _deviceOrientation;
  43061. /**
  43062. * Detach the current controls from the specified dom element.
  43063. * @param element Defines the element to stop listening the inputs from
  43064. */
  43065. detachControl(element: Nullable<HTMLElement>): void;
  43066. /**
  43067. * Update the current camera state depending on the inputs that have been used this frame.
  43068. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43069. */
  43070. checkInputs(): void;
  43071. /**
  43072. * Gets the class name of the current intput.
  43073. * @returns the class name
  43074. */
  43075. getClassName(): string;
  43076. /**
  43077. * Get the friendly name associated with the input class.
  43078. * @returns the input friendly name
  43079. */
  43080. getSimpleName(): string;
  43081. }
  43082. }
  43083. declare module BABYLON {
  43084. /**
  43085. * Manage the gamepad inputs to control a free camera.
  43086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43087. */
  43088. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43089. /**
  43090. * Define the camera the input is attached to.
  43091. */
  43092. camera: FreeCamera;
  43093. /**
  43094. * Define the Gamepad controlling the input
  43095. */
  43096. gamepad: Nullable<Gamepad>;
  43097. /**
  43098. * Defines the gamepad rotation sensiblity.
  43099. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43100. */
  43101. gamepadAngularSensibility: number;
  43102. /**
  43103. * Defines the gamepad move sensiblity.
  43104. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43105. */
  43106. gamepadMoveSensibility: number;
  43107. private _onGamepadConnectedObserver;
  43108. private _onGamepadDisconnectedObserver;
  43109. private _cameraTransform;
  43110. private _deltaTransform;
  43111. private _vector3;
  43112. private _vector2;
  43113. /**
  43114. * Attach the input controls to a specific dom element to get the input from.
  43115. * @param element Defines the element the controls should be listened from
  43116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43117. */
  43118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43119. /**
  43120. * Detach the current controls from the specified dom element.
  43121. * @param element Defines the element to stop listening the inputs from
  43122. */
  43123. detachControl(element: Nullable<HTMLElement>): void;
  43124. /**
  43125. * Update the current camera state depending on the inputs that have been used this frame.
  43126. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43127. */
  43128. checkInputs(): void;
  43129. /**
  43130. * Gets the class name of the current intput.
  43131. * @returns the class name
  43132. */
  43133. getClassName(): string;
  43134. /**
  43135. * Get the friendly name associated with the input class.
  43136. * @returns the input friendly name
  43137. */
  43138. getSimpleName(): string;
  43139. }
  43140. }
  43141. declare module BABYLON {
  43142. /**
  43143. * Manage the keyboard inputs to control the movement of a free camera.
  43144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43145. */
  43146. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  43147. /**
  43148. * Defines the camera the input is attached to.
  43149. */
  43150. camera: FreeCamera;
  43151. /**
  43152. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  43153. */
  43154. keysUp: number[];
  43155. /**
  43156. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  43157. */
  43158. keysDown: number[];
  43159. /**
  43160. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  43161. */
  43162. keysLeft: number[];
  43163. /**
  43164. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  43165. */
  43166. keysRight: number[];
  43167. private _keys;
  43168. private _onCanvasBlurObserver;
  43169. private _onKeyboardObserver;
  43170. private _engine;
  43171. private _scene;
  43172. /**
  43173. * Attach the input controls to a specific dom element to get the input from.
  43174. * @param element Defines the element the controls should be listened from
  43175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43176. */
  43177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43178. /**
  43179. * Detach the current controls from the specified dom element.
  43180. * @param element Defines the element to stop listening the inputs from
  43181. */
  43182. detachControl(element: Nullable<HTMLElement>): void;
  43183. /**
  43184. * Update the current camera state depending on the inputs that have been used this frame.
  43185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43186. */
  43187. checkInputs(): void;
  43188. /**
  43189. * Gets the class name of the current intput.
  43190. * @returns the class name
  43191. */
  43192. getClassName(): string;
  43193. /** @hidden */
  43194. _onLostFocus(e: FocusEvent): void;
  43195. /**
  43196. * Get the friendly name associated with the input class.
  43197. * @returns the input friendly name
  43198. */
  43199. getSimpleName(): string;
  43200. }
  43201. }
  43202. declare module BABYLON {
  43203. /**
  43204. * Manage the mouse inputs to control the movement of a free camera.
  43205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43206. */
  43207. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  43208. /**
  43209. * Define if touch is enabled in the mouse input
  43210. */
  43211. touchEnabled: boolean;
  43212. /**
  43213. * Defines the camera the input is attached to.
  43214. */
  43215. camera: FreeCamera;
  43216. /**
  43217. * Defines the buttons associated with the input to handle camera move.
  43218. */
  43219. buttons: number[];
  43220. /**
  43221. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  43222. */
  43223. angularSensibility: number;
  43224. private _pointerInput;
  43225. private _onMouseMove;
  43226. private _observer;
  43227. private previousPosition;
  43228. /**
  43229. * Manage the mouse inputs to control the movement of a free camera.
  43230. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43231. * @param touchEnabled Defines if touch is enabled or not
  43232. */
  43233. constructor(
  43234. /**
  43235. * Define if touch is enabled in the mouse input
  43236. */
  43237. touchEnabled?: boolean);
  43238. /**
  43239. * Attach the input controls to a specific dom element to get the input from.
  43240. * @param element Defines the element the controls should be listened from
  43241. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43242. */
  43243. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43244. /**
  43245. * Detach the current controls from the specified dom element.
  43246. * @param element Defines the element to stop listening the inputs from
  43247. */
  43248. detachControl(element: Nullable<HTMLElement>): void;
  43249. /**
  43250. * Gets the class name of the current intput.
  43251. * @returns the class name
  43252. */
  43253. getClassName(): string;
  43254. /**
  43255. * Get the friendly name associated with the input class.
  43256. * @returns the input friendly name
  43257. */
  43258. getSimpleName(): string;
  43259. }
  43260. }
  43261. declare module BABYLON {
  43262. /**
  43263. * Manage the touch inputs to control the movement of a free camera.
  43264. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43265. */
  43266. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  43267. /**
  43268. * Defines the camera the input is attached to.
  43269. */
  43270. camera: FreeCamera;
  43271. /**
  43272. * Defines the touch sensibility for rotation.
  43273. * The higher the faster.
  43274. */
  43275. touchAngularSensibility: number;
  43276. /**
  43277. * Defines the touch sensibility for move.
  43278. * The higher the faster.
  43279. */
  43280. touchMoveSensibility: number;
  43281. private _offsetX;
  43282. private _offsetY;
  43283. private _pointerPressed;
  43284. private _pointerInput;
  43285. private _observer;
  43286. private _onLostFocus;
  43287. /**
  43288. * Attach the input controls to a specific dom element to get the input from.
  43289. * @param element Defines the element the controls should be listened from
  43290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43291. */
  43292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43293. /**
  43294. * Detach the current controls from the specified dom element.
  43295. * @param element Defines the element to stop listening the inputs from
  43296. */
  43297. detachControl(element: Nullable<HTMLElement>): void;
  43298. /**
  43299. * Update the current camera state depending on the inputs that have been used this frame.
  43300. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43301. */
  43302. checkInputs(): void;
  43303. /**
  43304. * Gets the class name of the current intput.
  43305. * @returns the class name
  43306. */
  43307. getClassName(): string;
  43308. /**
  43309. * Get the friendly name associated with the input class.
  43310. * @returns the input friendly name
  43311. */
  43312. getSimpleName(): string;
  43313. }
  43314. }
  43315. declare module BABYLON {
  43316. /**
  43317. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43319. */
  43320. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43321. /**
  43322. * Defines the camera the input is attached to.
  43323. */
  43324. camera: FreeCamera;
  43325. private _leftjoystick;
  43326. private _rightjoystick;
  43327. /**
  43328. * Gets the left stick of the virtual joystick.
  43329. * @returns The virtual Joystick
  43330. */
  43331. getLeftJoystick(): VirtualJoystick;
  43332. /**
  43333. * Gets the right stick of the virtual joystick.
  43334. * @returns The virtual Joystick
  43335. */
  43336. getRightJoystick(): VirtualJoystick;
  43337. /**
  43338. * Update the current camera state depending on the inputs that have been used this frame.
  43339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43340. */
  43341. checkInputs(): void;
  43342. /**
  43343. * Attach the input controls to a specific dom element to get the input from.
  43344. * @param element Defines the element the controls should be listened from
  43345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43346. */
  43347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43348. /**
  43349. * Detach the current controls from the specified dom element.
  43350. * @param element Defines the element to stop listening the inputs from
  43351. */
  43352. detachControl(element: Nullable<HTMLElement>): void;
  43353. /**
  43354. * Gets the class name of the current intput.
  43355. * @returns the class name
  43356. */
  43357. getClassName(): string;
  43358. /**
  43359. * Get the friendly name associated with the input class.
  43360. * @returns the input friendly name
  43361. */
  43362. getSimpleName(): string;
  43363. }
  43364. }
  43365. declare module BABYLON {
  43366. /** @hidden */
  43367. class _OcclusionDataStorage {
  43368. /** @hidden */
  43369. occlusionInternalRetryCounter: number;
  43370. /** @hidden */
  43371. isOcclusionQueryInProgress: boolean;
  43372. /** @hidden */
  43373. isOccluded: boolean;
  43374. /** @hidden */
  43375. occlusionRetryCount: number;
  43376. /** @hidden */
  43377. occlusionType: number;
  43378. /** @hidden */
  43379. occlusionQueryAlgorithmType: number;
  43380. }
  43381. interface Engine {
  43382. /**
  43383. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43384. * @return the new query
  43385. */
  43386. createQuery(): WebGLQuery;
  43387. /**
  43388. * Delete and release a webGL query
  43389. * @param query defines the query to delete
  43390. * @return the current engine
  43391. */
  43392. deleteQuery(query: WebGLQuery): Engine;
  43393. /**
  43394. * Check if a given query has resolved and got its value
  43395. * @param query defines the query to check
  43396. * @returns true if the query got its value
  43397. */
  43398. isQueryResultAvailable(query: WebGLQuery): boolean;
  43399. /**
  43400. * Gets the value of a given query
  43401. * @param query defines the query to check
  43402. * @returns the value of the query
  43403. */
  43404. getQueryResult(query: WebGLQuery): number;
  43405. /**
  43406. * Initiates an occlusion query
  43407. * @param algorithmType defines the algorithm to use
  43408. * @param query defines the query to use
  43409. * @returns the current engine
  43410. * @see http://doc.babylonjs.com/features/occlusionquery
  43411. */
  43412. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43413. /**
  43414. * Ends an occlusion query
  43415. * @see http://doc.babylonjs.com/features/occlusionquery
  43416. * @param algorithmType defines the algorithm to use
  43417. * @returns the current engine
  43418. */
  43419. endOcclusionQuery(algorithmType: number): Engine;
  43420. /**
  43421. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43422. * Please note that only one query can be issued at a time
  43423. * @returns a time token used to track the time span
  43424. */
  43425. startTimeQuery(): Nullable<_TimeToken>;
  43426. /**
  43427. * Ends a time query
  43428. * @param token defines the token used to measure the time span
  43429. * @returns the time spent (in ns)
  43430. */
  43431. endTimeQuery(token: _TimeToken): int;
  43432. /** @hidden */
  43433. _currentNonTimestampToken: Nullable<_TimeToken>;
  43434. /** @hidden */
  43435. _createTimeQuery(): WebGLQuery;
  43436. /** @hidden */
  43437. _deleteTimeQuery(query: WebGLQuery): void;
  43438. /** @hidden */
  43439. _getGlAlgorithmType(algorithmType: number): number;
  43440. /** @hidden */
  43441. _getTimeQueryResult(query: WebGLQuery): any;
  43442. /** @hidden */
  43443. _getTimeQueryAvailability(query: WebGLQuery): any;
  43444. }
  43445. interface AbstractMesh {
  43446. /**
  43447. * Backing filed
  43448. * @hidden
  43449. */
  43450. __occlusionDataStorage: _OcclusionDataStorage;
  43451. /**
  43452. * Access property
  43453. * @hidden
  43454. */
  43455. _occlusionDataStorage: _OcclusionDataStorage;
  43456. /**
  43457. * 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.
  43458. * The default value is -1 which means don't break the query and wait till the result
  43459. * @see http://doc.babylonjs.com/features/occlusionquery
  43460. */
  43461. occlusionRetryCount: number;
  43462. /**
  43463. * 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:
  43464. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43465. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43466. * * 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.
  43467. * @see http://doc.babylonjs.com/features/occlusionquery
  43468. */
  43469. occlusionType: number;
  43470. /**
  43471. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43472. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43473. * * 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.
  43474. * @see http://doc.babylonjs.com/features/occlusionquery
  43475. */
  43476. occlusionQueryAlgorithmType: number;
  43477. /**
  43478. * 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
  43479. * @see http://doc.babylonjs.com/features/occlusionquery
  43480. */
  43481. isOccluded: boolean;
  43482. /**
  43483. * Flag to check the progress status of the query
  43484. * @see http://doc.babylonjs.com/features/occlusionquery
  43485. */
  43486. isOcclusionQueryInProgress: boolean;
  43487. }
  43488. }
  43489. declare module BABYLON {
  43490. interface Engine {
  43491. /**
  43492. * Creates a webGL transform feedback object
  43493. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43494. * @returns the webGL transform feedback object
  43495. */
  43496. createTransformFeedback(): WebGLTransformFeedback;
  43497. /**
  43498. * Delete a webGL transform feedback object
  43499. * @param value defines the webGL transform feedback object to delete
  43500. */
  43501. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43502. /**
  43503. * Bind a webGL transform feedback object to the webgl context
  43504. * @param value defines the webGL transform feedback object to bind
  43505. */
  43506. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43507. /**
  43508. * Begins a transform feedback operation
  43509. * @param usePoints defines if points or triangles must be used
  43510. */
  43511. beginTransformFeedback(usePoints: boolean): void;
  43512. /**
  43513. * Ends a transform feedback operation
  43514. */
  43515. endTransformFeedback(): void;
  43516. /**
  43517. * Specify the varyings to use with transform feedback
  43518. * @param program defines the associated webGL program
  43519. * @param value defines the list of strings representing the varying names
  43520. */
  43521. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43522. /**
  43523. * Bind a webGL buffer for a transform feedback operation
  43524. * @param value defines the webGL buffer to bind
  43525. */
  43526. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43527. }
  43528. }
  43529. declare module BABYLON {
  43530. /**
  43531. * Google Daydream controller
  43532. */
  43533. class DaydreamController extends WebVRController {
  43534. /**
  43535. * Base Url for the controller model.
  43536. */
  43537. static MODEL_BASE_URL: string;
  43538. /**
  43539. * File name for the controller model.
  43540. */
  43541. static MODEL_FILENAME: string;
  43542. /**
  43543. * Gamepad Id prefix used to identify Daydream Controller.
  43544. */
  43545. static readonly GAMEPAD_ID_PREFIX: string;
  43546. /**
  43547. * Creates a new DaydreamController from a gamepad
  43548. * @param vrGamepad the gamepad that the controller should be created from
  43549. */
  43550. constructor(vrGamepad: any);
  43551. /**
  43552. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43553. * @param scene scene in which to add meshes
  43554. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43555. */
  43556. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43557. /**
  43558. * Called once for each button that changed state since the last frame
  43559. * @param buttonIdx Which button index changed
  43560. * @param state New state of the button
  43561. * @param changes Which properties on the state changed since last frame
  43562. */
  43563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43564. }
  43565. }
  43566. declare module BABYLON {
  43567. /**
  43568. * Gear VR Controller
  43569. */
  43570. class GearVRController extends WebVRController {
  43571. /**
  43572. * Base Url for the controller model.
  43573. */
  43574. static MODEL_BASE_URL: string;
  43575. /**
  43576. * File name for the controller model.
  43577. */
  43578. static MODEL_FILENAME: string;
  43579. /**
  43580. * Gamepad Id prefix used to identify this controller.
  43581. */
  43582. static readonly GAMEPAD_ID_PREFIX: string;
  43583. private readonly _buttonIndexToObservableNameMap;
  43584. /**
  43585. * Creates a new GearVRController from a gamepad
  43586. * @param vrGamepad the gamepad that the controller should be created from
  43587. */
  43588. constructor(vrGamepad: any);
  43589. /**
  43590. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43591. * @param scene scene in which to add meshes
  43592. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43593. */
  43594. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43595. /**
  43596. * Called once for each button that changed state since the last frame
  43597. * @param buttonIdx Which button index changed
  43598. * @param state New state of the button
  43599. * @param changes Which properties on the state changed since last frame
  43600. */
  43601. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43602. }
  43603. }
  43604. declare module BABYLON {
  43605. /**
  43606. * Generic Controller
  43607. */
  43608. class GenericController extends WebVRController {
  43609. /**
  43610. * Base Url for the controller model.
  43611. */
  43612. static readonly MODEL_BASE_URL: string;
  43613. /**
  43614. * File name for the controller model.
  43615. */
  43616. static readonly MODEL_FILENAME: string;
  43617. /**
  43618. * Creates a new GenericController from a gamepad
  43619. * @param vrGamepad the gamepad that the controller should be created from
  43620. */
  43621. constructor(vrGamepad: any);
  43622. /**
  43623. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43624. * @param scene scene in which to add meshes
  43625. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43626. */
  43627. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43628. /**
  43629. * Called once for each button that changed state since the last frame
  43630. * @param buttonIdx Which button index changed
  43631. * @param state New state of the button
  43632. * @param changes Which properties on the state changed since last frame
  43633. */
  43634. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43635. }
  43636. }
  43637. declare module BABYLON {
  43638. /**
  43639. * Oculus Touch Controller
  43640. */
  43641. class OculusTouchController extends WebVRController {
  43642. /**
  43643. * Base Url for the controller model.
  43644. */
  43645. static MODEL_BASE_URL: string;
  43646. /**
  43647. * File name for the left controller model.
  43648. */
  43649. static MODEL_LEFT_FILENAME: string;
  43650. /**
  43651. * File name for the right controller model.
  43652. */
  43653. static MODEL_RIGHT_FILENAME: string;
  43654. /**
  43655. * Fired when the secondary trigger on this controller is modified
  43656. */
  43657. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43658. /**
  43659. * Fired when the thumb rest on this controller is modified
  43660. */
  43661. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43662. /**
  43663. * Creates a new OculusTouchController from a gamepad
  43664. * @param vrGamepad the gamepad that the controller should be created from
  43665. */
  43666. constructor(vrGamepad: any);
  43667. /**
  43668. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43669. * @param scene scene in which to add meshes
  43670. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43671. */
  43672. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43673. /**
  43674. * Fired when the A button on this controller is modified
  43675. */
  43676. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43677. /**
  43678. * Fired when the B button on this controller is modified
  43679. */
  43680. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43681. /**
  43682. * Fired when the X button on this controller is modified
  43683. */
  43684. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43685. /**
  43686. * Fired when the Y button on this controller is modified
  43687. */
  43688. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43689. /**
  43690. * Called once for each button that changed state since the last frame
  43691. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43692. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43693. * 2) secondary trigger (same)
  43694. * 3) A (right) X (left), touch, pressed = value
  43695. * 4) B / Y
  43696. * 5) thumb rest
  43697. * @param buttonIdx Which button index changed
  43698. * @param state New state of the button
  43699. * @param changes Which properties on the state changed since last frame
  43700. */
  43701. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43702. }
  43703. }
  43704. declare module BABYLON {
  43705. /**
  43706. * Defines the types of pose enabled controllers that are supported
  43707. */
  43708. enum PoseEnabledControllerType {
  43709. /**
  43710. * HTC Vive
  43711. */
  43712. VIVE = 0,
  43713. /**
  43714. * Oculus Rift
  43715. */
  43716. OCULUS = 1,
  43717. /**
  43718. * Windows mixed reality
  43719. */
  43720. WINDOWS = 2,
  43721. /**
  43722. * Samsung gear VR
  43723. */
  43724. GEAR_VR = 3,
  43725. /**
  43726. * Google Daydream
  43727. */
  43728. DAYDREAM = 4,
  43729. /**
  43730. * Generic
  43731. */
  43732. GENERIC = 5
  43733. }
  43734. /**
  43735. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43736. */
  43737. interface MutableGamepadButton {
  43738. /**
  43739. * Value of the button/trigger
  43740. */
  43741. value: number;
  43742. /**
  43743. * If the button/trigger is currently touched
  43744. */
  43745. touched: boolean;
  43746. /**
  43747. * If the button/trigger is currently pressed
  43748. */
  43749. pressed: boolean;
  43750. }
  43751. /**
  43752. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43753. * @hidden
  43754. */
  43755. interface ExtendedGamepadButton extends GamepadButton {
  43756. /**
  43757. * If the button/trigger is currently pressed
  43758. */
  43759. readonly pressed: boolean;
  43760. /**
  43761. * If the button/trigger is currently touched
  43762. */
  43763. readonly touched: boolean;
  43764. /**
  43765. * Value of the button/trigger
  43766. */
  43767. readonly value: number;
  43768. }
  43769. /**
  43770. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43771. */
  43772. class PoseEnabledControllerHelper {
  43773. /**
  43774. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43775. * @param vrGamepad the gamepad to initialized
  43776. * @returns a vr controller of the type the gamepad identified as
  43777. */
  43778. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43779. }
  43780. /**
  43781. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43782. */
  43783. class PoseEnabledController extends Gamepad implements PoseControlled {
  43784. private _deviceRoomPosition;
  43785. private _deviceRoomRotationQuaternion;
  43786. /**
  43787. * The device position in babylon space
  43788. */
  43789. devicePosition: Vector3;
  43790. /**
  43791. * The device rotation in babylon space
  43792. */
  43793. deviceRotationQuaternion: Quaternion;
  43794. /**
  43795. * The scale factor of the device in babylon space
  43796. */
  43797. deviceScaleFactor: number;
  43798. /**
  43799. * (Likely devicePosition should be used instead) The device position in its room space
  43800. */
  43801. position: Vector3;
  43802. /**
  43803. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  43804. */
  43805. rotationQuaternion: Quaternion;
  43806. /**
  43807. * The type of controller (Eg. Windows mixed reality)
  43808. */
  43809. controllerType: PoseEnabledControllerType;
  43810. protected _calculatedPosition: Vector3;
  43811. private _calculatedRotation;
  43812. /**
  43813. * The raw pose from the device
  43814. */
  43815. rawPose: DevicePose;
  43816. private _trackPosition;
  43817. private _maxRotationDistFromHeadset;
  43818. private _draggedRoomRotation;
  43819. /**
  43820. * @hidden
  43821. */
  43822. _disableTrackPosition(fixedPosition: Vector3): void;
  43823. /**
  43824. * Internal, the mesh attached to the controller
  43825. * @hidden
  43826. */
  43827. _mesh: Nullable<AbstractMesh>;
  43828. private _poseControlledCamera;
  43829. private _leftHandSystemQuaternion;
  43830. /**
  43831. * Internal, matrix used to convert room space to babylon space
  43832. * @hidden
  43833. */
  43834. _deviceToWorld: Matrix;
  43835. /**
  43836. * Node to be used when casting a ray from the controller
  43837. * @hidden
  43838. */
  43839. _pointingPoseNode: Nullable<TransformNode>;
  43840. /**
  43841. * Name of the child mesh that can be used to cast a ray from the controller
  43842. */
  43843. static readonly POINTING_POSE: string;
  43844. /**
  43845. * Creates a new PoseEnabledController from a gamepad
  43846. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  43847. */
  43848. constructor(browserGamepad: any);
  43849. private _workingMatrix;
  43850. /**
  43851. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  43852. */
  43853. update(): void;
  43854. /**
  43855. * Updates only the pose device and mesh without doing any button event checking
  43856. */
  43857. protected _updatePoseAndMesh(): void;
  43858. /**
  43859. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  43860. * @param poseData raw pose fromthe device
  43861. */
  43862. updateFromDevice(poseData: DevicePose): void;
  43863. /**
  43864. * @hidden
  43865. */
  43866. _meshAttachedObservable: Observable<AbstractMesh>;
  43867. /**
  43868. * Attaches a mesh to the controller
  43869. * @param mesh the mesh to be attached
  43870. */
  43871. attachToMesh(mesh: AbstractMesh): void;
  43872. /**
  43873. * Attaches the controllers mesh to a camera
  43874. * @param camera the camera the mesh should be attached to
  43875. */
  43876. attachToPoseControlledCamera(camera: TargetCamera): void;
  43877. /**
  43878. * Disposes of the controller
  43879. */
  43880. dispose(): void;
  43881. /**
  43882. * The mesh that is attached to the controller
  43883. */
  43884. readonly mesh: Nullable<AbstractMesh>;
  43885. /**
  43886. * Gets the ray of the controller in the direction the controller is pointing
  43887. * @param length the length the resulting ray should be
  43888. * @returns a ray in the direction the controller is pointing
  43889. */
  43890. getForwardRay(length?: number): Ray;
  43891. }
  43892. }
  43893. declare module BABYLON {
  43894. /**
  43895. * Vive Controller
  43896. */
  43897. class ViveController extends WebVRController {
  43898. /**
  43899. * Base Url for the controller model.
  43900. */
  43901. static MODEL_BASE_URL: string;
  43902. /**
  43903. * File name for the controller model.
  43904. */
  43905. static MODEL_FILENAME: string;
  43906. /**
  43907. * Creates a new ViveController from a gamepad
  43908. * @param vrGamepad the gamepad that the controller should be created from
  43909. */
  43910. constructor(vrGamepad: any);
  43911. /**
  43912. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43913. * @param scene scene in which to add meshes
  43914. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43915. */
  43916. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43917. /**
  43918. * Fired when the left button on this controller is modified
  43919. */
  43920. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43921. /**
  43922. * Fired when the right button on this controller is modified
  43923. */
  43924. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43925. /**
  43926. * Fired when the menu button on this controller is modified
  43927. */
  43928. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43929. /**
  43930. * Called once for each button that changed state since the last frame
  43931. * Vive mapping:
  43932. * 0: touchpad
  43933. * 1: trigger
  43934. * 2: left AND right buttons
  43935. * 3: menu button
  43936. * @param buttonIdx Which button index changed
  43937. * @param state New state of the button
  43938. * @param changes Which properties on the state changed since last frame
  43939. */
  43940. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43941. }
  43942. }
  43943. declare module BABYLON {
  43944. /**
  43945. * Defines the WebVRController object that represents controllers tracked in 3D space
  43946. */
  43947. abstract class WebVRController extends PoseEnabledController {
  43948. /**
  43949. * Internal, the default controller model for the controller
  43950. */
  43951. protected _defaultModel: AbstractMesh;
  43952. /**
  43953. * Fired when the trigger state has changed
  43954. */
  43955. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43956. /**
  43957. * Fired when the main button state has changed
  43958. */
  43959. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43960. /**
  43961. * Fired when the secondary button state has changed
  43962. */
  43963. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43964. /**
  43965. * Fired when the pad state has changed
  43966. */
  43967. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  43968. /**
  43969. * Fired when controllers stick values have changed
  43970. */
  43971. onPadValuesChangedObservable: Observable<StickValues>;
  43972. /**
  43973. * Array of button availible on the controller
  43974. */
  43975. protected _buttons: Array<MutableGamepadButton>;
  43976. private _onButtonStateChange;
  43977. /**
  43978. * Fired when a controller button's state has changed
  43979. * @param callback the callback containing the button that was modified
  43980. */
  43981. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  43982. /**
  43983. * X and Y axis corrisponding to the controllers joystick
  43984. */
  43985. pad: StickValues;
  43986. /**
  43987. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  43988. */
  43989. hand: string;
  43990. /**
  43991. * The default controller model for the controller
  43992. */
  43993. readonly defaultModel: AbstractMesh;
  43994. /**
  43995. * Creates a new WebVRController from a gamepad
  43996. * @param vrGamepad the gamepad that the WebVRController should be created from
  43997. */
  43998. constructor(vrGamepad: any);
  43999. /**
  44000. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44001. */
  44002. update(): void;
  44003. /**
  44004. * Function to be called when a button is modified
  44005. */
  44006. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44007. /**
  44008. * Loads a mesh and attaches it to the controller
  44009. * @param scene the scene the mesh should be added to
  44010. * @param meshLoaded callback for when the mesh has been loaded
  44011. */
  44012. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44013. private _setButtonValue;
  44014. private _changes;
  44015. private _checkChanges;
  44016. /**
  44017. * Disposes of th webVRCOntroller
  44018. */
  44019. dispose(): void;
  44020. }
  44021. }
  44022. declare module BABYLON {
  44023. /**
  44024. * Defines the WindowsMotionController object that the state of the windows motion controller
  44025. */
  44026. class WindowsMotionController extends WebVRController {
  44027. /**
  44028. * The base url used to load the left and right controller models
  44029. */
  44030. static MODEL_BASE_URL: string;
  44031. /**
  44032. * The name of the left controller model file
  44033. */
  44034. static MODEL_LEFT_FILENAME: string;
  44035. /**
  44036. * The name of the right controller model file
  44037. */
  44038. static MODEL_RIGHT_FILENAME: string;
  44039. /**
  44040. * The controller name prefix for this controller type
  44041. */
  44042. static readonly GAMEPAD_ID_PREFIX: string;
  44043. /**
  44044. * The controller id pattern for this controller type
  44045. */
  44046. private static readonly GAMEPAD_ID_PATTERN;
  44047. private _loadedMeshInfo;
  44048. private readonly _mapping;
  44049. /**
  44050. * Fired when the trackpad on this controller is clicked
  44051. */
  44052. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44053. /**
  44054. * Fired when the trackpad on this controller is modified
  44055. */
  44056. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44057. /**
  44058. * The current x and y values of this controller's trackpad
  44059. */
  44060. trackpad: StickValues;
  44061. /**
  44062. * Creates a new WindowsMotionController from a gamepad
  44063. * @param vrGamepad the gamepad that the controller should be created from
  44064. */
  44065. constructor(vrGamepad: any);
  44066. /**
  44067. * Fired when the trigger on this controller is modified
  44068. */
  44069. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44070. /**
  44071. * Fired when the menu button on this controller is modified
  44072. */
  44073. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44074. /**
  44075. * Fired when the grip button on this controller is modified
  44076. */
  44077. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44078. /**
  44079. * Fired when the thumbstick button on this controller is modified
  44080. */
  44081. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44082. /**
  44083. * Fired when the touchpad button on this controller is modified
  44084. */
  44085. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44086. /**
  44087. * Fired when the touchpad values on this controller are modified
  44088. */
  44089. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44090. private _updateTrackpad;
  44091. /**
  44092. * Called once per frame by the engine.
  44093. */
  44094. update(): void;
  44095. /**
  44096. * Called once for each button that changed state since the last frame
  44097. * @param buttonIdx Which button index changed
  44098. * @param state New state of the button
  44099. * @param changes Which properties on the state changed since last frame
  44100. */
  44101. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44102. /**
  44103. * Moves the buttons on the controller mesh based on their current state
  44104. * @param buttonName the name of the button to move
  44105. * @param buttonValue the value of the button which determines the buttons new position
  44106. */
  44107. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44108. /**
  44109. * Moves the axis on the controller mesh based on its current state
  44110. * @param axis the index of the axis
  44111. * @param axisValue the value of the axis which determines the meshes new position
  44112. * @hidden
  44113. */
  44114. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44115. /**
  44116. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44117. * @param scene scene in which to add meshes
  44118. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44119. */
  44120. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44121. /**
  44122. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44123. * can be transformed by button presses and axes values, based on this._mapping.
  44124. *
  44125. * @param scene scene in which the meshes exist
  44126. * @param meshes list of meshes that make up the controller model to process
  44127. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44128. */
  44129. private processModel;
  44130. private createMeshInfo;
  44131. /**
  44132. * Gets the ray of the controller in the direction the controller is pointing
  44133. * @param length the length the resulting ray should be
  44134. * @returns a ray in the direction the controller is pointing
  44135. */
  44136. getForwardRay(length?: number): Ray;
  44137. /**
  44138. * Disposes of the controller
  44139. */
  44140. dispose(): void;
  44141. }
  44142. }
  44143. declare module BABYLON {
  44144. /**
  44145. * Interface to implement to create a shadow generator compatible with BJS.
  44146. */
  44147. interface IShadowGenerator {
  44148. /**
  44149. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44150. * @returns The render target texture if present otherwise, null
  44151. */
  44152. getShadowMap(): Nullable<RenderTargetTexture>;
  44153. /**
  44154. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44155. * @returns The render target texture if the shadow map is present otherwise, null
  44156. */
  44157. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44158. /**
  44159. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44160. * @param subMesh The submesh we want to render in the shadow map
  44161. * @param useInstances Defines wether will draw in the map using instances
  44162. * @returns true if ready otherwise, false
  44163. */
  44164. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44165. /**
  44166. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44167. * @param defines Defines of the material we want to update
  44168. * @param lightIndex Index of the light in the enabled light list of the material
  44169. */
  44170. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44171. /**
  44172. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44173. * defined in the generator but impacting the effect).
  44174. * It implies the unifroms available on the materials are the standard BJS ones.
  44175. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44176. * @param effect The effect we are binfing the information for
  44177. */
  44178. bindShadowLight(lightIndex: string, effect: Effect): void;
  44179. /**
  44180. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44181. * (eq to shadow prjection matrix * light transform matrix)
  44182. * @returns The transform matrix used to create the shadow map
  44183. */
  44184. getTransformMatrix(): Matrix;
  44185. /**
  44186. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44187. * Cube and 2D textures for instance.
  44188. */
  44189. recreateShadowMap(): void;
  44190. /**
  44191. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44192. * @param onCompiled Callback triggered at the and of the effects compilation
  44193. * @param options Sets of optional options forcing the compilation with different modes
  44194. */
  44195. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44196. useInstances: boolean;
  44197. }>): void;
  44198. /**
  44199. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44200. * @param options Sets of optional options forcing the compilation with different modes
  44201. * @returns A promise that resolves when the compilation completes
  44202. */
  44203. forceCompilationAsync(options?: Partial<{
  44204. useInstances: boolean;
  44205. }>): Promise<void>;
  44206. /**
  44207. * Serializes the shadow generator setup to a json object.
  44208. * @returns The serialized JSON object
  44209. */
  44210. serialize(): any;
  44211. /**
  44212. * Disposes the Shadow map and related Textures and effects.
  44213. */
  44214. dispose(): void;
  44215. }
  44216. /**
  44217. * Default implementation IShadowGenerator.
  44218. * This is the main object responsible of generating shadows in the framework.
  44219. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44220. */
  44221. class ShadowGenerator implements IShadowGenerator {
  44222. /**
  44223. * Shadow generator mode None: no filtering applied.
  44224. */
  44225. static readonly FILTER_NONE: number;
  44226. /**
  44227. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44228. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44229. */
  44230. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44231. /**
  44232. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44233. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44234. */
  44235. static readonly FILTER_POISSONSAMPLING: number;
  44236. /**
  44237. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44238. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44239. */
  44240. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44241. /**
  44242. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44243. * edge artifacts on steep falloff.
  44244. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44245. */
  44246. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44247. /**
  44248. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44249. * edge artifacts on steep falloff.
  44250. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44251. */
  44252. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44253. /**
  44254. * Shadow generator mode PCF: Percentage Closer Filtering
  44255. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44256. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44257. */
  44258. static readonly FILTER_PCF: number;
  44259. /**
  44260. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44261. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44262. * Contact Hardening
  44263. */
  44264. static readonly FILTER_PCSS: number;
  44265. /**
  44266. * Reserved for PCF and PCSS
  44267. * Highest Quality.
  44268. *
  44269. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44270. *
  44271. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44272. */
  44273. static readonly QUALITY_HIGH: number;
  44274. /**
  44275. * Reserved for PCF and PCSS
  44276. * Good tradeoff for quality/perf cross devices
  44277. *
  44278. * Execute PCF on a 3*3 kernel.
  44279. *
  44280. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44281. */
  44282. static readonly QUALITY_MEDIUM: number;
  44283. /**
  44284. * Reserved for PCF and PCSS
  44285. * The lowest quality but the fastest.
  44286. *
  44287. * Execute PCF on a 1*1 kernel.
  44288. *
  44289. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44290. */
  44291. static readonly QUALITY_LOW: number;
  44292. private _bias;
  44293. /**
  44294. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44295. */
  44296. /**
  44297. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44298. */
  44299. bias: number;
  44300. private _normalBias;
  44301. /**
  44302. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44303. */
  44304. /**
  44305. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44306. */
  44307. normalBias: number;
  44308. private _blurBoxOffset;
  44309. /**
  44310. * Gets the blur box offset: offset applied during the blur pass.
  44311. * Only usefull if useKernelBlur = false
  44312. */
  44313. /**
  44314. * Sets the blur box offset: offset applied during the blur pass.
  44315. * Only usefull if useKernelBlur = false
  44316. */
  44317. blurBoxOffset: number;
  44318. private _blurScale;
  44319. /**
  44320. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44321. * 2 means half of the size.
  44322. */
  44323. /**
  44324. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44325. * 2 means half of the size.
  44326. */
  44327. blurScale: number;
  44328. private _blurKernel;
  44329. /**
  44330. * Gets the blur kernel: kernel size of the blur pass.
  44331. * Only usefull if useKernelBlur = true
  44332. */
  44333. /**
  44334. * Sets the blur kernel: kernel size of the blur pass.
  44335. * Only usefull if useKernelBlur = true
  44336. */
  44337. blurKernel: number;
  44338. private _useKernelBlur;
  44339. /**
  44340. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44341. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  44342. */
  44343. /**
  44344. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44345. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  44346. */
  44347. useKernelBlur: boolean;
  44348. private _depthScale;
  44349. /**
  44350. * Gets the depth scale used in ESM mode.
  44351. */
  44352. /**
  44353. * Sets the depth scale used in ESM mode.
  44354. * This can override the scale stored on the light.
  44355. */
  44356. depthScale: number;
  44357. private _filter;
  44358. /**
  44359. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44360. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44361. */
  44362. /**
  44363. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44364. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44365. */
  44366. filter: number;
  44367. /**
  44368. * Gets if the current filter is set to Poisson Sampling.
  44369. */
  44370. /**
  44371. * Sets the current filter to Poisson Sampling.
  44372. */
  44373. usePoissonSampling: boolean;
  44374. /**
  44375. * Gets if the current filter is set to ESM.
  44376. */
  44377. /**
  44378. * Sets the current filter is to ESM.
  44379. */
  44380. useExponentialShadowMap: boolean;
  44381. /**
  44382. * Gets if the current filter is set to filtered ESM.
  44383. */
  44384. /**
  44385. * Gets if the current filter is set to filtered ESM.
  44386. */
  44387. useBlurExponentialShadowMap: boolean;
  44388. /**
  44389. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44390. * exponential to prevent steep falloff artifacts).
  44391. */
  44392. /**
  44393. * Sets the current filter to "close ESM" (using the inverse of the
  44394. * exponential to prevent steep falloff artifacts).
  44395. */
  44396. useCloseExponentialShadowMap: boolean;
  44397. /**
  44398. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44399. * exponential to prevent steep falloff artifacts).
  44400. */
  44401. /**
  44402. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44403. * exponential to prevent steep falloff artifacts).
  44404. */
  44405. useBlurCloseExponentialShadowMap: boolean;
  44406. /**
  44407. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44408. */
  44409. /**
  44410. * Sets the current filter to "PCF" (percentage closer filtering).
  44411. */
  44412. usePercentageCloserFiltering: boolean;
  44413. private _filteringQuality;
  44414. /**
  44415. * Gets the PCF or PCSS Quality.
  44416. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44417. */
  44418. /**
  44419. * Sets the PCF or PCSS Quality.
  44420. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44421. */
  44422. filteringQuality: number;
  44423. /**
  44424. * Gets if the current filter is set to "PCSS" (contact hardening).
  44425. */
  44426. /**
  44427. * Sets the current filter to "PCSS" (contact hardening).
  44428. */
  44429. useContactHardeningShadow: boolean;
  44430. private _contactHardeningLightSizeUVRatio;
  44431. /**
  44432. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44433. * Using a ratio helps keeping shape stability independently of the map size.
  44434. *
  44435. * It does not account for the light projection as it was having too much
  44436. * instability during the light setup or during light position changes.
  44437. *
  44438. * Only valid if useContactHardeningShadow is true.
  44439. */
  44440. /**
  44441. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44442. * Using a ratio helps keeping shape stability independently of the map size.
  44443. *
  44444. * It does not account for the light projection as it was having too much
  44445. * instability during the light setup or during light position changes.
  44446. *
  44447. * Only valid if useContactHardeningShadow is true.
  44448. */
  44449. contactHardeningLightSizeUVRatio: number;
  44450. private _darkness;
  44451. /**
  44452. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44453. * 0 means strongest and 1 would means no shadow.
  44454. * @returns the darkness.
  44455. */
  44456. getDarkness(): number;
  44457. /**
  44458. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44459. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44460. * @returns the shadow generator allowing fluent coding.
  44461. */
  44462. setDarkness(darkness: number): ShadowGenerator;
  44463. private _transparencyShadow;
  44464. /**
  44465. * Sets the ability to have transparent shadow (boolean).
  44466. * @param transparent True if transparent else False
  44467. * @returns the shadow generator allowing fluent coding
  44468. */
  44469. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44470. private _shadowMap;
  44471. private _shadowMap2;
  44472. /**
  44473. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44474. * @returns The render target texture if present otherwise, null
  44475. */
  44476. getShadowMap(): Nullable<RenderTargetTexture>;
  44477. /**
  44478. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44479. * @returns The render target texture if the shadow map is present otherwise, null
  44480. */
  44481. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44482. /**
  44483. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44484. * @param mesh Mesh to add
  44485. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44486. * @returns the Shadow Generator itself
  44487. */
  44488. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44489. /**
  44490. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44491. * @param mesh Mesh to remove
  44492. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44493. * @returns the Shadow Generator itself
  44494. */
  44495. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44496. /**
  44497. * Controls the extent to which the shadows fade out at the edge of the frustum
  44498. * Used only by directionals and spots
  44499. */
  44500. frustumEdgeFalloff: number;
  44501. private _light;
  44502. /**
  44503. * Returns the associated light object.
  44504. * @returns the light generating the shadow
  44505. */
  44506. getLight(): IShadowLight;
  44507. /**
  44508. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44509. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44510. * It might on the other hand introduce peter panning.
  44511. */
  44512. forceBackFacesOnly: boolean;
  44513. private _scene;
  44514. private _lightDirection;
  44515. private _effect;
  44516. private _viewMatrix;
  44517. private _projectionMatrix;
  44518. private _transformMatrix;
  44519. private _cachedPosition;
  44520. private _cachedDirection;
  44521. private _cachedDefines;
  44522. private _currentRenderID;
  44523. private _boxBlurPostprocess;
  44524. private _kernelBlurXPostprocess;
  44525. private _kernelBlurYPostprocess;
  44526. private _blurPostProcesses;
  44527. private _mapSize;
  44528. private _currentFaceIndex;
  44529. private _currentFaceIndexCache;
  44530. private _textureType;
  44531. private _defaultTextureMatrix;
  44532. /**
  44533. * Creates a ShadowGenerator object.
  44534. * A ShadowGenerator is the required tool to use the shadows.
  44535. * Each light casting shadows needs to use its own ShadowGenerator.
  44536. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  44537. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44538. * @param light The light object generating the shadows.
  44539. * @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.
  44540. */
  44541. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  44542. private _initializeGenerator;
  44543. private _initializeShadowMap;
  44544. private _initializeBlurRTTAndPostProcesses;
  44545. private _renderForShadowMap;
  44546. private _renderSubMeshForShadowMap;
  44547. private _applyFilterValues;
  44548. /**
  44549. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44550. * @param onCompiled Callback triggered at the and of the effects compilation
  44551. * @param options Sets of optional options forcing the compilation with different modes
  44552. */
  44553. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44554. useInstances: boolean;
  44555. }>): void;
  44556. /**
  44557. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44558. * @param options Sets of optional options forcing the compilation with different modes
  44559. * @returns A promise that resolves when the compilation completes
  44560. */
  44561. forceCompilationAsync(options?: Partial<{
  44562. useInstances: boolean;
  44563. }>): Promise<void>;
  44564. /**
  44565. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44566. * @param subMesh The submesh we want to render in the shadow map
  44567. * @param useInstances Defines wether will draw in the map using instances
  44568. * @returns true if ready otherwise, false
  44569. */
  44570. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44571. /**
  44572. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44573. * @param defines Defines of the material we want to update
  44574. * @param lightIndex Index of the light in the enabled light list of the material
  44575. */
  44576. prepareDefines(defines: any, lightIndex: number): void;
  44577. /**
  44578. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44579. * defined in the generator but impacting the effect).
  44580. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44581. * @param effect The effect we are binfing the information for
  44582. */
  44583. bindShadowLight(lightIndex: string, effect: Effect): void;
  44584. /**
  44585. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44586. * (eq to shadow prjection matrix * light transform matrix)
  44587. * @returns The transform matrix used to create the shadow map
  44588. */
  44589. getTransformMatrix(): Matrix;
  44590. /**
  44591. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44592. * Cube and 2D textures for instance.
  44593. */
  44594. recreateShadowMap(): void;
  44595. private _disposeBlurPostProcesses;
  44596. private _disposeRTTandPostProcesses;
  44597. /**
  44598. * Disposes the ShadowGenerator.
  44599. * Returns nothing.
  44600. */
  44601. dispose(): void;
  44602. /**
  44603. * Serializes the shadow generator setup to a json object.
  44604. * @returns The serialized JSON object
  44605. */
  44606. serialize(): any;
  44607. /**
  44608. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44609. * @param parsedShadowGenerator The JSON object to parse
  44610. * @param scene The scene to create the shadow map for
  44611. * @returns The parsed shadow generator
  44612. */
  44613. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44614. }
  44615. }
  44616. declare module BABYLON {
  44617. /**
  44618. * Defines the shadow generator component responsible to manage any shadow generators
  44619. * in a given scene.
  44620. */
  44621. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44622. /**
  44623. * The component name helpfull to identify the component in the list of scene components.
  44624. */
  44625. readonly name: string;
  44626. /**
  44627. * The scene the component belongs to.
  44628. */
  44629. scene: Scene;
  44630. /**
  44631. * Creates a new instance of the component for the given scene
  44632. * @param scene Defines the scene to register the component in
  44633. */
  44634. constructor(scene: Scene);
  44635. /**
  44636. * Registers the component in a given scene
  44637. */
  44638. register(): void;
  44639. /**
  44640. * Rebuilds the elements related to this component in case of
  44641. * context lost for instance.
  44642. */
  44643. rebuild(): void;
  44644. /**
  44645. * Serializes the component data to the specified json object
  44646. * @param serializationObject The object to serialize to
  44647. */
  44648. serialize(serializationObject: any): void;
  44649. /**
  44650. * Adds all the element from the container to the scene
  44651. * @param container the container holding the elements
  44652. */
  44653. addFromContainer(container: AbstractScene): void;
  44654. /**
  44655. * Removes all the elements in the container from the scene
  44656. * @param container contains the elements to remove
  44657. */
  44658. removeFromContainer(container: AbstractScene): void;
  44659. /**
  44660. * Rebuilds the elements related to this component in case of
  44661. * context lost for instance.
  44662. */
  44663. dispose(): void;
  44664. private _gatherRenderTargets;
  44665. }
  44666. }
  44667. declare module BABYLON {
  44668. }
  44669. declare module BABYLON {
  44670. /**
  44671. * Background material used to create an efficient environement around your scene.
  44672. */
  44673. class BackgroundMaterial extends PushMaterial {
  44674. /**
  44675. * Standard reflectance value at parallel view angle.
  44676. */
  44677. static StandardReflectance0: number;
  44678. /**
  44679. * Standard reflectance value at grazing angle.
  44680. */
  44681. static StandardReflectance90: number;
  44682. protected _primaryColor: Color3;
  44683. /**
  44684. * Key light Color (multiply against the environement texture)
  44685. */
  44686. primaryColor: Color3;
  44687. protected __perceptualColor: Nullable<Color3>;
  44688. /**
  44689. * Experimental Internal Use Only.
  44690. *
  44691. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44692. * This acts as a helper to set the primary color to a more "human friendly" value.
  44693. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44694. * output color as close as possible from the chosen value.
  44695. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44696. * part of lighting setup.)
  44697. */
  44698. _perceptualColor: Nullable<Color3>;
  44699. protected _primaryColorShadowLevel: float;
  44700. /**
  44701. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44702. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44703. */
  44704. primaryColorShadowLevel: float;
  44705. protected _primaryColorHighlightLevel: float;
  44706. /**
  44707. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44708. * The primary color is used at the level chosen to define what the white area would look.
  44709. */
  44710. primaryColorHighlightLevel: float;
  44711. protected _reflectionTexture: Nullable<BaseTexture>;
  44712. /**
  44713. * Reflection Texture used in the material.
  44714. * Should be author in a specific way for the best result (refer to the documentation).
  44715. */
  44716. reflectionTexture: Nullable<BaseTexture>;
  44717. protected _reflectionBlur: float;
  44718. /**
  44719. * Reflection Texture level of blur.
  44720. *
  44721. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44722. * texture twice.
  44723. */
  44724. reflectionBlur: float;
  44725. protected _diffuseTexture: Nullable<BaseTexture>;
  44726. /**
  44727. * Diffuse Texture used in the material.
  44728. * Should be author in a specific way for the best result (refer to the documentation).
  44729. */
  44730. diffuseTexture: Nullable<BaseTexture>;
  44731. protected _shadowLights: Nullable<IShadowLight[]>;
  44732. /**
  44733. * Specify the list of lights casting shadow on the material.
  44734. * All scene shadow lights will be included if null.
  44735. */
  44736. shadowLights: Nullable<IShadowLight[]>;
  44737. protected _shadowLevel: float;
  44738. /**
  44739. * Helps adjusting the shadow to a softer level if required.
  44740. * 0 means black shadows and 1 means no shadows.
  44741. */
  44742. shadowLevel: float;
  44743. protected _sceneCenter: Vector3;
  44744. /**
  44745. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44746. * It is usually zero but might be interesting to modify according to your setup.
  44747. */
  44748. sceneCenter: Vector3;
  44749. protected _opacityFresnel: boolean;
  44750. /**
  44751. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44752. * This helps ensuring a nice transition when the camera goes under the ground.
  44753. */
  44754. opacityFresnel: boolean;
  44755. protected _reflectionFresnel: boolean;
  44756. /**
  44757. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44758. * This helps adding a mirror texture on the ground.
  44759. */
  44760. reflectionFresnel: boolean;
  44761. protected _reflectionFalloffDistance: number;
  44762. /**
  44763. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44764. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44765. */
  44766. reflectionFalloffDistance: number;
  44767. protected _reflectionAmount: number;
  44768. /**
  44769. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44770. */
  44771. reflectionAmount: number;
  44772. protected _reflectionReflectance0: number;
  44773. /**
  44774. * This specifies the weight of the reflection at grazing angle.
  44775. */
  44776. reflectionReflectance0: number;
  44777. protected _reflectionReflectance90: number;
  44778. /**
  44779. * This specifies the weight of the reflection at a perpendicular point of view.
  44780. */
  44781. reflectionReflectance90: number;
  44782. /**
  44783. * Sets the reflection reflectance fresnel values according to the default standard
  44784. * empirically know to work well :-)
  44785. */
  44786. reflectionStandardFresnelWeight: number;
  44787. protected _useRGBColor: boolean;
  44788. /**
  44789. * Helps to directly use the maps channels instead of their level.
  44790. */
  44791. useRGBColor: boolean;
  44792. protected _enableNoise: boolean;
  44793. /**
  44794. * This helps reducing the banding effect that could occur on the background.
  44795. */
  44796. enableNoise: boolean;
  44797. /**
  44798. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44799. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44800. * Recommended to be keep at 1.0 except for special cases.
  44801. */
  44802. fovMultiplier: number;
  44803. private _fovMultiplier;
  44804. /**
  44805. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44806. */
  44807. useEquirectangularFOV: boolean;
  44808. private _maxSimultaneousLights;
  44809. /**
  44810. * Number of Simultaneous lights allowed on the material.
  44811. */
  44812. maxSimultaneousLights: int;
  44813. /**
  44814. * Default configuration related to image processing available in the Background Material.
  44815. */
  44816. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44817. /**
  44818. * Keep track of the image processing observer to allow dispose and replace.
  44819. */
  44820. private _imageProcessingObserver;
  44821. /**
  44822. * Attaches a new image processing configuration to the PBR Material.
  44823. * @param configuration (if null the scene configuration will be use)
  44824. */
  44825. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44826. /**
  44827. * Gets the image processing configuration used either in this material.
  44828. */
  44829. /**
  44830. * Sets the Default image processing configuration used either in the this material.
  44831. *
  44832. * If sets to null, the scene one is in use.
  44833. */
  44834. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44835. /**
  44836. * Gets wether the color curves effect is enabled.
  44837. */
  44838. /**
  44839. * Sets wether the color curves effect is enabled.
  44840. */
  44841. cameraColorCurvesEnabled: boolean;
  44842. /**
  44843. * Gets wether the color grading effect is enabled.
  44844. */
  44845. /**
  44846. * Gets wether the color grading effect is enabled.
  44847. */
  44848. cameraColorGradingEnabled: boolean;
  44849. /**
  44850. * Gets wether tonemapping is enabled or not.
  44851. */
  44852. /**
  44853. * Sets wether tonemapping is enabled or not
  44854. */
  44855. cameraToneMappingEnabled: boolean;
  44856. /**
  44857. * The camera exposure used on this material.
  44858. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44859. * This corresponds to a photographic exposure.
  44860. */
  44861. /**
  44862. * The camera exposure used on this material.
  44863. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44864. * This corresponds to a photographic exposure.
  44865. */
  44866. cameraExposure: float;
  44867. /**
  44868. * Gets The camera contrast used on this material.
  44869. */
  44870. /**
  44871. * Sets The camera contrast used on this material.
  44872. */
  44873. cameraContrast: float;
  44874. /**
  44875. * Gets the Color Grading 2D Lookup Texture.
  44876. */
  44877. /**
  44878. * Sets the Color Grading 2D Lookup Texture.
  44879. */
  44880. cameraColorGradingTexture: Nullable<BaseTexture>;
  44881. /**
  44882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44884. * 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;
  44885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44886. */
  44887. /**
  44888. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44889. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44890. * 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;
  44891. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44892. */
  44893. cameraColorCurves: Nullable<ColorCurves>;
  44894. /**
  44895. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44896. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44897. */
  44898. switchToBGR: boolean;
  44899. private _renderTargets;
  44900. private _reflectionControls;
  44901. private _white;
  44902. private _primaryShadowColor;
  44903. private _primaryHighlightColor;
  44904. /**
  44905. * Instantiates a Background Material in the given scene
  44906. * @param name The friendly name of the material
  44907. * @param scene The scene to add the material to
  44908. */
  44909. constructor(name: string, scene: Scene);
  44910. /**
  44911. * Gets a boolean indicating that current material needs to register RTT
  44912. */
  44913. readonly hasRenderTargetTextures: boolean;
  44914. /**
  44915. * The entire material has been created in order to prevent overdraw.
  44916. * @returns false
  44917. */
  44918. needAlphaTesting(): boolean;
  44919. /**
  44920. * The entire material has been created in order to prevent overdraw.
  44921. * @returns true if blending is enable
  44922. */
  44923. needAlphaBlending(): boolean;
  44924. /**
  44925. * Checks wether the material is ready to be rendered for a given mesh.
  44926. * @param mesh The mesh to render
  44927. * @param subMesh The submesh to check against
  44928. * @param useInstances Specify wether or not the material is used with instances
  44929. * @returns true if all the dependencies are ready (Textures, Effects...)
  44930. */
  44931. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44932. /**
  44933. * Compute the primary color according to the chosen perceptual color.
  44934. */
  44935. private _computePrimaryColorFromPerceptualColor;
  44936. /**
  44937. * Compute the highlights and shadow colors according to their chosen levels.
  44938. */
  44939. private _computePrimaryColors;
  44940. /**
  44941. * Build the uniform buffer used in the material.
  44942. */
  44943. buildUniformLayout(): void;
  44944. /**
  44945. * Unbind the material.
  44946. */
  44947. unbind(): void;
  44948. /**
  44949. * Bind only the world matrix to the material.
  44950. * @param world The world matrix to bind.
  44951. */
  44952. bindOnlyWorldMatrix(world: Matrix): void;
  44953. /**
  44954. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44955. * @param world The world matrix to bind.
  44956. * @param subMesh The submesh to bind for.
  44957. */
  44958. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44959. /**
  44960. * Dispose the material.
  44961. * @param forceDisposeEffect Force disposal of the associated effect.
  44962. * @param forceDisposeTextures Force disposal of the associated textures.
  44963. */
  44964. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44965. /**
  44966. * Clones the material.
  44967. * @param name The cloned name.
  44968. * @returns The cloned material.
  44969. */
  44970. clone(name: string): BackgroundMaterial;
  44971. /**
  44972. * Serializes the current material to its JSON representation.
  44973. * @returns The JSON representation.
  44974. */
  44975. serialize(): any;
  44976. /**
  44977. * Gets the class name of the material
  44978. * @returns "BackgroundMaterial"
  44979. */
  44980. getClassName(): string;
  44981. /**
  44982. * Parse a JSON input to create back a background material.
  44983. * @param source The JSON data to parse
  44984. * @param scene The scene to create the parsed material in
  44985. * @param rootUrl The root url of the assets the material depends upon
  44986. * @returns the instantiated BackgroundMaterial.
  44987. */
  44988. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44989. }
  44990. }
  44991. declare module BABYLON {
  44992. /**
  44993. * The Physically based material base class of BJS.
  44994. *
  44995. * This offers the main features of a standard PBR material.
  44996. * For more information, please refer to the documentation :
  44997. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44998. */
  44999. abstract class PBRBaseMaterial extends PushMaterial {
  45000. /**
  45001. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45002. */
  45003. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45004. /**
  45005. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45006. * to enhance interoperability with other engines.
  45007. */
  45008. static readonly LIGHTFALLOFF_GLTF: number;
  45009. /**
  45010. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45011. * to enhance interoperability with other materials.
  45012. */
  45013. static readonly LIGHTFALLOFF_STANDARD: number;
  45014. /**
  45015. * Intensity of the direct lights e.g. the four lights available in your scene.
  45016. * This impacts both the direct diffuse and specular highlights.
  45017. */
  45018. protected _directIntensity: number;
  45019. /**
  45020. * Intensity of the emissive part of the material.
  45021. * This helps controlling the emissive effect without modifying the emissive color.
  45022. */
  45023. protected _emissiveIntensity: number;
  45024. /**
  45025. * Intensity of the environment e.g. how much the environment will light the object
  45026. * either through harmonics for rough material or through the refelction for shiny ones.
  45027. */
  45028. protected _environmentIntensity: number;
  45029. /**
  45030. * This is a special control allowing the reduction of the specular highlights coming from the
  45031. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45032. */
  45033. protected _specularIntensity: number;
  45034. /**
  45035. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45036. */
  45037. private _lightingInfos;
  45038. /**
  45039. * Debug Control allowing disabling the bump map on this material.
  45040. */
  45041. protected _disableBumpMap: boolean;
  45042. /**
  45043. * AKA Diffuse Texture in standard nomenclature.
  45044. */
  45045. protected _albedoTexture: BaseTexture;
  45046. /**
  45047. * AKA Occlusion Texture in other nomenclature.
  45048. */
  45049. protected _ambientTexture: BaseTexture;
  45050. /**
  45051. * AKA Occlusion Texture Intensity in other nomenclature.
  45052. */
  45053. protected _ambientTextureStrength: number;
  45054. /**
  45055. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45056. * 1 means it completely occludes it
  45057. * 0 mean it has no impact
  45058. */
  45059. protected _ambientTextureImpactOnAnalyticalLights: number;
  45060. /**
  45061. * Stores the alpha values in a texture.
  45062. */
  45063. protected _opacityTexture: BaseTexture;
  45064. /**
  45065. * Stores the reflection values in a texture.
  45066. */
  45067. protected _reflectionTexture: BaseTexture;
  45068. /**
  45069. * Stores the refraction values in a texture.
  45070. */
  45071. protected _refractionTexture: BaseTexture;
  45072. /**
  45073. * Stores the emissive values in a texture.
  45074. */
  45075. protected _emissiveTexture: BaseTexture;
  45076. /**
  45077. * AKA Specular texture in other nomenclature.
  45078. */
  45079. protected _reflectivityTexture: BaseTexture;
  45080. /**
  45081. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45082. */
  45083. protected _metallicTexture: BaseTexture;
  45084. /**
  45085. * Specifies the metallic scalar of the metallic/roughness workflow.
  45086. * Can also be used to scale the metalness values of the metallic texture.
  45087. */
  45088. protected _metallic: Nullable<number>;
  45089. /**
  45090. * Specifies the roughness scalar of the metallic/roughness workflow.
  45091. * Can also be used to scale the roughness values of the metallic texture.
  45092. */
  45093. protected _roughness: Nullable<number>;
  45094. /**
  45095. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45096. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45097. */
  45098. protected _microSurfaceTexture: BaseTexture;
  45099. /**
  45100. * Stores surface normal data used to displace a mesh in a texture.
  45101. */
  45102. protected _bumpTexture: BaseTexture;
  45103. /**
  45104. * Stores the pre-calculated light information of a mesh in a texture.
  45105. */
  45106. protected _lightmapTexture: BaseTexture;
  45107. /**
  45108. * The color of a material in ambient lighting.
  45109. */
  45110. protected _ambientColor: Color3;
  45111. /**
  45112. * AKA Diffuse Color in other nomenclature.
  45113. */
  45114. protected _albedoColor: Color3;
  45115. /**
  45116. * AKA Specular Color in other nomenclature.
  45117. */
  45118. protected _reflectivityColor: Color3;
  45119. /**
  45120. * The color applied when light is reflected from a material.
  45121. */
  45122. protected _reflectionColor: Color3;
  45123. /**
  45124. * The color applied when light is emitted from a material.
  45125. */
  45126. protected _emissiveColor: Color3;
  45127. /**
  45128. * AKA Glossiness in other nomenclature.
  45129. */
  45130. protected _microSurface: number;
  45131. /**
  45132. * source material index of refraction (IOR)' / 'destination material IOR.
  45133. */
  45134. protected _indexOfRefraction: number;
  45135. /**
  45136. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45137. */
  45138. protected _invertRefractionY: boolean;
  45139. /**
  45140. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45141. * Materials half opaque for instance using refraction could benefit from this control.
  45142. */
  45143. protected _linkRefractionWithTransparency: boolean;
  45144. /**
  45145. * Specifies that the material will use the light map as a show map.
  45146. */
  45147. protected _useLightmapAsShadowmap: boolean;
  45148. /**
  45149. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45150. * makes the reflect vector face the model (under horizon).
  45151. */
  45152. protected _useHorizonOcclusion: boolean;
  45153. /**
  45154. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45155. * too much the area relying on ambient texture to define their ambient occlusion.
  45156. */
  45157. protected _useRadianceOcclusion: boolean;
  45158. /**
  45159. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45160. */
  45161. protected _useAlphaFromAlbedoTexture: boolean;
  45162. /**
  45163. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45164. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45165. */
  45166. protected _useSpecularOverAlpha: boolean;
  45167. /**
  45168. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45169. */
  45170. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45171. /**
  45172. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45173. */
  45174. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45175. /**
  45176. * Specifies if the metallic texture contains the roughness information in its green channel.
  45177. */
  45178. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45179. /**
  45180. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45181. */
  45182. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45183. /**
  45184. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45185. */
  45186. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45187. /**
  45188. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45189. */
  45190. protected _useAmbientInGrayScale: boolean;
  45191. /**
  45192. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45193. * The material will try to infer what glossiness each pixel should be.
  45194. */
  45195. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45196. /**
  45197. * Defines the falloff type used in this material.
  45198. * It by default is Physical.
  45199. */
  45200. protected _lightFalloff: number;
  45201. /**
  45202. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45203. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45204. */
  45205. protected _useRadianceOverAlpha: boolean;
  45206. /**
  45207. * Allows using an object space normal map (instead of tangent space).
  45208. */
  45209. protected _useObjectSpaceNormalMap: boolean;
  45210. /**
  45211. * Allows using the bump map in parallax mode.
  45212. */
  45213. protected _useParallax: boolean;
  45214. /**
  45215. * Allows using the bump map in parallax occlusion mode.
  45216. */
  45217. protected _useParallaxOcclusion: boolean;
  45218. /**
  45219. * Controls the scale bias of the parallax mode.
  45220. */
  45221. protected _parallaxScaleBias: number;
  45222. /**
  45223. * If sets to true, disables all the lights affecting the material.
  45224. */
  45225. protected _disableLighting: boolean;
  45226. /**
  45227. * Number of Simultaneous lights allowed on the material.
  45228. */
  45229. protected _maxSimultaneousLights: number;
  45230. /**
  45231. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45232. */
  45233. protected _invertNormalMapX: boolean;
  45234. /**
  45235. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45236. */
  45237. protected _invertNormalMapY: boolean;
  45238. /**
  45239. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45240. */
  45241. protected _twoSidedLighting: boolean;
  45242. /**
  45243. * Defines the alpha limits in alpha test mode.
  45244. */
  45245. protected _alphaCutOff: number;
  45246. /**
  45247. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45248. */
  45249. protected _forceAlphaTest: boolean;
  45250. /**
  45251. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45252. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45253. */
  45254. protected _useAlphaFresnel: boolean;
  45255. /**
  45256. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45257. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45258. */
  45259. protected _useLinearAlphaFresnel: boolean;
  45260. /**
  45261. * The transparency mode of the material.
  45262. */
  45263. protected _transparencyMode: Nullable<number>;
  45264. /**
  45265. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45266. * from cos thetav and roughness:
  45267. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45268. */
  45269. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45270. /**
  45271. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45272. */
  45273. protected _forceIrradianceInFragment: boolean;
  45274. /**
  45275. * Force normal to face away from face.
  45276. */
  45277. protected _forceNormalForward: boolean;
  45278. /**
  45279. * Enables specular anti aliasing in the PBR shader.
  45280. * It will both interacts on the Geometry for analytical and IBL lighting.
  45281. * It also prefilter the roughness map based on the bump values.
  45282. */
  45283. protected _enableSpecularAntiAliasing: boolean;
  45284. /**
  45285. * Default configuration related to image processing available in the PBR Material.
  45286. */
  45287. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45288. /**
  45289. * Keep track of the image processing observer to allow dispose and replace.
  45290. */
  45291. private _imageProcessingObserver;
  45292. /**
  45293. * Attaches a new image processing configuration to the PBR Material.
  45294. * @param configuration
  45295. */
  45296. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45297. /**
  45298. * Stores the available render targets.
  45299. */
  45300. private _renderTargets;
  45301. /**
  45302. * Sets the global ambient color for the material used in lighting calculations.
  45303. */
  45304. private _globalAmbientColor;
  45305. /**
  45306. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45307. */
  45308. private _useLogarithmicDepth;
  45309. /**
  45310. * If set to true, no lighting calculations will be applied.
  45311. */
  45312. private _unlit;
  45313. /**
  45314. * Instantiates a new PBRMaterial instance.
  45315. *
  45316. * @param name The material name
  45317. * @param scene The scene the material will be use in.
  45318. */
  45319. constructor(name: string, scene: Scene);
  45320. /**
  45321. * Gets a boolean indicating that current material needs to register RTT
  45322. */
  45323. readonly hasRenderTargetTextures: boolean;
  45324. /**
  45325. * Gets the name of the material class.
  45326. */
  45327. getClassName(): string;
  45328. /**
  45329. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45330. */
  45331. /**
  45332. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45333. */
  45334. useLogarithmicDepth: boolean;
  45335. /**
  45336. * Gets the current transparency mode.
  45337. */
  45338. /**
  45339. * Sets the transparency mode of the material.
  45340. *
  45341. * | Value | Type | Description |
  45342. * | ----- | ----------------------------------- | ----------- |
  45343. * | 0 | OPAQUE | |
  45344. * | 1 | ALPHATEST | |
  45345. * | 2 | ALPHABLEND | |
  45346. * | 3 | ALPHATESTANDBLEND | |
  45347. *
  45348. */
  45349. transparencyMode: Nullable<number>;
  45350. /**
  45351. * Returns true if alpha blending should be disabled.
  45352. */
  45353. private readonly _disableAlphaBlending;
  45354. /**
  45355. * Specifies whether or not this material should be rendered in alpha blend mode.
  45356. */
  45357. needAlphaBlending(): boolean;
  45358. /**
  45359. * Specifies if the mesh will require alpha blending.
  45360. * @param mesh - BJS mesh.
  45361. */
  45362. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45363. /**
  45364. * Specifies whether or not this material should be rendered in alpha test mode.
  45365. */
  45366. needAlphaTesting(): boolean;
  45367. /**
  45368. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45369. */
  45370. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45371. /**
  45372. * Gets the texture used for the alpha test.
  45373. */
  45374. getAlphaTestTexture(): BaseTexture;
  45375. /**
  45376. * Stores the reflectivity values based on metallic roughness workflow.
  45377. */
  45378. private static _scaledReflectivity;
  45379. /**
  45380. * Specifies that the submesh is ready to be used.
  45381. * @param mesh - BJS mesh.
  45382. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45383. * @param useInstances - Specifies that instances should be used.
  45384. * @returns - boolean indicating that the submesh is ready or not.
  45385. */
  45386. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45387. /**
  45388. * Specifies if the material uses metallic roughness workflow.
  45389. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45390. */
  45391. isMetallicWorkflow(): boolean;
  45392. private _prepareEffect;
  45393. private _prepareDefines;
  45394. /**
  45395. * Force shader compilation
  45396. */
  45397. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45398. clipPlane: boolean;
  45399. }>): void;
  45400. /**
  45401. * Initializes the uniform buffer layout for the shader.
  45402. */
  45403. buildUniformLayout(): void;
  45404. /**
  45405. * Unbinds the textures.
  45406. */
  45407. unbind(): void;
  45408. /**
  45409. * Binds the submesh data.
  45410. * @param world - The world matrix.
  45411. * @param mesh - The BJS mesh.
  45412. * @param subMesh - A submesh of the BJS mesh.
  45413. */
  45414. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45415. /**
  45416. * Returns the animatable textures.
  45417. * @returns - Array of animatable textures.
  45418. */
  45419. getAnimatables(): IAnimatable[];
  45420. /**
  45421. * Returns the texture used for reflections.
  45422. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45423. */
  45424. private _getReflectionTexture;
  45425. /**
  45426. * Returns the texture used for refraction or null if none is used.
  45427. * @returns - Refection texture if present. If no refraction texture and refraction
  45428. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45429. */
  45430. private _getRefractionTexture;
  45431. /**
  45432. * Disposes the resources of the material.
  45433. * @param forceDisposeEffect - Forces the disposal of effects.
  45434. * @param forceDisposeTextures - Forces the disposal of all textures.
  45435. */
  45436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45437. }
  45438. }
  45439. declare module BABYLON {
  45440. /**
  45441. * The Physically based simple base material of BJS.
  45442. *
  45443. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45444. * It is used as the base class for both the specGloss and metalRough conventions.
  45445. */
  45446. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45447. /**
  45448. * Number of Simultaneous lights allowed on the material.
  45449. */
  45450. maxSimultaneousLights: number;
  45451. /**
  45452. * If sets to true, disables all the lights affecting the material.
  45453. */
  45454. disableLighting: boolean;
  45455. /**
  45456. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45457. */
  45458. environmentTexture: BaseTexture;
  45459. /**
  45460. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45461. */
  45462. invertNormalMapX: boolean;
  45463. /**
  45464. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45465. */
  45466. invertNormalMapY: boolean;
  45467. /**
  45468. * Normal map used in the model.
  45469. */
  45470. normalTexture: BaseTexture;
  45471. /**
  45472. * Emissivie color used to self-illuminate the model.
  45473. */
  45474. emissiveColor: Color3;
  45475. /**
  45476. * Emissivie texture used to self-illuminate the model.
  45477. */
  45478. emissiveTexture: BaseTexture;
  45479. /**
  45480. * Occlusion Channel Strenght.
  45481. */
  45482. occlusionStrength: number;
  45483. /**
  45484. * Occlusion Texture of the material (adding extra occlusion effects).
  45485. */
  45486. occlusionTexture: BaseTexture;
  45487. /**
  45488. * Defines the alpha limits in alpha test mode.
  45489. */
  45490. alphaCutOff: number;
  45491. /**
  45492. * Gets the current double sided mode.
  45493. */
  45494. /**
  45495. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45496. */
  45497. doubleSided: boolean;
  45498. /**
  45499. * Stores the pre-calculated light information of a mesh in a texture.
  45500. */
  45501. lightmapTexture: BaseTexture;
  45502. /**
  45503. * If true, the light map contains occlusion information instead of lighting info.
  45504. */
  45505. useLightmapAsShadowmap: boolean;
  45506. /**
  45507. * Return the active textures of the material.
  45508. */
  45509. getActiveTextures(): BaseTexture[];
  45510. hasTexture(texture: BaseTexture): boolean;
  45511. /**
  45512. * Instantiates a new PBRMaterial instance.
  45513. *
  45514. * @param name The material name
  45515. * @param scene The scene the material will be use in.
  45516. */
  45517. constructor(name: string, scene: Scene);
  45518. getClassName(): string;
  45519. }
  45520. }
  45521. declare module BABYLON {
  45522. /**
  45523. * The Physically based material of BJS.
  45524. *
  45525. * This offers the main features of a standard PBR material.
  45526. * For more information, please refer to the documentation :
  45527. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45528. */
  45529. class PBRMaterial extends PBRBaseMaterial {
  45530. /**
  45531. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45532. */
  45533. static readonly PBRMATERIAL_OPAQUE: number;
  45534. /**
  45535. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45536. */
  45537. static readonly PBRMATERIAL_ALPHATEST: number;
  45538. /**
  45539. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45540. */
  45541. static readonly PBRMATERIAL_ALPHABLEND: number;
  45542. /**
  45543. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45544. * They are also discarded below the alpha cutoff threshold to improve performances.
  45545. */
  45546. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45547. /**
  45548. * Defines the default value of how much AO map is occluding the analytical lights
  45549. * (point spot...).
  45550. */
  45551. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45552. /**
  45553. * Intensity of the direct lights e.g. the four lights available in your scene.
  45554. * This impacts both the direct diffuse and specular highlights.
  45555. */
  45556. directIntensity: number;
  45557. /**
  45558. * Intensity of the emissive part of the material.
  45559. * This helps controlling the emissive effect without modifying the emissive color.
  45560. */
  45561. emissiveIntensity: number;
  45562. /**
  45563. * Intensity of the environment e.g. how much the environment will light the object
  45564. * either through harmonics for rough material or through the refelction for shiny ones.
  45565. */
  45566. environmentIntensity: number;
  45567. /**
  45568. * This is a special control allowing the reduction of the specular highlights coming from the
  45569. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45570. */
  45571. specularIntensity: number;
  45572. /**
  45573. * Debug Control allowing disabling the bump map on this material.
  45574. */
  45575. disableBumpMap: boolean;
  45576. /**
  45577. * AKA Diffuse Texture in standard nomenclature.
  45578. */
  45579. albedoTexture: BaseTexture;
  45580. /**
  45581. * AKA Occlusion Texture in other nomenclature.
  45582. */
  45583. ambientTexture: BaseTexture;
  45584. /**
  45585. * AKA Occlusion Texture Intensity in other nomenclature.
  45586. */
  45587. ambientTextureStrength: number;
  45588. /**
  45589. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45590. * 1 means it completely occludes it
  45591. * 0 mean it has no impact
  45592. */
  45593. ambientTextureImpactOnAnalyticalLights: number;
  45594. /**
  45595. * Stores the alpha values in a texture.
  45596. */
  45597. opacityTexture: BaseTexture;
  45598. /**
  45599. * Stores the reflection values in a texture.
  45600. */
  45601. reflectionTexture: Nullable<BaseTexture>;
  45602. /**
  45603. * Stores the emissive values in a texture.
  45604. */
  45605. emissiveTexture: BaseTexture;
  45606. /**
  45607. * AKA Specular texture in other nomenclature.
  45608. */
  45609. reflectivityTexture: BaseTexture;
  45610. /**
  45611. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45612. */
  45613. metallicTexture: BaseTexture;
  45614. /**
  45615. * Specifies the metallic scalar of the metallic/roughness workflow.
  45616. * Can also be used to scale the metalness values of the metallic texture.
  45617. */
  45618. metallic: Nullable<number>;
  45619. /**
  45620. * Specifies the roughness scalar of the metallic/roughness workflow.
  45621. * Can also be used to scale the roughness values of the metallic texture.
  45622. */
  45623. roughness: Nullable<number>;
  45624. /**
  45625. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45626. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45627. */
  45628. microSurfaceTexture: BaseTexture;
  45629. /**
  45630. * Stores surface normal data used to displace a mesh in a texture.
  45631. */
  45632. bumpTexture: BaseTexture;
  45633. /**
  45634. * Stores the pre-calculated light information of a mesh in a texture.
  45635. */
  45636. lightmapTexture: BaseTexture;
  45637. /**
  45638. * Stores the refracted light information in a texture.
  45639. */
  45640. refractionTexture: BaseTexture;
  45641. /**
  45642. * The color of a material in ambient lighting.
  45643. */
  45644. ambientColor: Color3;
  45645. /**
  45646. * AKA Diffuse Color in other nomenclature.
  45647. */
  45648. albedoColor: Color3;
  45649. /**
  45650. * AKA Specular Color in other nomenclature.
  45651. */
  45652. reflectivityColor: Color3;
  45653. /**
  45654. * The color reflected from the material.
  45655. */
  45656. reflectionColor: Color3;
  45657. /**
  45658. * The color emitted from the material.
  45659. */
  45660. emissiveColor: Color3;
  45661. /**
  45662. * AKA Glossiness in other nomenclature.
  45663. */
  45664. microSurface: number;
  45665. /**
  45666. * source material index of refraction (IOR)' / 'destination material IOR.
  45667. */
  45668. indexOfRefraction: number;
  45669. /**
  45670. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45671. */
  45672. invertRefractionY: boolean;
  45673. /**
  45674. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45675. * Materials half opaque for instance using refraction could benefit from this control.
  45676. */
  45677. linkRefractionWithTransparency: boolean;
  45678. /**
  45679. * If true, the light map contains occlusion information instead of lighting info.
  45680. */
  45681. useLightmapAsShadowmap: boolean;
  45682. /**
  45683. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45684. */
  45685. useAlphaFromAlbedoTexture: boolean;
  45686. /**
  45687. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45688. */
  45689. forceAlphaTest: boolean;
  45690. /**
  45691. * Defines the alpha limits in alpha test mode.
  45692. */
  45693. alphaCutOff: number;
  45694. /**
  45695. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45696. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45697. */
  45698. useSpecularOverAlpha: boolean;
  45699. /**
  45700. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45701. */
  45702. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45703. /**
  45704. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45705. */
  45706. useRoughnessFromMetallicTextureAlpha: boolean;
  45707. /**
  45708. * Specifies if the metallic texture contains the roughness information in its green channel.
  45709. */
  45710. useRoughnessFromMetallicTextureGreen: boolean;
  45711. /**
  45712. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45713. */
  45714. useMetallnessFromMetallicTextureBlue: boolean;
  45715. /**
  45716. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45717. */
  45718. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45719. /**
  45720. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45721. */
  45722. useAmbientInGrayScale: boolean;
  45723. /**
  45724. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45725. * The material will try to infer what glossiness each pixel should be.
  45726. */
  45727. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45728. /**
  45729. * BJS is using an harcoded light falloff based on a manually sets up range.
  45730. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45731. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45732. */
  45733. /**
  45734. * BJS is using an harcoded light falloff based on a manually sets up range.
  45735. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45736. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45737. */
  45738. usePhysicalLightFalloff: boolean;
  45739. /**
  45740. * In order to support the falloff compatibility with gltf, a special mode has been added
  45741. * to reproduce the gltf light falloff.
  45742. */
  45743. /**
  45744. * In order to support the falloff compatibility with gltf, a special mode has been added
  45745. * to reproduce the gltf light falloff.
  45746. */
  45747. useGLTFLightFalloff: boolean;
  45748. /**
  45749. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45750. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45751. */
  45752. useRadianceOverAlpha: boolean;
  45753. /**
  45754. * Allows using an object space normal map (instead of tangent space).
  45755. */
  45756. useObjectSpaceNormalMap: boolean;
  45757. /**
  45758. * Allows using the bump map in parallax mode.
  45759. */
  45760. useParallax: boolean;
  45761. /**
  45762. * Allows using the bump map in parallax occlusion mode.
  45763. */
  45764. useParallaxOcclusion: boolean;
  45765. /**
  45766. * Controls the scale bias of the parallax mode.
  45767. */
  45768. parallaxScaleBias: number;
  45769. /**
  45770. * If sets to true, disables all the lights affecting the material.
  45771. */
  45772. disableLighting: boolean;
  45773. /**
  45774. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45775. */
  45776. forceIrradianceInFragment: boolean;
  45777. /**
  45778. * Number of Simultaneous lights allowed on the material.
  45779. */
  45780. maxSimultaneousLights: number;
  45781. /**
  45782. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45783. */
  45784. invertNormalMapX: boolean;
  45785. /**
  45786. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45787. */
  45788. invertNormalMapY: boolean;
  45789. /**
  45790. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45791. */
  45792. twoSidedLighting: boolean;
  45793. /**
  45794. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45795. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45796. */
  45797. useAlphaFresnel: boolean;
  45798. /**
  45799. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45800. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45801. */
  45802. useLinearAlphaFresnel: boolean;
  45803. /**
  45804. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45805. * And/Or occlude the blended part.
  45806. */
  45807. environmentBRDFTexture: Nullable<BaseTexture>;
  45808. /**
  45809. * Force normal to face away from face.
  45810. */
  45811. forceNormalForward: boolean;
  45812. /**
  45813. * Enables specular anti aliasing in the PBR shader.
  45814. * It will both interacts on the Geometry for analytical and IBL lighting.
  45815. * It also prefilter the roughness map based on the bump values.
  45816. */
  45817. enableSpecularAntiAliasing: boolean;
  45818. /**
  45819. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45820. * makes the reflect vector face the model (under horizon).
  45821. */
  45822. useHorizonOcclusion: boolean;
  45823. /**
  45824. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45825. * too much the area relying on ambient texture to define their ambient occlusion.
  45826. */
  45827. useRadianceOcclusion: boolean;
  45828. /**
  45829. * If set to true, no lighting calculations will be applied.
  45830. */
  45831. unlit: boolean;
  45832. /**
  45833. * Gets the image processing configuration used either in this material.
  45834. */
  45835. /**
  45836. * Sets the Default image processing configuration used either in the this material.
  45837. *
  45838. * If sets to null, the scene one is in use.
  45839. */
  45840. imageProcessingConfiguration: ImageProcessingConfiguration;
  45841. /**
  45842. * Gets wether the color curves effect is enabled.
  45843. */
  45844. /**
  45845. * Sets wether the color curves effect is enabled.
  45846. */
  45847. cameraColorCurvesEnabled: boolean;
  45848. /**
  45849. * Gets wether the color grading effect is enabled.
  45850. */
  45851. /**
  45852. * Gets wether the color grading effect is enabled.
  45853. */
  45854. cameraColorGradingEnabled: boolean;
  45855. /**
  45856. * Gets wether tonemapping is enabled or not.
  45857. */
  45858. /**
  45859. * Sets wether tonemapping is enabled or not
  45860. */
  45861. cameraToneMappingEnabled: boolean;
  45862. /**
  45863. * The camera exposure used on this material.
  45864. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45865. * This corresponds to a photographic exposure.
  45866. */
  45867. /**
  45868. * The camera exposure used on this material.
  45869. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45870. * This corresponds to a photographic exposure.
  45871. */
  45872. cameraExposure: number;
  45873. /**
  45874. * Gets The camera contrast used on this material.
  45875. */
  45876. /**
  45877. * Sets The camera contrast used on this material.
  45878. */
  45879. cameraContrast: number;
  45880. /**
  45881. * Gets the Color Grading 2D Lookup Texture.
  45882. */
  45883. /**
  45884. * Sets the Color Grading 2D Lookup Texture.
  45885. */
  45886. cameraColorGradingTexture: Nullable<BaseTexture>;
  45887. /**
  45888. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45889. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45890. * 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;
  45891. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45892. */
  45893. /**
  45894. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45895. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45896. * 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;
  45897. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45898. */
  45899. cameraColorCurves: Nullable<ColorCurves>;
  45900. /**
  45901. * Instantiates a new PBRMaterial instance.
  45902. *
  45903. * @param name The material name
  45904. * @param scene The scene the material will be use in.
  45905. */
  45906. constructor(name: string, scene: Scene);
  45907. /**
  45908. * Returns the name of this material class.
  45909. */
  45910. getClassName(): string;
  45911. /**
  45912. * Returns an array of the actively used textures.
  45913. * @returns - Array of BaseTextures
  45914. */
  45915. getActiveTextures(): BaseTexture[];
  45916. /**
  45917. * Checks to see if a texture is used in the material.
  45918. * @param texture - Base texture to use.
  45919. * @returns - Boolean specifying if a texture is used in the material.
  45920. */
  45921. hasTexture(texture: BaseTexture): boolean;
  45922. /**
  45923. * Makes a duplicate of the current material.
  45924. * @param name - name to use for the new material.
  45925. */
  45926. clone(name: string): PBRMaterial;
  45927. /**
  45928. * Serializes this PBR Material.
  45929. * @returns - An object with the serialized material.
  45930. */
  45931. serialize(): any;
  45932. /**
  45933. * Parses a PBR Material from a serialized object.
  45934. * @param source - Serialized object.
  45935. * @param scene - BJS scene instance.
  45936. * @param rootUrl - url for the scene object
  45937. * @returns - PBRMaterial
  45938. */
  45939. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45940. }
  45941. }
  45942. declare module BABYLON {
  45943. /**
  45944. * The PBR material of BJS following the metal roughness convention.
  45945. *
  45946. * This fits to the PBR convention in the GLTF definition:
  45947. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45948. */
  45949. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45950. /**
  45951. * The base color has two different interpretations depending on the value of metalness.
  45952. * When the material is a metal, the base color is the specific measured reflectance value
  45953. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45954. * of the material.
  45955. */
  45956. baseColor: Color3;
  45957. /**
  45958. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45959. * well as opacity information in the alpha channel.
  45960. */
  45961. baseTexture: BaseTexture;
  45962. /**
  45963. * Specifies the metallic scalar value of the material.
  45964. * Can also be used to scale the metalness values of the metallic texture.
  45965. */
  45966. metallic: number;
  45967. /**
  45968. * Specifies the roughness scalar value of the material.
  45969. * Can also be used to scale the roughness values of the metallic texture.
  45970. */
  45971. roughness: number;
  45972. /**
  45973. * Texture containing both the metallic value in the B channel and the
  45974. * roughness value in the G channel to keep better precision.
  45975. */
  45976. metallicRoughnessTexture: BaseTexture;
  45977. /**
  45978. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45979. *
  45980. * @param name The material name
  45981. * @param scene The scene the material will be use in.
  45982. */
  45983. constructor(name: string, scene: Scene);
  45984. /**
  45985. * Return the currrent class name of the material.
  45986. */
  45987. getClassName(): string;
  45988. /**
  45989. * Return the active textures of the material.
  45990. */
  45991. getActiveTextures(): BaseTexture[];
  45992. /**
  45993. * Checks to see if a texture is used in the material.
  45994. * @param texture - Base texture to use.
  45995. * @returns - Boolean specifying if a texture is used in the material.
  45996. */
  45997. hasTexture(texture: BaseTexture): boolean;
  45998. /**
  45999. * Makes a duplicate of the current material.
  46000. * @param name - name to use for the new material.
  46001. */
  46002. clone(name: string): PBRMetallicRoughnessMaterial;
  46003. /**
  46004. * Serialize the material to a parsable JSON object.
  46005. */
  46006. serialize(): any;
  46007. /**
  46008. * Parses a JSON object correponding to the serialize function.
  46009. */
  46010. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46011. }
  46012. }
  46013. declare module BABYLON {
  46014. /**
  46015. * The PBR material of BJS following the specular glossiness convention.
  46016. *
  46017. * This fits to the PBR convention in the GLTF definition:
  46018. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46019. */
  46020. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46021. /**
  46022. * Specifies the diffuse color of the material.
  46023. */
  46024. diffuseColor: Color3;
  46025. /**
  46026. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46027. * channel.
  46028. */
  46029. diffuseTexture: BaseTexture;
  46030. /**
  46031. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46032. */
  46033. specularColor: Color3;
  46034. /**
  46035. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46036. */
  46037. glossiness: number;
  46038. /**
  46039. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46040. */
  46041. specularGlossinessTexture: BaseTexture;
  46042. /**
  46043. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46044. *
  46045. * @param name The material name
  46046. * @param scene The scene the material will be use in.
  46047. */
  46048. constructor(name: string, scene: Scene);
  46049. /**
  46050. * Return the currrent class name of the material.
  46051. */
  46052. getClassName(): string;
  46053. /**
  46054. * Return the active textures of the material.
  46055. */
  46056. getActiveTextures(): BaseTexture[];
  46057. /**
  46058. * Checks to see if a texture is used in the material.
  46059. * @param texture - Base texture to use.
  46060. * @returns - Boolean specifying if a texture is used in the material.
  46061. */
  46062. hasTexture(texture: BaseTexture): boolean;
  46063. /**
  46064. * Makes a duplicate of the current material.
  46065. * @param name - name to use for the new material.
  46066. */
  46067. clone(name: string): PBRSpecularGlossinessMaterial;
  46068. /**
  46069. * Serialize the material to a parsable JSON object.
  46070. */
  46071. serialize(): any;
  46072. /**
  46073. * Parses a JSON object correponding to the serialize function.
  46074. */
  46075. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46076. }
  46077. }
  46078. declare module BABYLON {
  46079. /**
  46080. * Base class of all the textures in babylon.
  46081. * It groups all the common properties the materials, post process, lights... might need
  46082. * in order to make a correct use of the texture.
  46083. */
  46084. class BaseTexture {
  46085. /**
  46086. * Default anisotropic filtering level for the application.
  46087. * It is set to 4 as a good tradeoff between perf and quality.
  46088. */
  46089. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46090. /**
  46091. * Gets or sets the unique id of the texture
  46092. */
  46093. uniqueId: number;
  46094. /**
  46095. * Define the name of the texture.
  46096. */
  46097. name: string;
  46098. private _hasAlpha;
  46099. /**
  46100. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46101. */
  46102. hasAlpha: boolean;
  46103. /**
  46104. * Defines if the alpha value should be determined via the rgb values.
  46105. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46106. */
  46107. getAlphaFromRGB: boolean;
  46108. /**
  46109. * Intensity or strength of the texture.
  46110. * It is commonly used by materials to fine tune the intensity of the texture
  46111. */
  46112. level: number;
  46113. /**
  46114. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46115. * This is part of the texture as textures usually maps to one uv set.
  46116. */
  46117. coordinatesIndex: number;
  46118. private _coordinatesMode;
  46119. /**
  46120. * How a texture is mapped.
  46121. *
  46122. * | Value | Type | Description |
  46123. * | ----- | ----------------------------------- | ----------- |
  46124. * | 0 | EXPLICIT_MODE | |
  46125. * | 1 | SPHERICAL_MODE | |
  46126. * | 2 | PLANAR_MODE | |
  46127. * | 3 | CUBIC_MODE | |
  46128. * | 4 | PROJECTION_MODE | |
  46129. * | 5 | SKYBOX_MODE | |
  46130. * | 6 | INVCUBIC_MODE | |
  46131. * | 7 | EQUIRECTANGULAR_MODE | |
  46132. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46133. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46134. */
  46135. coordinatesMode: number;
  46136. /**
  46137. * | Value | Type | Description |
  46138. * | ----- | ------------------ | ----------- |
  46139. * | 0 | CLAMP_ADDRESSMODE | |
  46140. * | 1 | WRAP_ADDRESSMODE | |
  46141. * | 2 | MIRROR_ADDRESSMODE | |
  46142. */
  46143. wrapU: number;
  46144. /**
  46145. * | Value | Type | Description |
  46146. * | ----- | ------------------ | ----------- |
  46147. * | 0 | CLAMP_ADDRESSMODE | |
  46148. * | 1 | WRAP_ADDRESSMODE | |
  46149. * | 2 | MIRROR_ADDRESSMODE | |
  46150. */
  46151. wrapV: number;
  46152. /**
  46153. * | Value | Type | Description |
  46154. * | ----- | ------------------ | ----------- |
  46155. * | 0 | CLAMP_ADDRESSMODE | |
  46156. * | 1 | WRAP_ADDRESSMODE | |
  46157. * | 2 | MIRROR_ADDRESSMODE | |
  46158. */
  46159. wrapR: number;
  46160. /**
  46161. * With compliant hardware and browser (supporting anisotropic filtering)
  46162. * this defines the level of anisotropic filtering in the texture.
  46163. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46164. */
  46165. anisotropicFilteringLevel: number;
  46166. /**
  46167. * Define if the texture is a cube texture or if false a 2d texture.
  46168. */
  46169. isCube: boolean;
  46170. /**
  46171. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46172. */
  46173. is3D: boolean;
  46174. /**
  46175. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46176. * HDR texture are usually stored in linear space.
  46177. * This only impacts the PBR and Background materials
  46178. */
  46179. gammaSpace: boolean;
  46180. /**
  46181. * Gets whether or not the texture contains RGBD data.
  46182. */
  46183. readonly isRGBD: boolean;
  46184. /**
  46185. * Is Z inverted in the texture (useful in a cube texture).
  46186. */
  46187. invertZ: boolean;
  46188. /**
  46189. * @hidden
  46190. */
  46191. lodLevelInAlpha: boolean;
  46192. /**
  46193. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46194. */
  46195. lodGenerationOffset: number;
  46196. /**
  46197. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46198. */
  46199. lodGenerationScale: number;
  46200. /**
  46201. * Define if the texture is a render target.
  46202. */
  46203. isRenderTarget: boolean;
  46204. /**
  46205. * Define the unique id of the texture in the scene.
  46206. */
  46207. readonly uid: string;
  46208. /**
  46209. * Return a string representation of the texture.
  46210. * @returns the texture as a string
  46211. */
  46212. toString(): string;
  46213. /**
  46214. * Get the class name of the texture.
  46215. * @returns "BaseTexture"
  46216. */
  46217. getClassName(): string;
  46218. /**
  46219. * Define the list of animation attached to the texture.
  46220. */
  46221. animations: Animation[];
  46222. /**
  46223. * An event triggered when the texture is disposed.
  46224. */
  46225. onDisposeObservable: Observable<BaseTexture>;
  46226. private _onDisposeObserver;
  46227. /**
  46228. * Callback triggered when the texture has been disposed.
  46229. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46230. */
  46231. onDispose: () => void;
  46232. /**
  46233. * Define the current state of the loading sequence when in delayed load mode.
  46234. */
  46235. delayLoadState: number;
  46236. private _scene;
  46237. /** @hidden */
  46238. _texture: Nullable<InternalTexture>;
  46239. private _uid;
  46240. /**
  46241. * Define if the texture is preventinga material to render or not.
  46242. * If not and the texture is not ready, the engine will use a default black texture instead.
  46243. */
  46244. readonly isBlocking: boolean;
  46245. /**
  46246. * Instantiates a new BaseTexture.
  46247. * Base class of all the textures in babylon.
  46248. * It groups all the common properties the materials, post process, lights... might need
  46249. * in order to make a correct use of the texture.
  46250. * @param scene Define the scene the texture blongs to
  46251. */
  46252. constructor(scene: Nullable<Scene>);
  46253. /**
  46254. * Get the scene the texture belongs to.
  46255. * @returns the scene or null if undefined
  46256. */
  46257. getScene(): Nullable<Scene>;
  46258. /**
  46259. * Get the texture transform matrix used to offset tile the texture for istance.
  46260. * @returns the transformation matrix
  46261. */
  46262. getTextureMatrix(): Matrix;
  46263. /**
  46264. * Get the texture reflection matrix used to rotate/transform the reflection.
  46265. * @returns the reflection matrix
  46266. */
  46267. getReflectionTextureMatrix(): Matrix;
  46268. /**
  46269. * Get the underlying lower level texture from Babylon.
  46270. * @returns the insternal texture
  46271. */
  46272. getInternalTexture(): Nullable<InternalTexture>;
  46273. /**
  46274. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46275. * @returns true if ready or not blocking
  46276. */
  46277. isReadyOrNotBlocking(): boolean;
  46278. /**
  46279. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46280. * @returns true if fully ready
  46281. */
  46282. isReady(): boolean;
  46283. private _cachedSize;
  46284. /**
  46285. * Get the size of the texture.
  46286. * @returns the texture size.
  46287. */
  46288. getSize(): ISize;
  46289. /**
  46290. * Get the base size of the texture.
  46291. * It can be different from the size if the texture has been resized for POT for instance
  46292. * @returns the base size
  46293. */
  46294. getBaseSize(): ISize;
  46295. /**
  46296. * Scales the texture if is `canRescale()`
  46297. * @param ratio the resize factor we want to use to rescale
  46298. */
  46299. scale(ratio: number): void;
  46300. /**
  46301. * Get if the texture can rescale.
  46302. */
  46303. readonly canRescale: boolean;
  46304. /** @hidden */
  46305. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46306. /** @hidden */
  46307. _rebuild(): void;
  46308. /**
  46309. * Triggers the load sequence in delayed load mode.
  46310. */
  46311. delayLoad(): void;
  46312. /**
  46313. * Clones the texture.
  46314. * @returns the cloned texture
  46315. */
  46316. clone(): Nullable<BaseTexture>;
  46317. /**
  46318. * Get the texture underlying type (INT, FLOAT...)
  46319. */
  46320. readonly textureType: number;
  46321. /**
  46322. * Get the texture underlying format (RGB, RGBA...)
  46323. */
  46324. readonly textureFormat: number;
  46325. /**
  46326. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46327. * This will returns an RGBA array buffer containing either in values (0-255) or
  46328. * float values (0-1) depending of the underlying buffer type.
  46329. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46330. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46331. * @param buffer defines a user defined buffer to fill with data (can be null)
  46332. * @returns The Array buffer containing the pixels data.
  46333. */
  46334. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46335. /**
  46336. * Release and destroy the underlying lower level texture aka internalTexture.
  46337. */
  46338. releaseInternalTexture(): void;
  46339. /**
  46340. * Get the polynomial representation of the texture data.
  46341. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46342. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46343. */
  46344. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46345. /** @hidden */
  46346. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46347. /** @hidden */
  46348. readonly _lodTextureMid: Nullable<BaseTexture>;
  46349. /** @hidden */
  46350. readonly _lodTextureLow: Nullable<BaseTexture>;
  46351. /**
  46352. * Dispose the texture and release its associated resources.
  46353. */
  46354. dispose(): void;
  46355. /**
  46356. * Serialize the texture into a JSON representation that can be parsed later on.
  46357. * @returns the JSON representation of the texture
  46358. */
  46359. serialize(): any;
  46360. /**
  46361. * Helper function to be called back once a list of texture contains only ready textures.
  46362. * @param textures Define the list of textures to wait for
  46363. * @param callback Define the callback triggered once the entire list will be ready
  46364. */
  46365. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46366. }
  46367. }
  46368. declare module BABYLON {
  46369. /**
  46370. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46371. * It can help converting any input color in a desired output one. This can then be used to create effects
  46372. * from sepia, black and white to sixties or futuristic rendering...
  46373. *
  46374. * The only supported format is currently 3dl.
  46375. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46376. */
  46377. class ColorGradingTexture extends BaseTexture {
  46378. /**
  46379. * The current texture matrix. (will always be identity in color grading texture)
  46380. */
  46381. private _textureMatrix;
  46382. /**
  46383. * The texture URL.
  46384. */
  46385. url: string;
  46386. /**
  46387. * Empty line regex stored for GC.
  46388. */
  46389. private static _noneEmptyLineRegex;
  46390. private _engine;
  46391. /**
  46392. * Instantiates a ColorGradingTexture from the following parameters.
  46393. *
  46394. * @param url The location of the color gradind data (currently only supporting 3dl)
  46395. * @param scene The scene the texture will be used in
  46396. */
  46397. constructor(url: string, scene: Scene);
  46398. /**
  46399. * Returns the texture matrix used in most of the material.
  46400. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46401. */
  46402. getTextureMatrix(): Matrix;
  46403. /**
  46404. * Occurs when the file being loaded is a .3dl LUT file.
  46405. */
  46406. private load3dlTexture;
  46407. /**
  46408. * Starts the loading process of the texture.
  46409. */
  46410. private loadTexture;
  46411. /**
  46412. * Clones the color gradind texture.
  46413. */
  46414. clone(): ColorGradingTexture;
  46415. /**
  46416. * Called during delayed load for textures.
  46417. */
  46418. delayLoad(): void;
  46419. /**
  46420. * Parses a color grading texture serialized by Babylon.
  46421. * @param parsedTexture The texture information being parsedTexture
  46422. * @param scene The scene to load the texture in
  46423. * @param rootUrl The root url of the data assets to load
  46424. * @return A color gradind texture
  46425. */
  46426. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46427. /**
  46428. * Serializes the LUT texture to json format.
  46429. */
  46430. serialize(): any;
  46431. }
  46432. }
  46433. declare module BABYLON {
  46434. /**
  46435. * Class for creating a cube texture
  46436. */
  46437. class CubeTexture extends BaseTexture {
  46438. /**
  46439. * The url of the texture
  46440. */
  46441. url: string;
  46442. /**
  46443. * Gets or sets the center of the bounding box associated with the cube texture.
  46444. * It must define where the camera used to render the texture was set
  46445. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46446. */
  46447. boundingBoxPosition: Vector3;
  46448. private _boundingBoxSize;
  46449. /**
  46450. * Gets or sets the size of the bounding box associated with the cube texture
  46451. * When defined, the cubemap will switch to local mode
  46452. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46453. * @example https://www.babylonjs-playground.com/#RNASML
  46454. */
  46455. /**
  46456. * Returns the bounding box size
  46457. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46458. */
  46459. boundingBoxSize: Vector3;
  46460. protected _rotationY: number;
  46461. /**
  46462. * Sets texture matrix rotation angle around Y axis in radians.
  46463. */
  46464. /**
  46465. * Gets texture matrix rotation angle around Y axis radians.
  46466. */
  46467. rotationY: number;
  46468. private _noMipmap;
  46469. private _files;
  46470. private _extensions;
  46471. private _textureMatrix;
  46472. private _format;
  46473. private _createPolynomials;
  46474. /** @hidden */
  46475. readonly _prefiltered: boolean;
  46476. /**
  46477. * Creates a cube texture from an array of image urls
  46478. * @param files defines an array of image urls
  46479. * @param scene defines the hosting scene
  46480. * @param noMipmap specifies if mip maps are not used
  46481. * @returns a cube texture
  46482. */
  46483. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46484. /**
  46485. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46486. * @param url defines the url of the prefiltered texture
  46487. * @param scene defines the scene the texture is attached to
  46488. * @param forcedExtension defines the extension of the file if different from the url
  46489. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46490. * @return the prefiltered texture
  46491. */
  46492. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46493. /**
  46494. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46495. * as prefiltered data.
  46496. * @param rootUrl defines the url of the texture or the root name of the six images
  46497. * @param scene defines the scene the texture is attached to
  46498. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46499. * @param noMipmap defines if mipmaps should be created or not
  46500. * @param files defines the six files to load for the different faces
  46501. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46502. * @param onError defines a callback triggered in case of error during load
  46503. * @param format defines the internal format to use for the texture once loaded
  46504. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46505. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46506. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46507. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46508. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46509. * @return the cube texture
  46510. */
  46511. 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);
  46512. /**
  46513. * Delays loading of the cube texture
  46514. */
  46515. delayLoad(): void;
  46516. /**
  46517. * Returns the reflection texture matrix
  46518. * @returns the reflection texture matrix
  46519. */
  46520. getReflectionTextureMatrix(): Matrix;
  46521. /**
  46522. * Sets the reflection texture matrix
  46523. * @param value Reflection texture matrix
  46524. */
  46525. setReflectionTextureMatrix(value: Matrix): void;
  46526. /**
  46527. * Parses text to create a cube texture
  46528. * @param parsedTexture define the serialized text to read from
  46529. * @param scene defines the hosting scene
  46530. * @param rootUrl defines the root url of the cube texture
  46531. * @returns a cube texture
  46532. */
  46533. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46534. /**
  46535. * Makes a clone, or deep copy, of the cube texture
  46536. * @returns a new cube texture
  46537. */
  46538. clone(): CubeTexture;
  46539. }
  46540. }
  46541. declare module BABYLON {
  46542. /**
  46543. * A class extending Texture allowing drawing on a texture
  46544. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46545. */
  46546. class DynamicTexture extends Texture {
  46547. private _generateMipMaps;
  46548. private _canvas;
  46549. private _context;
  46550. private _engine;
  46551. /**
  46552. * Creates a DynamicTexture
  46553. * @param name defines the name of the texture
  46554. * @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
  46555. * @param scene defines the scene where you want the texture
  46556. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46557. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46558. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46559. */
  46560. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46561. /**
  46562. * Gets the current state of canRescale
  46563. */
  46564. readonly canRescale: boolean;
  46565. private _recreate;
  46566. /**
  46567. * Scales the texture
  46568. * @param ratio the scale factor to apply to both width and height
  46569. */
  46570. scale(ratio: number): void;
  46571. /**
  46572. * Resizes the texture
  46573. * @param width the new width
  46574. * @param height the new height
  46575. */
  46576. scaleTo(width: number, height: number): void;
  46577. /**
  46578. * Gets the context of the canvas used by the texture
  46579. * @returns the canvas context of the dynamic texture
  46580. */
  46581. getContext(): CanvasRenderingContext2D;
  46582. /**
  46583. * Clears the texture
  46584. */
  46585. clear(): void;
  46586. /**
  46587. * Updates the texture
  46588. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46589. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46590. */
  46591. update(invertY?: boolean, premulAlpha?: boolean): void;
  46592. /**
  46593. * Draws text onto the texture
  46594. * @param text defines the text to be drawn
  46595. * @param x defines the placement of the text from the left
  46596. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46597. * @param font defines the font to be used with font-style, font-size, font-name
  46598. * @param color defines the color used for the text
  46599. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46600. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46601. * @param update defines whether texture is immediately update (default is true)
  46602. */
  46603. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46604. /**
  46605. * Clones the texture
  46606. * @returns the clone of the texture.
  46607. */
  46608. clone(): DynamicTexture;
  46609. /**
  46610. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46611. * @returns a serialized dynamic texture object
  46612. */
  46613. serialize(): any;
  46614. /** @hidden */
  46615. _rebuild(): void;
  46616. }
  46617. }
  46618. declare module BABYLON {
  46619. /**
  46620. * This represents a texture coming from an HDR input.
  46621. *
  46622. * The only supported format is currently panorama picture stored in RGBE format.
  46623. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46624. */
  46625. class HDRCubeTexture extends BaseTexture {
  46626. private static _facesMapping;
  46627. private _generateHarmonics;
  46628. private _noMipmap;
  46629. private _textureMatrix;
  46630. private _size;
  46631. private _onLoad;
  46632. private _onError;
  46633. /**
  46634. * The texture URL.
  46635. */
  46636. url: string;
  46637. /**
  46638. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46639. */
  46640. coordinatesMode: number;
  46641. protected _isBlocking: boolean;
  46642. /**
  46643. * Sets wether or not the texture is blocking during loading.
  46644. */
  46645. /**
  46646. * Gets wether or not the texture is blocking during loading.
  46647. */
  46648. isBlocking: boolean;
  46649. protected _rotationY: number;
  46650. /**
  46651. * Sets texture matrix rotation angle around Y axis in radians.
  46652. */
  46653. /**
  46654. * Gets texture matrix rotation angle around Y axis radians.
  46655. */
  46656. rotationY: number;
  46657. /**
  46658. * Gets or sets the center of the bounding box associated with the cube texture
  46659. * It must define where the camera used to render the texture was set
  46660. */
  46661. boundingBoxPosition: Vector3;
  46662. private _boundingBoxSize;
  46663. /**
  46664. * Gets or sets the size of the bounding box associated with the cube texture
  46665. * When defined, the cubemap will switch to local mode
  46666. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46667. * @example https://www.babylonjs-playground.com/#RNASML
  46668. */
  46669. boundingBoxSize: Vector3;
  46670. /**
  46671. * Instantiates an HDRTexture from the following parameters.
  46672. *
  46673. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46674. * @param scene The scene the texture will be used in
  46675. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46676. * @param noMipmap Forces to not generate the mipmap if true
  46677. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46678. * @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)
  46679. * @param reserved Reserved flag for internal use.
  46680. */
  46681. 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>);
  46682. /**
  46683. * Occurs when the file is raw .hdr file.
  46684. */
  46685. private loadTexture;
  46686. clone(): HDRCubeTexture;
  46687. delayLoad(): void;
  46688. /**
  46689. * Get the texture reflection matrix used to rotate/transform the reflection.
  46690. * @returns the reflection matrix
  46691. */
  46692. getReflectionTextureMatrix(): Matrix;
  46693. /**
  46694. * Set the texture reflection matrix used to rotate/transform the reflection.
  46695. * @param value Define the reflection matrix to set
  46696. */
  46697. setReflectionTextureMatrix(value: Matrix): void;
  46698. /**
  46699. * Parses a JSON representation of an HDR Texture in order to create the texture
  46700. * @param parsedTexture Define the JSON representation
  46701. * @param scene Define the scene the texture should be created in
  46702. * @param rootUrl Define the root url in case we need to load relative dependencies
  46703. * @returns the newly created texture after parsing
  46704. */
  46705. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46706. serialize(): any;
  46707. }
  46708. }
  46709. declare module BABYLON {
  46710. /**
  46711. * Class used to store data associated with WebGL texture data for the engine
  46712. * This class should not be used directly
  46713. */
  46714. class InternalTexture implements IInternalTextureTracker {
  46715. /**
  46716. * The source of the texture data is unknown
  46717. */
  46718. static DATASOURCE_UNKNOWN: number;
  46719. /**
  46720. * Texture data comes from an URL
  46721. */
  46722. static DATASOURCE_URL: number;
  46723. /**
  46724. * Texture data is only used for temporary storage
  46725. */
  46726. static DATASOURCE_TEMP: number;
  46727. /**
  46728. * Texture data comes from raw data (ArrayBuffer)
  46729. */
  46730. static DATASOURCE_RAW: number;
  46731. /**
  46732. * Texture content is dynamic (video or dynamic texture)
  46733. */
  46734. static DATASOURCE_DYNAMIC: number;
  46735. /**
  46736. * Texture content is generated by rendering to it
  46737. */
  46738. static DATASOURCE_RENDERTARGET: number;
  46739. /**
  46740. * Texture content is part of a multi render target process
  46741. */
  46742. static DATASOURCE_MULTIRENDERTARGET: number;
  46743. /**
  46744. * Texture data comes from a cube data file
  46745. */
  46746. static DATASOURCE_CUBE: number;
  46747. /**
  46748. * Texture data comes from a raw cube data
  46749. */
  46750. static DATASOURCE_CUBERAW: number;
  46751. /**
  46752. * Texture data come from a prefiltered cube data file
  46753. */
  46754. static DATASOURCE_CUBEPREFILTERED: number;
  46755. /**
  46756. * Texture content is raw 3D data
  46757. */
  46758. static DATASOURCE_RAW3D: number;
  46759. /**
  46760. * Texture content is a depth texture
  46761. */
  46762. static DATASOURCE_DEPTHTEXTURE: number;
  46763. /**
  46764. * Texture data comes from a raw cube data encoded with RGBD
  46765. */
  46766. static DATASOURCE_CUBERAW_RGBD: number;
  46767. /**
  46768. * Defines if the texture is ready
  46769. */
  46770. isReady: boolean;
  46771. /**
  46772. * Defines if the texture is a cube texture
  46773. */
  46774. isCube: boolean;
  46775. /**
  46776. * Defines if the texture contains 3D data
  46777. */
  46778. is3D: boolean;
  46779. /**
  46780. * Gets the URL used to load this texture
  46781. */
  46782. url: string;
  46783. /**
  46784. * Gets the sampling mode of the texture
  46785. */
  46786. samplingMode: number;
  46787. /**
  46788. * Gets a boolean indicating if the texture needs mipmaps generation
  46789. */
  46790. generateMipMaps: boolean;
  46791. /**
  46792. * Gets the number of samples used by the texture (WebGL2+ only)
  46793. */
  46794. samples: number;
  46795. /**
  46796. * Gets the type of the texture (int, float...)
  46797. */
  46798. type: number;
  46799. /**
  46800. * Gets the format of the texture (RGB, RGBA...)
  46801. */
  46802. format: number;
  46803. /**
  46804. * Observable called when the texture is loaded
  46805. */
  46806. onLoadedObservable: Observable<InternalTexture>;
  46807. /**
  46808. * Gets the width of the texture
  46809. */
  46810. width: number;
  46811. /**
  46812. * Gets the height of the texture
  46813. */
  46814. height: number;
  46815. /**
  46816. * Gets the depth of the texture
  46817. */
  46818. depth: number;
  46819. /**
  46820. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  46821. */
  46822. baseWidth: number;
  46823. /**
  46824. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  46825. */
  46826. baseHeight: number;
  46827. /**
  46828. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  46829. */
  46830. baseDepth: number;
  46831. /**
  46832. * Gets a boolean indicating if the texture is inverted on Y axis
  46833. */
  46834. invertY: boolean;
  46835. /**
  46836. * Gets or set the previous tracker in the list
  46837. */
  46838. previous: Nullable<IInternalTextureTracker>;
  46839. /**
  46840. * Gets or set the next tracker in the list
  46841. */
  46842. next: Nullable<IInternalTextureTracker>;
  46843. /** @hidden */
  46844. _initialSlot: number;
  46845. /** @hidden */
  46846. _designatedSlot: number;
  46847. /** @hidden */
  46848. _dataSource: number;
  46849. /** @hidden */
  46850. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  46851. /** @hidden */
  46852. _bufferView: Nullable<ArrayBufferView>;
  46853. /** @hidden */
  46854. _bufferViewArray: Nullable<ArrayBufferView[]>;
  46855. /** @hidden */
  46856. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  46857. /** @hidden */
  46858. _size: number;
  46859. /** @hidden */
  46860. _extension: string;
  46861. /** @hidden */
  46862. _files: Nullable<string[]>;
  46863. /** @hidden */
  46864. _workingCanvas: HTMLCanvasElement;
  46865. /** @hidden */
  46866. _workingContext: CanvasRenderingContext2D;
  46867. /** @hidden */
  46868. _framebuffer: Nullable<WebGLFramebuffer>;
  46869. /** @hidden */
  46870. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  46871. /** @hidden */
  46872. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  46873. /** @hidden */
  46874. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  46875. /** @hidden */
  46876. _attachments: Nullable<number[]>;
  46877. /** @hidden */
  46878. _cachedCoordinatesMode: Nullable<number>;
  46879. /** @hidden */
  46880. _cachedWrapU: Nullable<number>;
  46881. /** @hidden */
  46882. _cachedWrapV: Nullable<number>;
  46883. /** @hidden */
  46884. _cachedWrapR: Nullable<number>;
  46885. /** @hidden */
  46886. _cachedAnisotropicFilteringLevel: Nullable<number>;
  46887. /** @hidden */
  46888. _isDisabled: boolean;
  46889. /** @hidden */
  46890. _compression: Nullable<string>;
  46891. /** @hidden */
  46892. _generateStencilBuffer: boolean;
  46893. /** @hidden */
  46894. _generateDepthBuffer: boolean;
  46895. /** @hidden */
  46896. _comparisonFunction: number;
  46897. /** @hidden */
  46898. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  46899. /** @hidden */
  46900. _lodGenerationScale: number;
  46901. /** @hidden */
  46902. _lodGenerationOffset: number;
  46903. /** @hidden */
  46904. _lodTextureHigh: BaseTexture;
  46905. /** @hidden */
  46906. _lodTextureMid: BaseTexture;
  46907. /** @hidden */
  46908. _lodTextureLow: BaseTexture;
  46909. /** @hidden */
  46910. _isRGBD: boolean;
  46911. /** @hidden */
  46912. _webGLTexture: Nullable<WebGLTexture>;
  46913. /** @hidden */
  46914. _references: number;
  46915. private _engine;
  46916. /**
  46917. * Gets the Engine the texture belongs to.
  46918. * @returns The babylon engine
  46919. */
  46920. getEngine(): Engine;
  46921. /**
  46922. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  46923. */
  46924. readonly dataSource: number;
  46925. /**
  46926. * Creates a new InternalTexture
  46927. * @param engine defines the engine to use
  46928. * @param dataSource defines the type of data that will be used
  46929. * @param delayAllocation if the texture allocation should be delayed (default: false)
  46930. */
  46931. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  46932. /**
  46933. * Increments the number of references (ie. the number of Texture that point to it)
  46934. */
  46935. incrementReferences(): void;
  46936. /**
  46937. * Change the size of the texture (not the size of the content)
  46938. * @param width defines the new width
  46939. * @param height defines the new height
  46940. * @param depth defines the new depth (1 by default)
  46941. */
  46942. updateSize(width: int, height: int, depth?: int): void;
  46943. /** @hidden */
  46944. _rebuild(): void;
  46945. /** @hidden */
  46946. _swapAndDie(target: InternalTexture): void;
  46947. /**
  46948. * Dispose the current allocated resources
  46949. */
  46950. dispose(): void;
  46951. }
  46952. }
  46953. declare module BABYLON {
  46954. /**
  46955. * This represents the required contract to create a new type of texture loader.
  46956. */
  46957. interface IInternalTextureLoader {
  46958. /**
  46959. * Defines wether the loader supports cascade loading the different faces.
  46960. */
  46961. supportCascades: boolean;
  46962. /**
  46963. * This returns if the loader support the current file information.
  46964. * @param extension defines the file extension of the file being loaded
  46965. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46966. * @param fallback defines the fallback internal texture if any
  46967. * @param isBase64 defines whether the texture is encoded as a base64
  46968. * @param isBuffer defines whether the texture data are stored as a buffer
  46969. * @returns true if the loader can load the specified file
  46970. */
  46971. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46972. /**
  46973. * Transform the url before loading if required.
  46974. * @param rootUrl the url of the texture
  46975. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46976. * @returns the transformed texture
  46977. */
  46978. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46979. /**
  46980. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46981. * @param rootUrl the url of the texture
  46982. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46983. * @returns the fallback texture
  46984. */
  46985. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46986. /**
  46987. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46988. * @param data contains the texture data
  46989. * @param texture defines the BabylonJS internal texture
  46990. * @param createPolynomials will be true if polynomials have been requested
  46991. * @param onLoad defines the callback to trigger once the texture is ready
  46992. * @param onError defines the callback to trigger in case of error
  46993. */
  46994. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46995. /**
  46996. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46997. * @param data contains the texture data
  46998. * @param texture defines the BabylonJS internal texture
  46999. * @param callback defines the method to call once ready to upload
  47000. */
  47001. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47002. }
  47003. }
  47004. declare module BABYLON {
  47005. /**
  47006. * Internal interface used to track InternalTexture already bound to the GL context
  47007. */
  47008. interface IInternalTextureTracker {
  47009. /**
  47010. * Gets or set the previous tracker in the list
  47011. */
  47012. previous: Nullable<IInternalTextureTracker>;
  47013. /**
  47014. * Gets or set the next tracker in the list
  47015. */
  47016. next: Nullable<IInternalTextureTracker>;
  47017. }
  47018. /**
  47019. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47020. */
  47021. class DummyInternalTextureTracker {
  47022. /**
  47023. * Gets or set the previous tracker in the list
  47024. */
  47025. previous: Nullable<IInternalTextureTracker>;
  47026. /**
  47027. * Gets or set the next tracker in the list
  47028. */
  47029. next: Nullable<IInternalTextureTracker>;
  47030. }
  47031. }
  47032. declare module BABYLON {
  47033. /**
  47034. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47035. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47036. * You can then easily use it as a reflectionTexture on a flat surface.
  47037. * In case the surface is not a plane, please consider relying on reflection probes.
  47038. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47039. */
  47040. class MirrorTexture extends RenderTargetTexture {
  47041. private scene;
  47042. /**
  47043. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47044. * 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.
  47045. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47046. */
  47047. mirrorPlane: Plane;
  47048. /**
  47049. * Define the blur ratio used to blur the reflection if needed.
  47050. */
  47051. blurRatio: number;
  47052. /**
  47053. * Define the adaptive blur kernel used to blur the reflection if needed.
  47054. * This will autocompute the closest best match for the `blurKernel`
  47055. */
  47056. adaptiveBlurKernel: number;
  47057. /**
  47058. * Define the blur kernel used to blur the reflection if needed.
  47059. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47060. */
  47061. blurKernel: number;
  47062. /**
  47063. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47064. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47065. */
  47066. blurKernelX: number;
  47067. /**
  47068. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47069. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47070. */
  47071. blurKernelY: number;
  47072. private _autoComputeBlurKernel;
  47073. protected _onRatioRescale(): void;
  47074. private _updateGammaSpace;
  47075. private _imageProcessingConfigChangeObserver;
  47076. private _transformMatrix;
  47077. private _mirrorMatrix;
  47078. private _savedViewMatrix;
  47079. private _blurX;
  47080. private _blurY;
  47081. private _adaptiveBlurKernel;
  47082. private _blurKernelX;
  47083. private _blurKernelY;
  47084. private _blurRatio;
  47085. /**
  47086. * Instantiates a Mirror Texture.
  47087. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47088. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47089. * You can then easily use it as a reflectionTexture on a flat surface.
  47090. * In case the surface is not a plane, please consider relying on reflection probes.
  47091. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47092. * @param name
  47093. * @param size
  47094. * @param scene
  47095. * @param generateMipMaps
  47096. * @param type
  47097. * @param samplingMode
  47098. * @param generateDepthBuffer
  47099. */
  47100. constructor(name: string, size: number | {
  47101. width: number;
  47102. height: number;
  47103. } | {
  47104. ratio: number;
  47105. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47106. private _preparePostProcesses;
  47107. /**
  47108. * Clone the mirror texture.
  47109. * @returns the cloned texture
  47110. */
  47111. clone(): MirrorTexture;
  47112. /**
  47113. * Serialize the texture to a JSON representation you could use in Parse later on
  47114. * @returns the serialized JSON representation
  47115. */
  47116. serialize(): any;
  47117. /**
  47118. * Dispose the texture and release its associated resources.
  47119. */
  47120. dispose(): void;
  47121. }
  47122. }
  47123. declare module BABYLON {
  47124. /**
  47125. * Creation options of the multi render target texture.
  47126. */
  47127. interface IMultiRenderTargetOptions {
  47128. /**
  47129. * Define if the texture needs to create mip maps after render.
  47130. */
  47131. generateMipMaps?: boolean;
  47132. /**
  47133. * Define the types of all the draw buffers we want to create
  47134. */
  47135. types?: number[];
  47136. /**
  47137. * Define the sampling modes of all the draw buffers we want to create
  47138. */
  47139. samplingModes?: number[];
  47140. /**
  47141. * Define if a depth buffer is required
  47142. */
  47143. generateDepthBuffer?: boolean;
  47144. /**
  47145. * Define if a stencil buffer is required
  47146. */
  47147. generateStencilBuffer?: boolean;
  47148. /**
  47149. * Define if a depth texture is required instead of a depth buffer
  47150. */
  47151. generateDepthTexture?: boolean;
  47152. /**
  47153. * Define the number of desired draw buffers
  47154. */
  47155. textureCount?: number;
  47156. /**
  47157. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47158. */
  47159. doNotChangeAspectRatio?: boolean;
  47160. /**
  47161. * Define the default type of the buffers we are creating
  47162. */
  47163. defaultType?: number;
  47164. }
  47165. /**
  47166. * A multi render target, like a render target provides the ability to render to a texture.
  47167. * Unlike the render target, it can render to several draw buffers in one draw.
  47168. * This is specially interesting in deferred rendering or for any effects requiring more than
  47169. * just one color from a single pass.
  47170. */
  47171. class MultiRenderTarget extends RenderTargetTexture {
  47172. private _internalTextures;
  47173. private _textures;
  47174. private _multiRenderTargetOptions;
  47175. /**
  47176. * Get if draw buffers are currently supported by the used hardware and browser.
  47177. */
  47178. readonly isSupported: boolean;
  47179. /**
  47180. * Get the list of textures generated by the multi render target.
  47181. */
  47182. readonly textures: Texture[];
  47183. /**
  47184. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47185. */
  47186. readonly depthTexture: Texture;
  47187. /**
  47188. * Set the wrapping mode on U of all the textures we are rendering to.
  47189. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47190. */
  47191. wrapU: number;
  47192. /**
  47193. * Set the wrapping mode on V of all the textures we are rendering to.
  47194. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47195. */
  47196. wrapV: number;
  47197. /**
  47198. * Instantiate a new multi render target texture.
  47199. * A multi render target, like a render target provides the ability to render to a texture.
  47200. * Unlike the render target, it can render to several draw buffers in one draw.
  47201. * This is specially interesting in deferred rendering or for any effects requiring more than
  47202. * just one color from a single pass.
  47203. * @param name Define the name of the texture
  47204. * @param size Define the size of the buffers to render to
  47205. * @param count Define the number of target we are rendering into
  47206. * @param scene Define the scene the texture belongs to
  47207. * @param options Define the options used to create the multi render target
  47208. */
  47209. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47210. /** @hidden */
  47211. _rebuild(): void;
  47212. private _createInternalTextures;
  47213. private _createTextures;
  47214. /**
  47215. * Define the number of samples used if MSAA is enabled.
  47216. */
  47217. samples: number;
  47218. /**
  47219. * Resize all the textures in the multi render target.
  47220. * Be carrefull as it will recreate all the data in the new texture.
  47221. * @param size Define the new size
  47222. */
  47223. resize(size: any): void;
  47224. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47225. /**
  47226. * Dispose the render targets and their associated resources
  47227. */
  47228. dispose(): void;
  47229. /**
  47230. * Release all the underlying texture used as draw buffers.
  47231. */
  47232. releaseInternalTextures(): void;
  47233. }
  47234. }
  47235. declare module BABYLON {
  47236. /**
  47237. * Raw cube texture where the raw buffers are passed in
  47238. */
  47239. class RawCubeTexture extends CubeTexture {
  47240. /**
  47241. * Creates a cube texture where the raw buffers are passed in.
  47242. * @param scene defines the scene the texture is attached to
  47243. * @param data defines the array of data to use to create each face
  47244. * @param size defines the size of the textures
  47245. * @param format defines the format of the data
  47246. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47247. * @param generateMipMaps defines if the engine should generate the mip levels
  47248. * @param invertY defines if data must be stored with Y axis inverted
  47249. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47250. * @param compression defines the compression used (null by default)
  47251. */
  47252. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47253. /**
  47254. * Updates the raw cube texture.
  47255. * @param data defines the data to store
  47256. * @param format defines the data format
  47257. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47258. * @param invertY defines if data must be stored with Y axis inverted
  47259. * @param compression defines the compression used (null by default)
  47260. * @param level defines which level of the texture to update
  47261. */
  47262. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47263. /**
  47264. * Updates a raw cube texture with RGBD encoded data.
  47265. * @param data defines the array of data [mipmap][face] to use to create each face
  47266. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47267. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47268. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47269. * @returns a promsie that resolves when the operation is complete
  47270. */
  47271. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47272. /**
  47273. * Clones the raw cube texture.
  47274. * @return a new cube texture
  47275. */
  47276. clone(): CubeTexture;
  47277. /** @hidden */
  47278. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47279. }
  47280. }
  47281. declare module BABYLON {
  47282. /**
  47283. * Raw texture can help creating a texture directly from an array of data.
  47284. * This can be super useful if you either get the data from an uncompressed source or
  47285. * if you wish to create your texture pixel by pixel.
  47286. */
  47287. class RawTexture extends Texture {
  47288. /**
  47289. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47290. */
  47291. format: number;
  47292. private _engine;
  47293. /**
  47294. * Instantiates a new RawTexture.
  47295. * Raw texture can help creating a texture directly from an array of data.
  47296. * This can be super useful if you either get the data from an uncompressed source or
  47297. * if you wish to create your texture pixel by pixel.
  47298. * @param data define the array of data to use to create the texture
  47299. * @param width define the width of the texture
  47300. * @param height define the height of the texture
  47301. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47302. * @param scene define the scene the texture belongs to
  47303. * @param generateMipMaps define whether mip maps should be generated or not
  47304. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47305. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47306. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47307. */
  47308. constructor(data: ArrayBufferView, width: number, height: number,
  47309. /**
  47310. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47311. */
  47312. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47313. /**
  47314. * Updates the texture underlying data.
  47315. * @param data Define the new data of the texture
  47316. */
  47317. update(data: ArrayBufferView): void;
  47318. /**
  47319. * Creates a luminance texture from some data.
  47320. * @param data Define the texture data
  47321. * @param width Define the width of the texture
  47322. * @param height Define the height of the texture
  47323. * @param scene Define the scene the texture belongs to
  47324. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47325. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47326. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47327. * @returns the luminance texture
  47328. */
  47329. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47330. /**
  47331. * Creates a luminance alpha texture from some data.
  47332. * @param data Define the texture data
  47333. * @param width Define the width of the texture
  47334. * @param height Define the height of the texture
  47335. * @param scene Define the scene the texture belongs to
  47336. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47337. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47338. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47339. * @returns the luminance alpha texture
  47340. */
  47341. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47342. /**
  47343. * Creates an alpha texture from some data.
  47344. * @param data Define the texture data
  47345. * @param width Define the width of the texture
  47346. * @param height Define the height of the texture
  47347. * @param scene Define the scene the texture belongs to
  47348. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47349. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47350. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47351. * @returns the alpha texture
  47352. */
  47353. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47354. /**
  47355. * Creates a RGB texture from some data.
  47356. * @param data Define the texture data
  47357. * @param width Define the width of the texture
  47358. * @param height Define the height of the texture
  47359. * @param scene Define the scene the texture belongs to
  47360. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47361. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47362. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47363. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47364. * @returns the RGB alpha texture
  47365. */
  47366. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47367. /**
  47368. * Creates a RGBA texture from some data.
  47369. * @param data Define the texture data
  47370. * @param width Define the width of the texture
  47371. * @param height Define the height of the texture
  47372. * @param scene Define the scene the texture belongs to
  47373. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47374. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47375. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47376. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47377. * @returns the RGBA texture
  47378. */
  47379. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47380. /**
  47381. * Creates a R texture from some data.
  47382. * @param data Define the texture data
  47383. * @param width Define the width of the texture
  47384. * @param height Define the height of the texture
  47385. * @param scene Define the scene the texture belongs to
  47386. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47387. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47388. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47389. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47390. * @returns the R texture
  47391. */
  47392. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47393. }
  47394. }
  47395. declare module BABYLON {
  47396. /**
  47397. * Class used to store 3D textures containing user data
  47398. */
  47399. class RawTexture3D extends Texture {
  47400. /** Gets or sets the texture format to use */
  47401. format: number;
  47402. private _engine;
  47403. /**
  47404. * Create a new RawTexture3D
  47405. * @param data defines the data of the texture
  47406. * @param width defines the width of the texture
  47407. * @param height defines the height of the texture
  47408. * @param depth defines the depth of the texture
  47409. * @param format defines the texture format to use
  47410. * @param scene defines the hosting scene
  47411. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47412. * @param invertY defines if texture must be stored with Y axis inverted
  47413. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47414. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47415. */
  47416. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47417. /** Gets or sets the texture format to use */
  47418. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47419. /**
  47420. * Update the texture with new data
  47421. * @param data defines the data to store in the texture
  47422. */
  47423. update(data: ArrayBufferView): void;
  47424. }
  47425. }
  47426. declare module BABYLON {
  47427. /**
  47428. * Creates a refraction texture used by refraction channel of the standard material.
  47429. * It is like a mirror but to see through a material.
  47430. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47431. */
  47432. class RefractionTexture extends RenderTargetTexture {
  47433. /**
  47434. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47435. * 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.
  47436. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47437. */
  47438. refractionPlane: Plane;
  47439. /**
  47440. * Define how deep under the surface we should see.
  47441. */
  47442. depth: number;
  47443. /**
  47444. * Creates a refraction texture used by refraction channel of the standard material.
  47445. * It is like a mirror but to see through a material.
  47446. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47447. * @param name Define the texture name
  47448. * @param size Define the size of the underlying texture
  47449. * @param scene Define the scene the refraction belongs to
  47450. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47451. */
  47452. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47453. /**
  47454. * Clone the refraction texture.
  47455. * @returns the cloned texture
  47456. */
  47457. clone(): RefractionTexture;
  47458. /**
  47459. * Serialize the texture to a JSON representation you could use in Parse later on
  47460. * @returns the serialized JSON representation
  47461. */
  47462. serialize(): any;
  47463. }
  47464. }
  47465. declare module BABYLON {
  47466. /**
  47467. * This Helps creating a texture that will be created from a camera in your scene.
  47468. * It is basically a dynamic texture that could be used to create special effects for instance.
  47469. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47470. */
  47471. class RenderTargetTexture extends Texture {
  47472. isCube: boolean;
  47473. /**
  47474. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47475. */
  47476. static readonly REFRESHRATE_RENDER_ONCE: number;
  47477. /**
  47478. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47479. */
  47480. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47481. /**
  47482. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47483. * the central point of your effect and can save a lot of performances.
  47484. */
  47485. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47486. /**
  47487. * Use this predicate to dynamically define the list of mesh you want to render.
  47488. * If set, the renderList property will be overwritten.
  47489. */
  47490. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47491. private _renderList;
  47492. /**
  47493. * Use this list to define the list of mesh you want to render.
  47494. */
  47495. renderList: Nullable<Array<AbstractMesh>>;
  47496. private _hookArray;
  47497. /**
  47498. * Define if particles should be rendered in your texture.
  47499. */
  47500. renderParticles: boolean;
  47501. /**
  47502. * Define if sprites should be rendered in your texture.
  47503. */
  47504. renderSprites: boolean;
  47505. /**
  47506. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47507. */
  47508. coordinatesMode: number;
  47509. /**
  47510. * Define the camera used to render the texture.
  47511. */
  47512. activeCamera: Nullable<Camera>;
  47513. /**
  47514. * Override the render function of the texture with your own one.
  47515. */
  47516. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47517. /**
  47518. * Define if camera post processes should be use while rendering the texture.
  47519. */
  47520. useCameraPostProcesses: boolean;
  47521. /**
  47522. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47523. */
  47524. ignoreCameraViewport: boolean;
  47525. private _postProcessManager;
  47526. private _postProcesses;
  47527. private _resizeObserver;
  47528. /**
  47529. * An event triggered when the texture is unbind.
  47530. */
  47531. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47532. /**
  47533. * An event triggered when the texture is unbind.
  47534. */
  47535. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47536. private _onAfterUnbindObserver;
  47537. /**
  47538. * Set a after unbind callback in the texture.
  47539. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47540. */
  47541. onAfterUnbind: () => void;
  47542. /**
  47543. * An event triggered before rendering the texture
  47544. */
  47545. onBeforeRenderObservable: Observable<number>;
  47546. private _onBeforeRenderObserver;
  47547. /**
  47548. * Set a before render callback in the texture.
  47549. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47550. */
  47551. onBeforeRender: (faceIndex: number) => void;
  47552. /**
  47553. * An event triggered after rendering the texture
  47554. */
  47555. onAfterRenderObservable: Observable<number>;
  47556. private _onAfterRenderObserver;
  47557. /**
  47558. * Set a after render callback in the texture.
  47559. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47560. */
  47561. onAfterRender: (faceIndex: number) => void;
  47562. /**
  47563. * An event triggered after the texture clear
  47564. */
  47565. onClearObservable: Observable<Engine>;
  47566. private _onClearObserver;
  47567. /**
  47568. * Set a clear callback in the texture.
  47569. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47570. */
  47571. onClear: (Engine: Engine) => void;
  47572. /**
  47573. * Define the clear color of the Render Target if it should be different from the scene.
  47574. */
  47575. clearColor: Color4;
  47576. protected _size: number | {
  47577. width: number;
  47578. height: number;
  47579. };
  47580. protected _initialSizeParameter: number | {
  47581. width: number;
  47582. height: number;
  47583. } | {
  47584. ratio: number;
  47585. };
  47586. protected _sizeRatio: Nullable<number>;
  47587. /** @hidden */
  47588. _generateMipMaps: boolean;
  47589. protected _renderingManager: RenderingManager;
  47590. /** @hidden */
  47591. _waitingRenderList: string[];
  47592. protected _doNotChangeAspectRatio: boolean;
  47593. protected _currentRefreshId: number;
  47594. protected _refreshRate: number;
  47595. protected _textureMatrix: Matrix;
  47596. protected _samples: number;
  47597. protected _renderTargetOptions: RenderTargetCreationOptions;
  47598. /**
  47599. * Gets render target creation options that were used.
  47600. */
  47601. readonly renderTargetOptions: RenderTargetCreationOptions;
  47602. protected _engine: Engine;
  47603. protected _onRatioRescale(): void;
  47604. /**
  47605. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47606. * It must define where the camera used to render the texture is set
  47607. */
  47608. boundingBoxPosition: Vector3;
  47609. private _boundingBoxSize;
  47610. /**
  47611. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47612. * When defined, the cubemap will switch to local mode
  47613. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47614. * @example https://www.babylonjs-playground.com/#RNASML
  47615. */
  47616. boundingBoxSize: Vector3;
  47617. /**
  47618. * In case the RTT has been created with a depth texture, get the associated
  47619. * depth texture.
  47620. * Otherwise, return null.
  47621. */
  47622. depthStencilTexture: Nullable<InternalTexture>;
  47623. /**
  47624. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47625. * or used a shadow, depth texture...
  47626. * @param name The friendly name of the texture
  47627. * @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)
  47628. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47629. * @param generateMipMaps True if mip maps need to be generated after render.
  47630. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47631. * @param type The type of the buffer in the RTT (int, half float, float...)
  47632. * @param isCube True if a cube texture needs to be created
  47633. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47634. * @param generateDepthBuffer True to generate a depth buffer
  47635. * @param generateStencilBuffer True to generate a stencil buffer
  47636. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47637. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47638. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47639. */
  47640. constructor(name: string, size: number | {
  47641. width: number;
  47642. height: number;
  47643. } | {
  47644. ratio: number;
  47645. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47646. /**
  47647. * Creates a depth stencil texture.
  47648. * This is only available in WebGL 2 or with the depth texture extension available.
  47649. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  47650. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  47651. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  47652. */
  47653. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  47654. private _processSizeParameter;
  47655. /**
  47656. * Define the number of samples to use in case of MSAA.
  47657. * It defaults to one meaning no MSAA has been enabled.
  47658. */
  47659. samples: number;
  47660. /**
  47661. * Resets the refresh counter of the texture and start bak from scratch.
  47662. * Could be usefull to regenerate the texture if it is setup to render only once.
  47663. */
  47664. resetRefreshCounter(): void;
  47665. /**
  47666. * Define the refresh rate of the texture or the rendering frequency.
  47667. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47668. */
  47669. refreshRate: number;
  47670. /**
  47671. * Adds a post process to the render target rendering passes.
  47672. * @param postProcess define the post process to add
  47673. */
  47674. addPostProcess(postProcess: PostProcess): void;
  47675. /**
  47676. * Clear all the post processes attached to the render target
  47677. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47678. */
  47679. clearPostProcesses(dispose?: boolean): void;
  47680. /**
  47681. * Remove one of the post process from the list of attached post processes to the texture
  47682. * @param postProcess define the post process to remove from the list
  47683. */
  47684. removePostProcess(postProcess: PostProcess): void;
  47685. /** @hidden */
  47686. _shouldRender(): boolean;
  47687. /**
  47688. * Gets the actual render size of the texture.
  47689. * @returns the width of the render size
  47690. */
  47691. getRenderSize(): number;
  47692. /**
  47693. * Gets the actual render width of the texture.
  47694. * @returns the width of the render size
  47695. */
  47696. getRenderWidth(): number;
  47697. /**
  47698. * Gets the actual render height of the texture.
  47699. * @returns the height of the render size
  47700. */
  47701. getRenderHeight(): number;
  47702. /**
  47703. * Get if the texture can be rescaled or not.
  47704. */
  47705. readonly canRescale: boolean;
  47706. /**
  47707. * Resize the texture using a ratio.
  47708. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47709. */
  47710. scale(ratio: number): void;
  47711. /**
  47712. * Get the texture reflection matrix used to rotate/transform the reflection.
  47713. * @returns the reflection matrix
  47714. */
  47715. getReflectionTextureMatrix(): Matrix;
  47716. /**
  47717. * Resize the texture to a new desired size.
  47718. * Be carrefull as it will recreate all the data in the new texture.
  47719. * @param size Define the new size. It can be:
  47720. * - a number for squared texture,
  47721. * - an object containing { width: number, height: number }
  47722. * - or an object containing a ratio { ratio: number }
  47723. */
  47724. resize(size: number | {
  47725. width: number;
  47726. height: number;
  47727. } | {
  47728. ratio: number;
  47729. }): void;
  47730. /**
  47731. * Renders all the objects from the render list into the texture.
  47732. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  47733. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  47734. */
  47735. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  47736. private _bestReflectionRenderTargetDimension;
  47737. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47738. private renderToTarget;
  47739. /**
  47740. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47741. * This allowed control for front to back rendering or reversly depending of the special needs.
  47742. *
  47743. * @param renderingGroupId The rendering group id corresponding to its index
  47744. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47745. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47746. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47747. */
  47748. 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;
  47749. /**
  47750. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47751. *
  47752. * @param renderingGroupId The rendering group id corresponding to its index
  47753. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47754. */
  47755. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47756. /**
  47757. * Clones the texture.
  47758. * @returns the cloned texture
  47759. */
  47760. clone(): RenderTargetTexture;
  47761. /**
  47762. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47763. * @returns The JSON representation of the texture
  47764. */
  47765. serialize(): any;
  47766. /**
  47767. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  47768. */
  47769. disposeFramebufferObjects(): void;
  47770. /**
  47771. * Dispose the texture and release its associated resources.
  47772. */
  47773. dispose(): void;
  47774. /** @hidden */
  47775. _rebuild(): void;
  47776. /**
  47777. * Clear the info related to rendering groups preventing retention point in material dispose.
  47778. */
  47779. freeRenderingGroups(): void;
  47780. }
  47781. }
  47782. declare module BABYLON {
  47783. /**
  47784. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47785. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47786. */
  47787. class Texture extends BaseTexture {
  47788. /** nearest is mag = nearest and min = nearest and mip = linear */
  47789. static readonly NEAREST_SAMPLINGMODE: number;
  47790. /** nearest is mag = nearest and min = nearest and mip = linear */
  47791. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  47792. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47793. static readonly BILINEAR_SAMPLINGMODE: number;
  47794. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47795. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  47796. /** Trilinear is mag = linear and min = linear and mip = linear */
  47797. static readonly TRILINEAR_SAMPLINGMODE: number;
  47798. /** Trilinear is mag = linear and min = linear and mip = linear */
  47799. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  47800. /** mag = nearest and min = nearest and mip = nearest */
  47801. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  47802. /** mag = nearest and min = linear and mip = nearest */
  47803. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  47804. /** mag = nearest and min = linear and mip = linear */
  47805. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  47806. /** mag = nearest and min = linear and mip = none */
  47807. static readonly NEAREST_LINEAR: number;
  47808. /** mag = nearest and min = nearest and mip = none */
  47809. static readonly NEAREST_NEAREST: number;
  47810. /** mag = linear and min = nearest and mip = nearest */
  47811. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  47812. /** mag = linear and min = nearest and mip = linear */
  47813. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  47814. /** mag = linear and min = linear and mip = none */
  47815. static readonly LINEAR_LINEAR: number;
  47816. /** mag = linear and min = nearest and mip = none */
  47817. static readonly LINEAR_NEAREST: number;
  47818. /** Explicit coordinates mode */
  47819. static readonly EXPLICIT_MODE: number;
  47820. /** Spherical coordinates mode */
  47821. static readonly SPHERICAL_MODE: number;
  47822. /** Planar coordinates mode */
  47823. static readonly PLANAR_MODE: number;
  47824. /** Cubic coordinates mode */
  47825. static readonly CUBIC_MODE: number;
  47826. /** Projection coordinates mode */
  47827. static readonly PROJECTION_MODE: number;
  47828. /** Inverse Cubic coordinates mode */
  47829. static readonly SKYBOX_MODE: number;
  47830. /** Inverse Cubic coordinates mode */
  47831. static readonly INVCUBIC_MODE: number;
  47832. /** Equirectangular coordinates mode */
  47833. static readonly EQUIRECTANGULAR_MODE: number;
  47834. /** Equirectangular Fixed coordinates mode */
  47835. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  47836. /** Equirectangular Fixed Mirrored coordinates mode */
  47837. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  47838. /** Texture is not repeating outside of 0..1 UVs */
  47839. static readonly CLAMP_ADDRESSMODE: number;
  47840. /** Texture is repeating outside of 0..1 UVs */
  47841. static readonly WRAP_ADDRESSMODE: number;
  47842. /** Texture is repeating and mirrored */
  47843. static readonly MIRROR_ADDRESSMODE: number;
  47844. /**
  47845. * 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
  47846. */
  47847. static UseSerializedUrlIfAny: boolean;
  47848. /**
  47849. * Define the url of the texture.
  47850. */
  47851. url: Nullable<string>;
  47852. /**
  47853. * Define an offset on the texture to offset the u coordinates of the UVs
  47854. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47855. */
  47856. uOffset: number;
  47857. /**
  47858. * Define an offset on the texture to offset the v coordinates of the UVs
  47859. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47860. */
  47861. vOffset: number;
  47862. /**
  47863. * Define an offset on the texture to scale the u coordinates of the UVs
  47864. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47865. */
  47866. uScale: number;
  47867. /**
  47868. * Define an offset on the texture to scale the v coordinates of the UVs
  47869. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47870. */
  47871. vScale: number;
  47872. /**
  47873. * Define an offset on the texture to rotate around the u coordinates of the UVs
  47874. * @see http://doc.babylonjs.com/how_to/more_materials
  47875. */
  47876. uAng: number;
  47877. /**
  47878. * Define an offset on the texture to rotate around the v coordinates of the UVs
  47879. * @see http://doc.babylonjs.com/how_to/more_materials
  47880. */
  47881. vAng: number;
  47882. /**
  47883. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  47884. * @see http://doc.babylonjs.com/how_to/more_materials
  47885. */
  47886. wAng: number;
  47887. /**
  47888. * Defines the center of rotation (U)
  47889. */
  47890. uRotationCenter: number;
  47891. /**
  47892. * Defines the center of rotation (V)
  47893. */
  47894. vRotationCenter: number;
  47895. /**
  47896. * Defines the center of rotation (W)
  47897. */
  47898. wRotationCenter: number;
  47899. /**
  47900. * Are mip maps generated for this texture or not.
  47901. */
  47902. readonly noMipmap: boolean;
  47903. private _noMipmap;
  47904. /** @hidden */
  47905. _invertY: boolean;
  47906. private _rowGenerationMatrix;
  47907. private _cachedTextureMatrix;
  47908. private _projectionModeMatrix;
  47909. private _t0;
  47910. private _t1;
  47911. private _t2;
  47912. private _cachedUOffset;
  47913. private _cachedVOffset;
  47914. private _cachedUScale;
  47915. private _cachedVScale;
  47916. private _cachedUAng;
  47917. private _cachedVAng;
  47918. private _cachedWAng;
  47919. private _cachedProjectionMatrixId;
  47920. private _cachedCoordinatesMode;
  47921. /** @hidden */
  47922. _samplingMode: number;
  47923. /** @hidden */
  47924. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47925. private _deleteBuffer;
  47926. protected _format: Nullable<number>;
  47927. private _delayedOnLoad;
  47928. private _delayedOnError;
  47929. /**
  47930. * Observable triggered once the texture has been loaded.
  47931. */
  47932. onLoadObservable: Observable<Texture>;
  47933. protected _isBlocking: boolean;
  47934. /**
  47935. * Is the texture preventing material to render while loading.
  47936. * If false, a default texture will be used instead of the loading one during the preparation step.
  47937. */
  47938. isBlocking: boolean;
  47939. /**
  47940. * Get the current sampling mode associated with the texture.
  47941. */
  47942. readonly samplingMode: number;
  47943. /**
  47944. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  47945. */
  47946. readonly invertY: boolean;
  47947. /**
  47948. * Instantiates a new texture.
  47949. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47950. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47951. * @param url define the url of the picture to load as a texture
  47952. * @param scene define the scene the texture will belong to
  47953. * @param noMipmap define if the texture will require mip maps or not
  47954. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47955. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47956. * @param onLoad define a callback triggered when the texture has been loaded
  47957. * @param onError define a callback triggered when an error occurred during the loading session
  47958. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47959. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47960. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47961. */
  47962. 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);
  47963. /**
  47964. * Update the url (and optional buffer) of this texture if url was null during construction.
  47965. * @param url the url of the texture
  47966. * @param buffer the buffer of the texture (defaults to null)
  47967. */
  47968. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  47969. /**
  47970. * Finish the loading sequence of a texture flagged as delayed load.
  47971. * @hidden
  47972. */
  47973. delayLoad(): void;
  47974. /**
  47975. * Update the sampling mode of the texture.
  47976. * Default is Trilinear mode.
  47977. *
  47978. * | Value | Type | Description |
  47979. * | ----- | ------------------ | ----------- |
  47980. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  47981. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  47982. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  47983. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  47984. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  47985. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  47986. * | 7 | NEAREST_LINEAR | |
  47987. * | 8 | NEAREST_NEAREST | |
  47988. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  47989. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  47990. * | 11 | LINEAR_LINEAR | |
  47991. * | 12 | LINEAR_NEAREST | |
  47992. *
  47993. * > _mag_: magnification filter (close to the viewer)
  47994. * > _min_: minification filter (far from the viewer)
  47995. * > _mip_: filter used between mip map levels
  47996. *@param samplingMode Define the new sampling mode of the texture
  47997. */
  47998. updateSamplingMode(samplingMode: number): void;
  47999. private _prepareRowForTextureGeneration;
  48000. /**
  48001. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48002. * @returns the transform matrix of the texture.
  48003. */
  48004. getTextureMatrix(): Matrix;
  48005. /**
  48006. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48007. * @returns The reflection texture transform
  48008. */
  48009. getReflectionTextureMatrix(): Matrix;
  48010. /**
  48011. * Clones the texture.
  48012. * @returns the cloned texture
  48013. */
  48014. clone(): Texture;
  48015. /**
  48016. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48017. * @returns The JSON representation of the texture
  48018. */
  48019. serialize(): any;
  48020. /**
  48021. * Get the current class name of the texture usefull for serialization or dynamic coding.
  48022. * @returns "Texture"
  48023. */
  48024. getClassName(): string;
  48025. /**
  48026. * Dispose the texture and release its associated resources.
  48027. */
  48028. dispose(): void;
  48029. /**
  48030. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48031. * @param parsedTexture Define the JSON representation of the texture
  48032. * @param scene Define the scene the parsed texture should be instantiated in
  48033. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48034. * @returns The parsed texture if successful
  48035. */
  48036. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48037. /**
  48038. * Creates a texture from its base 64 representation.
  48039. * @param data Define the base64 payload without the data: prefix
  48040. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48041. * @param scene Define the scene the texture should belong to
  48042. * @param noMipmap Forces the texture to not create mip map information if true
  48043. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48044. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48045. * @param onLoad define a callback triggered when the texture has been loaded
  48046. * @param onError define a callback triggered when an error occurred during the loading session
  48047. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48048. * @returns the created texture
  48049. */
  48050. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48051. /**
  48052. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48053. * @param data Define the base64 payload without the data: prefix
  48054. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48055. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48056. * @param scene Define the scene the texture should belong to
  48057. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48058. * @param noMipmap Forces the texture to not create mip map information if true
  48059. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48060. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48061. * @param onLoad define a callback triggered when the texture has been loaded
  48062. * @param onError define a callback triggered when an error occurred during the loading session
  48063. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48064. * @returns the created texture
  48065. */
  48066. 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;
  48067. }
  48068. }
  48069. declare module BABYLON {
  48070. /**
  48071. * Settings for finer control over video usage
  48072. */
  48073. interface VideoTextureSettings {
  48074. /**
  48075. * Applies `autoplay` to video, if specified
  48076. */
  48077. autoPlay?: boolean;
  48078. /**
  48079. * Applies `loop` to video, if specified
  48080. */
  48081. loop?: boolean;
  48082. /**
  48083. * Automatically updates internal texture from video at every frame in the render loop
  48084. */
  48085. autoUpdateTexture: boolean;
  48086. /**
  48087. * Image src displayed during the video loading or until the user interacts with the video.
  48088. */
  48089. poster?: string;
  48090. }
  48091. /**
  48092. * If you want to display a video in your scene, this is the special texture for that.
  48093. * This special texture works similar to other textures, with the exception of a few parameters.
  48094. * @see https://doc.babylonjs.com/how_to/video_texture
  48095. */
  48096. class VideoTexture extends Texture {
  48097. /**
  48098. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48099. */
  48100. readonly autoUpdateTexture: boolean;
  48101. /**
  48102. * The video instance used by the texture internally
  48103. */
  48104. readonly video: HTMLVideoElement;
  48105. private _onUserActionRequestedObservable;
  48106. /**
  48107. * Event triggerd when a dom action is required by the user to play the video.
  48108. * This happens due to recent changes in browser policies preventing video to auto start.
  48109. */
  48110. readonly onUserActionRequestedObservable: Observable<Texture>;
  48111. private _generateMipMaps;
  48112. private _engine;
  48113. private _stillImageCaptured;
  48114. private _poster;
  48115. /**
  48116. * Creates a video texture.
  48117. * If you want to display a video in your scene, this is the special texture for that.
  48118. * This special texture works similar to other textures, with the exception of a few parameters.
  48119. * @see https://doc.babylonjs.com/how_to/video_texture
  48120. * @param name optional name, will detect from video source, if not defined
  48121. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48122. * @param scene is obviously the current scene.
  48123. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48124. * @param invertY is false by default but can be used to invert video on Y axis
  48125. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48126. * @param settings allows finer control over video usage
  48127. */
  48128. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48129. private _getName;
  48130. private _getVideo;
  48131. private _createInternalTexture;
  48132. private reset;
  48133. /**
  48134. * @hidden Internal method to initiate `update`.
  48135. */
  48136. _rebuild(): void;
  48137. /**
  48138. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48139. */
  48140. update(): void;
  48141. /**
  48142. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48143. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48144. */
  48145. updateTexture(isVisible: boolean): void;
  48146. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48147. /**
  48148. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48149. * @param url New url.
  48150. */
  48151. updateURL(url: string): void;
  48152. /**
  48153. * Dispose the texture and release its associated resources.
  48154. */
  48155. dispose(): void;
  48156. /**
  48157. * Creates a video texture straight from your WebCam video feed.
  48158. * @param scene Define the scene the texture should be created in
  48159. * @param onReady Define a callback to triggered once the texture will be ready
  48160. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48161. */
  48162. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48163. minWidth: number;
  48164. maxWidth: number;
  48165. minHeight: number;
  48166. maxHeight: number;
  48167. deviceId: string;
  48168. }): void;
  48169. }
  48170. }
  48171. declare var DracoDecoderModule: any;
  48172. declare var WebAssembly: any;
  48173. declare module BABYLON {
  48174. /**
  48175. * Configuration for Draco compression
  48176. */
  48177. interface IDracoCompressionConfiguration {
  48178. /**
  48179. * Configuration for the decoder.
  48180. */
  48181. decoder?: {
  48182. /**
  48183. * The url to the WebAssembly module.
  48184. */
  48185. wasmUrl?: string;
  48186. /**
  48187. * The url to the WebAssembly binary.
  48188. */
  48189. wasmBinaryUrl?: string;
  48190. /**
  48191. * The url to the fallback JavaScript module.
  48192. */
  48193. fallbackUrl?: string;
  48194. };
  48195. }
  48196. /**
  48197. * Draco compression (https://google.github.io/draco/)
  48198. *
  48199. * This class wraps the Draco module.
  48200. *
  48201. * **Encoder**
  48202. *
  48203. * The encoder is not currently implemented.
  48204. *
  48205. * **Decoder**
  48206. *
  48207. * 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.
  48208. *
  48209. * To update the configuration, use the following code:
  48210. * ```javascript
  48211. * BABYLON.DracoCompression.Configuration = {
  48212. * decoder: {
  48213. * wasmUrl: "<url to the WebAssembly library>",
  48214. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48215. * fallbackUrl: "<url to the fallback JavaScript library>",
  48216. * }
  48217. * };
  48218. * ```
  48219. *
  48220. * 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.
  48221. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48222. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48223. *
  48224. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48225. * ```javascript
  48226. * var dracoCompression = new BABYLON.DracoCompression();
  48227. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48228. * [BABYLON.VertexBuffer.PositionKind]: 0
  48229. * });
  48230. * ```
  48231. *
  48232. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48233. */
  48234. class DracoCompression implements IDisposable {
  48235. private static _DecoderModulePromise;
  48236. /**
  48237. * The configuration. Defaults to the following urls:
  48238. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48239. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48240. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48241. */
  48242. static Configuration: IDracoCompressionConfiguration;
  48243. /**
  48244. * Returns true if the decoder is available.
  48245. */
  48246. static readonly DecoderAvailable: boolean;
  48247. /**
  48248. * Constructor
  48249. */
  48250. constructor();
  48251. /**
  48252. * Stop all async operations and release resources.
  48253. */
  48254. dispose(): void;
  48255. /**
  48256. * Decode Draco compressed mesh data to vertex data.
  48257. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48258. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48259. * @returns A promise that resolves with the decoded vertex data
  48260. */
  48261. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48262. [kind: string]: number;
  48263. }): Promise<VertexData>;
  48264. private static _GetDecoderModule;
  48265. private static _LoadScriptAsync;
  48266. private static _LoadFileAsync;
  48267. }
  48268. }
  48269. declare module BABYLON {
  48270. /**
  48271. * Particle emitter emitting particles from the inside of a box.
  48272. * It emits the particles randomly between 2 given directions.
  48273. */
  48274. class BoxParticleEmitter implements IParticleEmitterType {
  48275. /**
  48276. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48277. */
  48278. direction1: Vector3;
  48279. /**
  48280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48281. */
  48282. direction2: Vector3;
  48283. /**
  48284. * 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.
  48285. */
  48286. minEmitBox: Vector3;
  48287. /**
  48288. * 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.
  48289. */
  48290. maxEmitBox: Vector3;
  48291. /**
  48292. * Creates a new instance BoxParticleEmitter
  48293. */
  48294. constructor();
  48295. /**
  48296. * Called by the particle System when the direction is computed for the created particle.
  48297. * @param worldMatrix is the world matrix of the particle system
  48298. * @param directionToUpdate is the direction vector to update with the result
  48299. * @param particle is the particle we are computed the direction for
  48300. */
  48301. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48302. /**
  48303. * Called by the particle System when the position is computed for the created particle.
  48304. * @param worldMatrix is the world matrix of the particle system
  48305. * @param positionToUpdate is the position vector to update with the result
  48306. * @param particle is the particle we are computed the position for
  48307. */
  48308. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48309. /**
  48310. * Clones the current emitter and returns a copy of it
  48311. * @returns the new emitter
  48312. */
  48313. clone(): BoxParticleEmitter;
  48314. /**
  48315. * Called by the GPUParticleSystem to setup the update shader
  48316. * @param effect defines the update shader
  48317. */
  48318. applyToShader(effect: Effect): void;
  48319. /**
  48320. * Returns a string to use to update the GPU particles update shader
  48321. * @returns a string containng the defines string
  48322. */
  48323. getEffectDefines(): string;
  48324. /**
  48325. * Returns the string "BoxParticleEmitter"
  48326. * @returns a string containing the class name
  48327. */
  48328. getClassName(): string;
  48329. /**
  48330. * Serializes the particle system to a JSON object.
  48331. * @returns the JSON object
  48332. */
  48333. serialize(): any;
  48334. /**
  48335. * Parse properties from a JSON object
  48336. * @param serializationObject defines the JSON object
  48337. */
  48338. parse(serializationObject: any): void;
  48339. }
  48340. }
  48341. declare module BABYLON {
  48342. /**
  48343. * Particle emitter emitting particles from the inside of a cone.
  48344. * It emits the particles alongside the cone volume from the base to the particle.
  48345. * The emission direction might be randomized.
  48346. */
  48347. class ConeParticleEmitter implements IParticleEmitterType {
  48348. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48349. directionRandomizer: number;
  48350. private _radius;
  48351. private _angle;
  48352. private _height;
  48353. /**
  48354. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48355. */
  48356. radiusRange: number;
  48357. /**
  48358. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48359. */
  48360. heightRange: number;
  48361. /**
  48362. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48363. */
  48364. emitFromSpawnPointOnly: boolean;
  48365. /**
  48366. * Gets or sets the radius of the emission cone
  48367. */
  48368. radius: number;
  48369. /**
  48370. * Gets or sets the angle of the emission cone
  48371. */
  48372. angle: number;
  48373. private _buildHeight;
  48374. /**
  48375. * Creates a new instance ConeParticleEmitter
  48376. * @param radius the radius of the emission cone (1 by default)
  48377. * @param angles the cone base angle (PI by default)
  48378. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48379. */
  48380. constructor(radius?: number, angle?: number,
  48381. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48382. directionRandomizer?: number);
  48383. /**
  48384. * Called by the particle System when the direction is computed for the created particle.
  48385. * @param worldMatrix is the world matrix of the particle system
  48386. * @param directionToUpdate is the direction vector to update with the result
  48387. * @param particle is the particle we are computed the direction for
  48388. */
  48389. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48390. /**
  48391. * Called by the particle System when the position is computed for the created particle.
  48392. * @param worldMatrix is the world matrix of the particle system
  48393. * @param positionToUpdate is the position vector to update with the result
  48394. * @param particle is the particle we are computed the position for
  48395. */
  48396. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48397. /**
  48398. * Clones the current emitter and returns a copy of it
  48399. * @returns the new emitter
  48400. */
  48401. clone(): ConeParticleEmitter;
  48402. /**
  48403. * Called by the GPUParticleSystem to setup the update shader
  48404. * @param effect defines the update shader
  48405. */
  48406. applyToShader(effect: Effect): void;
  48407. /**
  48408. * Returns a string to use to update the GPU particles update shader
  48409. * @returns a string containng the defines string
  48410. */
  48411. getEffectDefines(): string;
  48412. /**
  48413. * Returns the string "ConeParticleEmitter"
  48414. * @returns a string containing the class name
  48415. */
  48416. getClassName(): string;
  48417. /**
  48418. * Serializes the particle system to a JSON object.
  48419. * @returns the JSON object
  48420. */
  48421. serialize(): any;
  48422. /**
  48423. * Parse properties from a JSON object
  48424. * @param serializationObject defines the JSON object
  48425. */
  48426. parse(serializationObject: any): void;
  48427. }
  48428. }
  48429. declare module BABYLON {
  48430. /**
  48431. * Particle emitter emitting particles from the inside of a cylinder.
  48432. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48433. */
  48434. class CylinderParticleEmitter implements IParticleEmitterType {
  48435. /**
  48436. * The radius of the emission cylinder.
  48437. */
  48438. radius: number;
  48439. /**
  48440. * The height of the emission cylinder.
  48441. */
  48442. height: number;
  48443. /**
  48444. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48445. */
  48446. radiusRange: number;
  48447. /**
  48448. * How much to randomize the particle direction [0-1].
  48449. */
  48450. directionRandomizer: number;
  48451. /**
  48452. * Creates a new instance CylinderParticleEmitter
  48453. * @param radius the radius of the emission cylinder (1 by default)
  48454. * @param height the height of the emission cylinder (1 by default)
  48455. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48456. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48457. */
  48458. constructor(
  48459. /**
  48460. * The radius of the emission cylinder.
  48461. */
  48462. radius?: number,
  48463. /**
  48464. * The height of the emission cylinder.
  48465. */
  48466. height?: number,
  48467. /**
  48468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48469. */
  48470. radiusRange?: number,
  48471. /**
  48472. * How much to randomize the particle direction [0-1].
  48473. */
  48474. directionRandomizer?: number);
  48475. /**
  48476. * Called by the particle System when the direction is computed for the created particle.
  48477. * @param worldMatrix is the world matrix of the particle system
  48478. * @param directionToUpdate is the direction vector to update with the result
  48479. * @param particle is the particle we are computed the direction for
  48480. */
  48481. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48482. /**
  48483. * Called by the particle System when the position is computed for the created particle.
  48484. * @param worldMatrix is the world matrix of the particle system
  48485. * @param positionToUpdate is the position vector to update with the result
  48486. * @param particle is the particle we are computed the position for
  48487. */
  48488. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48489. /**
  48490. * Clones the current emitter and returns a copy of it
  48491. * @returns the new emitter
  48492. */
  48493. clone(): CylinderParticleEmitter;
  48494. /**
  48495. * Called by the GPUParticleSystem to setup the update shader
  48496. * @param effect defines the update shader
  48497. */
  48498. applyToShader(effect: Effect): void;
  48499. /**
  48500. * Returns a string to use to update the GPU particles update shader
  48501. * @returns a string containng the defines string
  48502. */
  48503. getEffectDefines(): string;
  48504. /**
  48505. * Returns the string "CylinderParticleEmitter"
  48506. * @returns a string containing the class name
  48507. */
  48508. getClassName(): string;
  48509. /**
  48510. * Serializes the particle system to a JSON object.
  48511. * @returns the JSON object
  48512. */
  48513. serialize(): any;
  48514. /**
  48515. * Parse properties from a JSON object
  48516. * @param serializationObject defines the JSON object
  48517. */
  48518. parse(serializationObject: any): void;
  48519. }
  48520. /**
  48521. * Particle emitter emitting particles from the inside of a cylinder.
  48522. * It emits the particles randomly between two vectors.
  48523. */
  48524. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48525. /**
  48526. * The min limit of the emission direction.
  48527. */
  48528. direction1: Vector3;
  48529. /**
  48530. * The max limit of the emission direction.
  48531. */
  48532. direction2: Vector3;
  48533. /**
  48534. * Creates a new instance CylinderDirectedParticleEmitter
  48535. * @param radius the radius of the emission cylinder (1 by default)
  48536. * @param height the height of the emission cylinder (1 by default)
  48537. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48538. * @param direction1 the min limit of the emission direction (up vector by default)
  48539. * @param direction2 the max limit of the emission direction (up vector by default)
  48540. */
  48541. constructor(radius?: number, height?: number, radiusRange?: number,
  48542. /**
  48543. * The min limit of the emission direction.
  48544. */
  48545. direction1?: Vector3,
  48546. /**
  48547. * The max limit of the emission direction.
  48548. */
  48549. direction2?: Vector3);
  48550. /**
  48551. * Called by the particle System when the direction is computed for the created particle.
  48552. * @param worldMatrix is the world matrix of the particle system
  48553. * @param directionToUpdate is the direction vector to update with the result
  48554. * @param particle is the particle we are computed the direction for
  48555. */
  48556. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48557. /**
  48558. * Clones the current emitter and returns a copy of it
  48559. * @returns the new emitter
  48560. */
  48561. clone(): CylinderDirectedParticleEmitter;
  48562. /**
  48563. * Called by the GPUParticleSystem to setup the update shader
  48564. * @param effect defines the update shader
  48565. */
  48566. applyToShader(effect: Effect): void;
  48567. /**
  48568. * Returns a string to use to update the GPU particles update shader
  48569. * @returns a string containng the defines string
  48570. */
  48571. getEffectDefines(): string;
  48572. /**
  48573. * Returns the string "CylinderDirectedParticleEmitter"
  48574. * @returns a string containing the class name
  48575. */
  48576. getClassName(): string;
  48577. /**
  48578. * Serializes the particle system to a JSON object.
  48579. * @returns the JSON object
  48580. */
  48581. serialize(): any;
  48582. /**
  48583. * Parse properties from a JSON object
  48584. * @param serializationObject defines the JSON object
  48585. */
  48586. parse(serializationObject: any): void;
  48587. }
  48588. }
  48589. declare module BABYLON {
  48590. /**
  48591. * Particle emitter emitting particles from the inside of a hemisphere.
  48592. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48593. */
  48594. class HemisphericParticleEmitter implements IParticleEmitterType {
  48595. /**
  48596. * The radius of the emission hemisphere.
  48597. */
  48598. radius: number;
  48599. /**
  48600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48601. */
  48602. radiusRange: number;
  48603. /**
  48604. * How much to randomize the particle direction [0-1].
  48605. */
  48606. directionRandomizer: number;
  48607. /**
  48608. * Creates a new instance HemisphericParticleEmitter
  48609. * @param radius the radius of the emission hemisphere (1 by default)
  48610. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48611. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48612. */
  48613. constructor(
  48614. /**
  48615. * The radius of the emission hemisphere.
  48616. */
  48617. radius?: number,
  48618. /**
  48619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48620. */
  48621. radiusRange?: number,
  48622. /**
  48623. * How much to randomize the particle direction [0-1].
  48624. */
  48625. directionRandomizer?: number);
  48626. /**
  48627. * Called by the particle System when the direction is computed for the created particle.
  48628. * @param worldMatrix is the world matrix of the particle system
  48629. * @param directionToUpdate is the direction vector to update with the result
  48630. * @param particle is the particle we are computed the direction for
  48631. */
  48632. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48633. /**
  48634. * Called by the particle System when the position is computed for the created particle.
  48635. * @param worldMatrix is the world matrix of the particle system
  48636. * @param positionToUpdate is the position vector to update with the result
  48637. * @param particle is the particle we are computed the position for
  48638. */
  48639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48640. /**
  48641. * Clones the current emitter and returns a copy of it
  48642. * @returns the new emitter
  48643. */
  48644. clone(): HemisphericParticleEmitter;
  48645. /**
  48646. * Called by the GPUParticleSystem to setup the update shader
  48647. * @param effect defines the update shader
  48648. */
  48649. applyToShader(effect: Effect): void;
  48650. /**
  48651. * Returns a string to use to update the GPU particles update shader
  48652. * @returns a string containng the defines string
  48653. */
  48654. getEffectDefines(): string;
  48655. /**
  48656. * Returns the string "HemisphericParticleEmitter"
  48657. * @returns a string containing the class name
  48658. */
  48659. getClassName(): string;
  48660. /**
  48661. * Serializes the particle system to a JSON object.
  48662. * @returns the JSON object
  48663. */
  48664. serialize(): any;
  48665. /**
  48666. * Parse properties from a JSON object
  48667. * @param serializationObject defines the JSON object
  48668. */
  48669. parse(serializationObject: any): void;
  48670. }
  48671. }
  48672. declare module BABYLON {
  48673. /**
  48674. * Particle emitter represents a volume emitting particles.
  48675. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48676. */
  48677. interface IParticleEmitterType {
  48678. /**
  48679. * Called by the particle System when the direction is computed for the created particle.
  48680. * @param worldMatrix is the world matrix of the particle system
  48681. * @param directionToUpdate is the direction vector to update with the result
  48682. * @param particle is the particle we are computed the direction for
  48683. */
  48684. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48685. /**
  48686. * Called by the particle System when the position is computed for the created particle.
  48687. * @param worldMatrix is the world matrix of the particle system
  48688. * @param positionToUpdate is the position vector to update with the result
  48689. * @param particle is the particle we are computed the position for
  48690. */
  48691. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48692. /**
  48693. * Clones the current emitter and returns a copy of it
  48694. * @returns the new emitter
  48695. */
  48696. clone(): IParticleEmitterType;
  48697. /**
  48698. * Called by the GPUParticleSystem to setup the update shader
  48699. * @param effect defines the update shader
  48700. */
  48701. applyToShader(effect: Effect): void;
  48702. /**
  48703. * Returns a string to use to update the GPU particles update shader
  48704. * @returns the effect defines string
  48705. */
  48706. getEffectDefines(): string;
  48707. /**
  48708. * Returns a string representing the class name
  48709. * @returns a string containing the class name
  48710. */
  48711. getClassName(): string;
  48712. /**
  48713. * Serializes the particle system to a JSON object.
  48714. * @returns the JSON object
  48715. */
  48716. serialize(): any;
  48717. /**
  48718. * Parse properties from a JSON object
  48719. * @param serializationObject defines the JSON object
  48720. */
  48721. parse(serializationObject: any): void;
  48722. }
  48723. }
  48724. declare module BABYLON {
  48725. /**
  48726. * Particle emitter emitting particles from a point.
  48727. * It emits the particles randomly between 2 given directions.
  48728. */
  48729. class PointParticleEmitter implements IParticleEmitterType {
  48730. /**
  48731. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48732. */
  48733. direction1: Vector3;
  48734. /**
  48735. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48736. */
  48737. direction2: Vector3;
  48738. /**
  48739. * Creates a new instance PointParticleEmitter
  48740. */
  48741. constructor();
  48742. /**
  48743. * Called by the particle System when the direction is computed for the created particle.
  48744. * @param worldMatrix is the world matrix of the particle system
  48745. * @param directionToUpdate is the direction vector to update with the result
  48746. * @param particle is the particle we are computed the direction for
  48747. */
  48748. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48749. /**
  48750. * Called by the particle System when the position is computed for the created particle.
  48751. * @param worldMatrix is the world matrix of the particle system
  48752. * @param positionToUpdate is the position vector to update with the result
  48753. * @param particle is the particle we are computed the position for
  48754. */
  48755. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48756. /**
  48757. * Clones the current emitter and returns a copy of it
  48758. * @returns the new emitter
  48759. */
  48760. clone(): PointParticleEmitter;
  48761. /**
  48762. * Called by the GPUParticleSystem to setup the update shader
  48763. * @param effect defines the update shader
  48764. */
  48765. applyToShader(effect: Effect): void;
  48766. /**
  48767. * Returns a string to use to update the GPU particles update shader
  48768. * @returns a string containng the defines string
  48769. */
  48770. getEffectDefines(): string;
  48771. /**
  48772. * Returns the string "PointParticleEmitter"
  48773. * @returns a string containing the class name
  48774. */
  48775. getClassName(): string;
  48776. /**
  48777. * Serializes the particle system to a JSON object.
  48778. * @returns the JSON object
  48779. */
  48780. serialize(): any;
  48781. /**
  48782. * Parse properties from a JSON object
  48783. * @param serializationObject defines the JSON object
  48784. */
  48785. parse(serializationObject: any): void;
  48786. }
  48787. }
  48788. declare module BABYLON {
  48789. /**
  48790. * Particle emitter emitting particles from the inside of a sphere.
  48791. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  48792. */
  48793. class SphereParticleEmitter implements IParticleEmitterType {
  48794. /**
  48795. * The radius of the emission sphere.
  48796. */
  48797. radius: number;
  48798. /**
  48799. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48800. */
  48801. radiusRange: number;
  48802. /**
  48803. * How much to randomize the particle direction [0-1].
  48804. */
  48805. directionRandomizer: number;
  48806. /**
  48807. * Creates a new instance SphereParticleEmitter
  48808. * @param radius the radius of the emission sphere (1 by default)
  48809. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48810. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48811. */
  48812. constructor(
  48813. /**
  48814. * The radius of the emission sphere.
  48815. */
  48816. radius?: number,
  48817. /**
  48818. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48819. */
  48820. radiusRange?: number,
  48821. /**
  48822. * How much to randomize the particle direction [0-1].
  48823. */
  48824. directionRandomizer?: number);
  48825. /**
  48826. * Called by the particle System when the direction is computed for the created particle.
  48827. * @param worldMatrix is the world matrix of the particle system
  48828. * @param directionToUpdate is the direction vector to update with the result
  48829. * @param particle is the particle we are computed the direction for
  48830. */
  48831. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48832. /**
  48833. * Called by the particle System when the position is computed for the created particle.
  48834. * @param worldMatrix is the world matrix of the particle system
  48835. * @param positionToUpdate is the position vector to update with the result
  48836. * @param particle is the particle we are computed the position for
  48837. */
  48838. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48839. /**
  48840. * Clones the current emitter and returns a copy of it
  48841. * @returns the new emitter
  48842. */
  48843. clone(): SphereParticleEmitter;
  48844. /**
  48845. * Called by the GPUParticleSystem to setup the update shader
  48846. * @param effect defines the update shader
  48847. */
  48848. applyToShader(effect: Effect): void;
  48849. /**
  48850. * Returns a string to use to update the GPU particles update shader
  48851. * @returns a string containng the defines string
  48852. */
  48853. getEffectDefines(): string;
  48854. /**
  48855. * Returns the string "SphereParticleEmitter"
  48856. * @returns a string containing the class name
  48857. */
  48858. getClassName(): string;
  48859. /**
  48860. * Serializes the particle system to a JSON object.
  48861. * @returns the JSON object
  48862. */
  48863. serialize(): any;
  48864. /**
  48865. * Parse properties from a JSON object
  48866. * @param serializationObject defines the JSON object
  48867. */
  48868. parse(serializationObject: any): void;
  48869. }
  48870. /**
  48871. * Particle emitter emitting particles from the inside of a sphere.
  48872. * It emits the particles randomly between two vectors.
  48873. */
  48874. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  48875. /**
  48876. * The min limit of the emission direction.
  48877. */
  48878. direction1: Vector3;
  48879. /**
  48880. * The max limit of the emission direction.
  48881. */
  48882. direction2: Vector3;
  48883. /**
  48884. * Creates a new instance SphereDirectedParticleEmitter
  48885. * @param radius the radius of the emission sphere (1 by default)
  48886. * @param direction1 the min limit of the emission direction (up vector by default)
  48887. * @param direction2 the max limit of the emission direction (up vector by default)
  48888. */
  48889. constructor(radius?: number,
  48890. /**
  48891. * The min limit of the emission direction.
  48892. */
  48893. direction1?: Vector3,
  48894. /**
  48895. * The max limit of the emission direction.
  48896. */
  48897. direction2?: Vector3);
  48898. /**
  48899. * Called by the particle System when the direction is computed for the created particle.
  48900. * @param worldMatrix is the world matrix of the particle system
  48901. * @param directionToUpdate is the direction vector to update with the result
  48902. * @param particle is the particle we are computed the direction for
  48903. */
  48904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48905. /**
  48906. * Clones the current emitter and returns a copy of it
  48907. * @returns the new emitter
  48908. */
  48909. clone(): SphereDirectedParticleEmitter;
  48910. /**
  48911. * Called by the GPUParticleSystem to setup the update shader
  48912. * @param effect defines the update shader
  48913. */
  48914. applyToShader(effect: Effect): void;
  48915. /**
  48916. * Returns a string to use to update the GPU particles update shader
  48917. * @returns a string containng the defines string
  48918. */
  48919. getEffectDefines(): string;
  48920. /**
  48921. * Returns the string "SphereDirectedParticleEmitter"
  48922. * @returns a string containing the class name
  48923. */
  48924. getClassName(): string;
  48925. /**
  48926. * Serializes the particle system to a JSON object.
  48927. * @returns the JSON object
  48928. */
  48929. serialize(): any;
  48930. /**
  48931. * Parse properties from a JSON object
  48932. * @param serializationObject defines the JSON object
  48933. */
  48934. parse(serializationObject: any): void;
  48935. }
  48936. }
  48937. declare module BABYLON {
  48938. /** @hidden */
  48939. class CannonJSPlugin implements IPhysicsEnginePlugin {
  48940. private _useDeltaForWorldStep;
  48941. world: any;
  48942. name: string;
  48943. private _physicsMaterials;
  48944. private _fixedTimeStep;
  48945. BJSCANNON: any;
  48946. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  48947. setGravity(gravity: Vector3): void;
  48948. setTimeStep(timeStep: number): void;
  48949. getTimeStep(): number;
  48950. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48951. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48952. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48953. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48954. private _processChildMeshes;
  48955. removePhysicsBody(impostor: PhysicsImpostor): void;
  48956. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48957. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48958. private _addMaterial;
  48959. private _checkWithEpsilon;
  48960. private _createShape;
  48961. private _createHeightmap;
  48962. private _minus90X;
  48963. private _plus90X;
  48964. private _tmpPosition;
  48965. private _tmpDeltaPosition;
  48966. private _tmpUnityRotation;
  48967. private _updatePhysicsBodyTransformation;
  48968. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48969. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48970. isSupported(): boolean;
  48971. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48972. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48973. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48974. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48975. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48976. getBodyMass(impostor: PhysicsImpostor): number;
  48977. getBodyFriction(impostor: PhysicsImpostor): number;
  48978. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48979. getBodyRestitution(impostor: PhysicsImpostor): number;
  48980. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48981. sleepBody(impostor: PhysicsImpostor): void;
  48982. wakeUpBody(impostor: PhysicsImpostor): void;
  48983. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48984. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48985. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48986. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48987. getRadius(impostor: PhysicsImpostor): number;
  48988. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48989. dispose(): void;
  48990. private _extendNamespace;
  48991. }
  48992. }
  48993. declare module BABYLON {
  48994. /** @hidden */
  48995. class OimoJSPlugin implements IPhysicsEnginePlugin {
  48996. world: any;
  48997. name: string;
  48998. BJSOIMO: any;
  48999. constructor(iterations?: number);
  49000. setGravity(gravity: Vector3): void;
  49001. setTimeStep(timeStep: number): void;
  49002. getTimeStep(): number;
  49003. private _tmpImpostorsArray;
  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 _tmpPositionVector;
  49009. removePhysicsBody(impostor: PhysicsImpostor): void;
  49010. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49011. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49012. isSupported(): boolean;
  49013. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49014. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49015. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49016. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49017. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49018. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49019. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49020. getBodyMass(impostor: PhysicsImpostor): number;
  49021. getBodyFriction(impostor: PhysicsImpostor): number;
  49022. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49023. getBodyRestitution(impostor: PhysicsImpostor): number;
  49024. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49025. sleepBody(impostor: PhysicsImpostor): void;
  49026. wakeUpBody(impostor: PhysicsImpostor): void;
  49027. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49028. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49029. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49030. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49031. getRadius(impostor: PhysicsImpostor): number;
  49032. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49033. dispose(): void;
  49034. }
  49035. }
  49036. declare module BABYLON {
  49037. /**
  49038. * This represents a set of one or more post processes in Babylon.
  49039. * A post process can be used to apply a shader to a texture after it is rendered.
  49040. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49041. */
  49042. class PostProcessRenderEffect {
  49043. private _postProcesses;
  49044. private _getPostProcesses;
  49045. private _singleInstance;
  49046. private _cameras;
  49047. private _indicesForCamera;
  49048. /**
  49049. * Name of the effect
  49050. * @hidden
  49051. */
  49052. _name: string;
  49053. /**
  49054. * Instantiates a post process render effect.
  49055. * A post process can be used to apply a shader to a texture after it is rendered.
  49056. * @param engine The engine the effect is tied to
  49057. * @param name The name of the effect
  49058. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49059. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49060. */
  49061. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49062. /**
  49063. * Checks if all the post processes in the effect are supported.
  49064. */
  49065. readonly isSupported: boolean;
  49066. /**
  49067. * Updates the current state of the effect
  49068. * @hidden
  49069. */
  49070. _update(): void;
  49071. /**
  49072. * Attaches the effect on cameras
  49073. * @param cameras The camera to attach to.
  49074. * @hidden
  49075. */
  49076. _attachCameras(cameras: Camera): void;
  49077. /**
  49078. * Attaches the effect on cameras
  49079. * @param cameras The camera to attach to.
  49080. * @hidden
  49081. */
  49082. _attachCameras(cameras: Camera[]): void;
  49083. /**
  49084. * Detatches the effect on cameras
  49085. * @param cameras The camera to detatch from.
  49086. * @hidden
  49087. */
  49088. _detachCameras(cameras: Camera): void;
  49089. /**
  49090. * Detatches the effect on cameras
  49091. * @param cameras The camera to detatch from.
  49092. * @hidden
  49093. */
  49094. _detachCameras(cameras: Camera[]): void;
  49095. /**
  49096. * Enables the effect on given cameras
  49097. * @param cameras The camera to enable.
  49098. * @hidden
  49099. */
  49100. _enable(cameras: Camera): void;
  49101. /**
  49102. * Enables the effect on given cameras
  49103. * @param cameras The camera to enable.
  49104. * @hidden
  49105. */
  49106. _enable(cameras: Nullable<Camera[]>): void;
  49107. /**
  49108. * Disables the effect on the given cameras
  49109. * @param cameras The camera to disable.
  49110. * @hidden
  49111. */
  49112. _disable(cameras: Camera): void;
  49113. /**
  49114. * Disables the effect on the given cameras
  49115. * @param cameras The camera to disable.
  49116. * @hidden
  49117. */
  49118. _disable(cameras: Nullable<Camera[]>): void;
  49119. /**
  49120. * Gets a list of the post processes contained in the effect.
  49121. * @param camera The camera to get the post processes on.
  49122. * @returns The list of the post processes in the effect.
  49123. */
  49124. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49125. }
  49126. }
  49127. declare module BABYLON {
  49128. /**
  49129. * PostProcessRenderPipeline
  49130. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49131. */
  49132. class PostProcessRenderPipeline {
  49133. private engine;
  49134. private _renderEffects;
  49135. private _renderEffectsForIsolatedPass;
  49136. /**
  49137. * @hidden
  49138. */
  49139. protected _cameras: Camera[];
  49140. /** @hidden */
  49141. _name: string;
  49142. /**
  49143. * Initializes a PostProcessRenderPipeline
  49144. * @param engine engine to add the pipeline to
  49145. * @param name name of the pipeline
  49146. */
  49147. constructor(engine: Engine, name: string);
  49148. /**
  49149. * "PostProcessRenderPipeline"
  49150. * @returns "PostProcessRenderPipeline"
  49151. */
  49152. getClassName(): string;
  49153. /**
  49154. * If all the render effects in the pipeline are support
  49155. */
  49156. readonly isSupported: boolean;
  49157. /**
  49158. * Adds an effect to the pipeline
  49159. * @param renderEffect the effect to add
  49160. */
  49161. addEffect(renderEffect: PostProcessRenderEffect): void;
  49162. /** @hidden */
  49163. _rebuild(): void;
  49164. /** @hidden */
  49165. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49166. /** @hidden */
  49167. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49168. /** @hidden */
  49169. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49170. /** @hidden */
  49171. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49172. /** @hidden */
  49173. _attachCameras(cameras: Camera, unique: boolean): void;
  49174. /** @hidden */
  49175. _attachCameras(cameras: Camera[], unique: boolean): void;
  49176. /** @hidden */
  49177. _detachCameras(cameras: Camera): void;
  49178. /** @hidden */
  49179. _detachCameras(cameras: Nullable<Camera[]>): void;
  49180. /** @hidden */
  49181. _update(): void;
  49182. /** @hidden */
  49183. _reset(): void;
  49184. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49185. /**
  49186. * Disposes of the pipeline
  49187. */
  49188. dispose(): void;
  49189. }
  49190. }
  49191. declare module BABYLON {
  49192. /**
  49193. * PostProcessRenderPipelineManager class
  49194. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49195. */
  49196. class PostProcessRenderPipelineManager {
  49197. private _renderPipelines;
  49198. /**
  49199. * Initializes a PostProcessRenderPipelineManager
  49200. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49201. */
  49202. constructor();
  49203. /**
  49204. * Adds a pipeline to the manager
  49205. * @param renderPipeline The pipeline to add
  49206. */
  49207. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49208. /**
  49209. * Attaches a camera to the pipeline
  49210. * @param renderPipelineName The name of the pipeline to attach to
  49211. * @param cameras the camera to attach
  49212. * @param unique if the camera can be attached multiple times to the pipeline
  49213. */
  49214. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49215. /**
  49216. * Detaches a camera from the pipeline
  49217. * @param renderPipelineName The name of the pipeline to detach from
  49218. * @param cameras the camera to detach
  49219. */
  49220. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49221. /**
  49222. * Enables an effect by name on a pipeline
  49223. * @param renderPipelineName the name of the pipeline to enable the effect in
  49224. * @param renderEffectName the name of the effect to enable
  49225. * @param cameras the cameras that the effect should be enabled on
  49226. */
  49227. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49228. /**
  49229. * Disables an effect by name on a pipeline
  49230. * @param renderPipelineName the name of the pipeline to disable the effect in
  49231. * @param renderEffectName the name of the effect to disable
  49232. * @param cameras the cameras that the effect should be disabled on
  49233. */
  49234. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49235. /**
  49236. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49237. */
  49238. update(): void;
  49239. /** @hidden */
  49240. _rebuild(): void;
  49241. /**
  49242. * Disposes of the manager and pipelines
  49243. */
  49244. dispose(): void;
  49245. }
  49246. }
  49247. declare module BABYLON {
  49248. interface Scene {
  49249. /** @hidden (Backing field) */
  49250. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49251. /**
  49252. * Gets the postprocess render pipeline manager
  49253. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49254. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49255. */
  49256. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49257. }
  49258. /**
  49259. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49260. */
  49261. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49262. /**
  49263. * The component name helpfull to identify the component in the list of scene components.
  49264. */
  49265. readonly name: string;
  49266. /**
  49267. * The scene the component belongs to.
  49268. */
  49269. scene: Scene;
  49270. /**
  49271. * Creates a new instance of the component for the given scene
  49272. * @param scene Defines the scene to register the component in
  49273. */
  49274. constructor(scene: Scene);
  49275. /**
  49276. * Registers the component in a given scene
  49277. */
  49278. register(): void;
  49279. /**
  49280. * Rebuilds the elements related to this component in case of
  49281. * context lost for instance.
  49282. */
  49283. rebuild(): void;
  49284. /**
  49285. * Disposes the component and the associated ressources
  49286. */
  49287. dispose(): void;
  49288. private _gatherRenderTargets;
  49289. }
  49290. }
  49291. declare module BABYLON {
  49292. /**
  49293. * Helper class dealing with the extraction of spherical polynomial dataArray
  49294. * from a cube map.
  49295. */
  49296. class CubeMapToSphericalPolynomialTools {
  49297. private static FileFaces;
  49298. /**
  49299. * Converts a texture to the according Spherical Polynomial data.
  49300. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49301. *
  49302. * @param texture The texture to extract the information from.
  49303. * @return The Spherical Polynomial data.
  49304. */
  49305. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49306. /**
  49307. * Converts a cubemap to the according Spherical Polynomial data.
  49308. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49309. *
  49310. * @param cubeInfo The Cube map to extract the information from.
  49311. * @return The Spherical Polynomial data.
  49312. */
  49313. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49314. }
  49315. }
  49316. declare module BABYLON {
  49317. /**
  49318. * Header information of HDR texture files.
  49319. */
  49320. interface HDRInfo {
  49321. /**
  49322. * The height of the texture in pixels.
  49323. */
  49324. height: number;
  49325. /**
  49326. * The width of the texture in pixels.
  49327. */
  49328. width: number;
  49329. /**
  49330. * The index of the beginning of the data in the binary file.
  49331. */
  49332. dataPosition: number;
  49333. }
  49334. /**
  49335. * This groups tools to convert HDR texture to native colors array.
  49336. */
  49337. class HDRTools {
  49338. private static Ldexp;
  49339. private static Rgbe2float;
  49340. private static readStringLine;
  49341. /**
  49342. * Reads header information from an RGBE texture stored in a native array.
  49343. * More information on this format are available here:
  49344. * https://en.wikipedia.org/wiki/RGBE_image_format
  49345. *
  49346. * @param uint8array The binary file stored in native array.
  49347. * @return The header information.
  49348. */
  49349. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49350. /**
  49351. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49352. * This RGBE texture needs to store the information as a panorama.
  49353. *
  49354. * More information on this format are available here:
  49355. * https://en.wikipedia.org/wiki/RGBE_image_format
  49356. *
  49357. * @param buffer The binary file stored in an array buffer.
  49358. * @param size The expected size of the extracted cubemap.
  49359. * @return The Cube Map information.
  49360. */
  49361. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49362. /**
  49363. * Returns the pixels data extracted from an RGBE texture.
  49364. * This pixels will be stored left to right up to down in the R G B order in one array.
  49365. *
  49366. * More information on this format are available here:
  49367. * https://en.wikipedia.org/wiki/RGBE_image_format
  49368. *
  49369. * @param uint8array The binary file stored in an array buffer.
  49370. * @param hdrInfo The header information of the file.
  49371. * @return The pixels data in RGB right to left up to down order.
  49372. */
  49373. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49374. private static RGBE_ReadPixels_RLE;
  49375. }
  49376. }
  49377. declare module BABYLON {
  49378. /**
  49379. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49380. */
  49381. interface CubeMapInfo {
  49382. /**
  49383. * The pixel array for the front face.
  49384. * This is stored in format, left to right, up to down format.
  49385. */
  49386. front: Nullable<ArrayBufferView>;
  49387. /**
  49388. * The pixel array for the back face.
  49389. * This is stored in format, left to right, up to down format.
  49390. */
  49391. back: Nullable<ArrayBufferView>;
  49392. /**
  49393. * The pixel array for the left face.
  49394. * This is stored in format, left to right, up to down format.
  49395. */
  49396. left: Nullable<ArrayBufferView>;
  49397. /**
  49398. * The pixel array for the right face.
  49399. * This is stored in format, left to right, up to down format.
  49400. */
  49401. right: Nullable<ArrayBufferView>;
  49402. /**
  49403. * The pixel array for the up face.
  49404. * This is stored in format, left to right, up to down format.
  49405. */
  49406. up: Nullable<ArrayBufferView>;
  49407. /**
  49408. * The pixel array for the down face.
  49409. * This is stored in format, left to right, up to down format.
  49410. */
  49411. down: Nullable<ArrayBufferView>;
  49412. /**
  49413. * The size of the cubemap stored.
  49414. *
  49415. * Each faces will be size * size pixels.
  49416. */
  49417. size: number;
  49418. /**
  49419. * The format of the texture.
  49420. *
  49421. * RGBA, RGB.
  49422. */
  49423. format: number;
  49424. /**
  49425. * The type of the texture data.
  49426. *
  49427. * UNSIGNED_INT, FLOAT.
  49428. */
  49429. type: number;
  49430. /**
  49431. * Specifies whether the texture is in gamma space.
  49432. */
  49433. gammaSpace: boolean;
  49434. }
  49435. /**
  49436. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  49437. */
  49438. class PanoramaToCubeMapTools {
  49439. private static FACE_FRONT;
  49440. private static FACE_BACK;
  49441. private static FACE_RIGHT;
  49442. private static FACE_LEFT;
  49443. private static FACE_DOWN;
  49444. private static FACE_UP;
  49445. /**
  49446. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49447. *
  49448. * @param float32Array The source data.
  49449. * @param inputWidth The width of the input panorama.
  49450. * @param inputHeight The height of the input panorama.
  49451. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49452. * @return The cubemap data
  49453. */
  49454. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49455. private static CreateCubemapTexture;
  49456. private static CalcProjectionSpherical;
  49457. }
  49458. }
  49459. declare module BABYLON {
  49460. }
  49461. declare module BABYLON {
  49462. }
  49463. declare module BABYLON {
  49464. }
  49465. declare module BABYLON {
  49466. }
  49467. declare module BABYLON {
  49468. /**
  49469. * 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.
  49470. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49471. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49472. */
  49473. class CustomProceduralTexture extends ProceduralTexture {
  49474. private _animate;
  49475. private _time;
  49476. private _config;
  49477. private _texturePath;
  49478. /**
  49479. * Instantiates a new Custom Procedural Texture.
  49480. * 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.
  49481. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49482. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49483. * @param name Define the name of the texture
  49484. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49485. * @param size Define the size of the texture to create
  49486. * @param scene Define the scene the texture belongs to
  49487. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49488. * @param generateMipMaps Define if the texture should creates mip maps or not
  49489. */
  49490. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49491. private _loadJson;
  49492. /**
  49493. * Is the texture ready to be used ? (rendered at least once)
  49494. * @returns true if ready, otherwise, false.
  49495. */
  49496. isReady(): boolean;
  49497. /**
  49498. * Render the texture to its associated render target.
  49499. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49500. */
  49501. render(useCameraPostProcess?: boolean): void;
  49502. /**
  49503. * Update the list of dependant textures samplers in the shader.
  49504. */
  49505. updateTextures(): void;
  49506. /**
  49507. * Update the uniform values of the procedural texture in the shader.
  49508. */
  49509. updateShaderUniforms(): void;
  49510. /**
  49511. * Define if the texture animates or not.
  49512. */
  49513. animate: boolean;
  49514. }
  49515. }
  49516. declare module BABYLON {
  49517. /**
  49518. * Class used to generate noise procedural textures
  49519. */
  49520. class NoiseProceduralTexture extends ProceduralTexture {
  49521. private _time;
  49522. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49523. brightness: number;
  49524. /** Defines the number of octaves to process */
  49525. octaves: number;
  49526. /** Defines the level of persistence (0.8 by default) */
  49527. persistence: number;
  49528. /** Gets or sets animation speed factor (default is 1) */
  49529. animationSpeedFactor: number;
  49530. /**
  49531. * Creates a new NoiseProceduralTexture
  49532. * @param name defines the name fo the texture
  49533. * @param size defines the size of the texture (default is 256)
  49534. * @param scene defines the hosting scene
  49535. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49536. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49537. */
  49538. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49539. private _updateShaderUniforms;
  49540. protected _getDefines(): string;
  49541. /** Generate the current state of the procedural texture */
  49542. render(useCameraPostProcess?: boolean): void;
  49543. /**
  49544. * Serializes this noise procedural texture
  49545. * @returns a serialized noise procedural texture object
  49546. */
  49547. serialize(): any;
  49548. /**
  49549. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49550. * @param parsedTexture defines parsed texture data
  49551. * @param scene defines the current scene
  49552. * @param rootUrl defines the root URL containing noise procedural texture information
  49553. * @returns a parsed NoiseProceduralTexture
  49554. */
  49555. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  49556. }
  49557. }
  49558. declare module BABYLON {
  49559. /**
  49560. * 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.
  49561. * This is the base class of any Procedural texture and contains most of the shareable code.
  49562. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49563. */
  49564. class ProceduralTexture extends Texture {
  49565. isCube: boolean;
  49566. /**
  49567. * Define if the texture is enabled or not (disabled texture will not render)
  49568. */
  49569. isEnabled: boolean;
  49570. /**
  49571. * Define if the texture must be cleared before rendering (default is true)
  49572. */
  49573. autoClear: boolean;
  49574. /**
  49575. * Callback called when the texture is generated
  49576. */
  49577. onGenerated: () => void;
  49578. /**
  49579. * Event raised when the texture is generated
  49580. */
  49581. onGeneratedObservable: Observable<ProceduralTexture>;
  49582. /** @hidden */
  49583. _generateMipMaps: boolean;
  49584. /** @hidden **/
  49585. _effect: Effect;
  49586. /** @hidden */
  49587. _textures: {
  49588. [key: string]: Texture;
  49589. };
  49590. private _size;
  49591. private _currentRefreshId;
  49592. private _refreshRate;
  49593. private _vertexBuffers;
  49594. private _indexBuffer;
  49595. private _uniforms;
  49596. private _samplers;
  49597. private _fragment;
  49598. private _floats;
  49599. private _ints;
  49600. private _floatsArrays;
  49601. private _colors3;
  49602. private _colors4;
  49603. private _vectors2;
  49604. private _vectors3;
  49605. private _matrices;
  49606. private _fallbackTexture;
  49607. private _fallbackTextureUsed;
  49608. private _engine;
  49609. private _cachedDefines;
  49610. private _contentUpdateId;
  49611. private _contentData;
  49612. /**
  49613. * Instantiates a new procedural texture.
  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. * @param name Define the name of the texture
  49618. * @param size Define the size of the texture to create
  49619. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  49620. * @param scene Define the scene the texture belongs to
  49621. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49622. * @param generateMipMaps Define if the texture should creates mip maps or not
  49623. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  49624. */
  49625. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  49626. /**
  49627. * The effect that is created when initializing the post process.
  49628. * @returns The created effect corrisponding the the postprocess.
  49629. */
  49630. getEffect(): Effect;
  49631. /**
  49632. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  49633. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  49634. */
  49635. getContent(): Nullable<ArrayBufferView>;
  49636. private _createIndexBuffer;
  49637. /** @hidden */
  49638. _rebuild(): void;
  49639. /**
  49640. * Resets the texture in order to recreate its associated resources.
  49641. * This can be called in case of context loss
  49642. */
  49643. reset(): void;
  49644. protected _getDefines(): string;
  49645. /**
  49646. * Is the texture ready to be used ? (rendered at least once)
  49647. * @returns true if ready, otherwise, false.
  49648. */
  49649. isReady(): boolean;
  49650. /**
  49651. * Resets the refresh counter of the texture and start bak from scratch.
  49652. * Could be usefull to regenerate the texture if it is setup to render only once.
  49653. */
  49654. resetRefreshCounter(): void;
  49655. /**
  49656. * Set the fragment shader to use in order to render the texture.
  49657. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  49658. */
  49659. setFragment(fragment: any): void;
  49660. /**
  49661. * Define the refresh rate of the texture or the rendering frequency.
  49662. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  49663. */
  49664. refreshRate: number;
  49665. /** @hidden */
  49666. _shouldRender(): boolean;
  49667. /**
  49668. * Get the size the texture is rendering at.
  49669. * @returns the size (texture is always squared)
  49670. */
  49671. getRenderSize(): number;
  49672. /**
  49673. * Resize the texture to new value.
  49674. * @param size Define the new size the texture should have
  49675. * @param generateMipMaps Define whether the new texture should create mip maps
  49676. */
  49677. resize(size: number, generateMipMaps: boolean): void;
  49678. private _checkUniform;
  49679. /**
  49680. * Set a texture in the shader program used to render.
  49681. * @param name Define the name of the uniform samplers as defined in the shader
  49682. * @param texture Define the texture to bind to this sampler
  49683. * @return the texture itself allowing "fluent" like uniform updates
  49684. */
  49685. setTexture(name: string, texture: Texture): ProceduralTexture;
  49686. /**
  49687. * Set a float in the shader.
  49688. * @param name Define the name of the uniform as defined in the shader
  49689. * @param value Define the value to give to the uniform
  49690. * @return the texture itself allowing "fluent" like uniform updates
  49691. */
  49692. setFloat(name: string, value: number): ProceduralTexture;
  49693. /**
  49694. * Set a int in the shader.
  49695. * @param name Define the name of the uniform as defined in the shader
  49696. * @param value Define the value to give to the uniform
  49697. * @return the texture itself allowing "fluent" like uniform updates
  49698. */
  49699. setInt(name: string, value: number): ProceduralTexture;
  49700. /**
  49701. * Set an array of floats in the shader.
  49702. * @param name Define the name of the uniform as defined in the shader
  49703. * @param value Define the value to give to the uniform
  49704. * @return the texture itself allowing "fluent" like uniform updates
  49705. */
  49706. setFloats(name: string, value: number[]): ProceduralTexture;
  49707. /**
  49708. * Set a vec3 in the shader from a Color3.
  49709. * @param name Define the name of the uniform as defined in the shader
  49710. * @param value Define the value to give to the uniform
  49711. * @return the texture itself allowing "fluent" like uniform updates
  49712. */
  49713. setColor3(name: string, value: Color3): ProceduralTexture;
  49714. /**
  49715. * Set a vec4 in the shader from a Color4.
  49716. * @param name Define the name of the uniform as defined in the shader
  49717. * @param value Define the value to give to the uniform
  49718. * @return the texture itself allowing "fluent" like uniform updates
  49719. */
  49720. setColor4(name: string, value: Color4): ProceduralTexture;
  49721. /**
  49722. * Set a vec2 in the shader from a Vector2.
  49723. * @param name Define the name of the uniform as defined in the shader
  49724. * @param value Define the value to give to the uniform
  49725. * @return the texture itself allowing "fluent" like uniform updates
  49726. */
  49727. setVector2(name: string, value: Vector2): ProceduralTexture;
  49728. /**
  49729. * Set a vec3 in the shader from a Vector3.
  49730. * @param name Define the name of the uniform as defined in the shader
  49731. * @param value Define the value to give to the uniform
  49732. * @return the texture itself allowing "fluent" like uniform updates
  49733. */
  49734. setVector3(name: string, value: Vector3): ProceduralTexture;
  49735. /**
  49736. * Set a mat4 in the shader from a MAtrix.
  49737. * @param name Define the name of the uniform as defined in the shader
  49738. * @param value Define the value to give to the uniform
  49739. * @return the texture itself allowing "fluent" like uniform updates
  49740. */
  49741. setMatrix(name: string, value: Matrix): ProceduralTexture;
  49742. /**
  49743. * Render the texture to its associated render target.
  49744. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49745. */
  49746. render(useCameraPostProcess?: boolean): void;
  49747. /**
  49748. * Clone the texture.
  49749. * @returns the cloned texture
  49750. */
  49751. clone(): ProceduralTexture;
  49752. /**
  49753. * Dispose the texture and release its asoociated resources.
  49754. */
  49755. dispose(): void;
  49756. }
  49757. }
  49758. declare module BABYLON {
  49759. interface AbstractScene {
  49760. /**
  49761. * The list of procedural textures added to the scene
  49762. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49763. */
  49764. proceduralTextures: Array<ProceduralTexture>;
  49765. }
  49766. /**
  49767. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  49768. * in a given scene.
  49769. */
  49770. class ProceduralTextureSceneComponent implements ISceneComponent {
  49771. /**
  49772. * The component name helpfull to identify the component in the list of scene components.
  49773. */
  49774. readonly name: string;
  49775. /**
  49776. * The scene the component belongs to.
  49777. */
  49778. scene: Scene;
  49779. /**
  49780. * Creates a new instance of the component for the given scene
  49781. * @param scene Defines the scene to register the component in
  49782. */
  49783. constructor(scene: Scene);
  49784. /**
  49785. * Registers the component in a given scene
  49786. */
  49787. register(): void;
  49788. /**
  49789. * Rebuilds the elements related to this component in case of
  49790. * context lost for instance.
  49791. */
  49792. rebuild(): void;
  49793. /**
  49794. * Disposes the component and the associated ressources.
  49795. */
  49796. dispose(): void;
  49797. private _beforeClear;
  49798. }
  49799. }
  49800. declare module BABYLON {
  49801. /**
  49802. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49803. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49804. */
  49805. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49806. private _scene;
  49807. private _camerasToBeAttached;
  49808. /**
  49809. * ID of the sharpen post process,
  49810. */
  49811. private readonly SharpenPostProcessId;
  49812. /**
  49813. * @ignore
  49814. * ID of the image processing post process;
  49815. */
  49816. readonly ImageProcessingPostProcessId: string;
  49817. /**
  49818. * @ignore
  49819. * ID of the Fast Approximate Anti-Aliasing post process;
  49820. */
  49821. readonly FxaaPostProcessId: string;
  49822. /**
  49823. * ID of the chromatic aberration post process,
  49824. */
  49825. private readonly ChromaticAberrationPostProcessId;
  49826. /**
  49827. * ID of the grain post process
  49828. */
  49829. private readonly GrainPostProcessId;
  49830. /**
  49831. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49832. */
  49833. sharpen: SharpenPostProcess;
  49834. private _sharpenEffect;
  49835. private bloom;
  49836. /**
  49837. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49838. */
  49839. depthOfField: DepthOfFieldEffect;
  49840. /**
  49841. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49842. */
  49843. fxaa: FxaaPostProcess;
  49844. /**
  49845. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49846. */
  49847. imageProcessing: ImageProcessingPostProcess;
  49848. /**
  49849. * Chromatic aberration post process which will shift rgb colors in the image
  49850. */
  49851. chromaticAberration: ChromaticAberrationPostProcess;
  49852. private _chromaticAberrationEffect;
  49853. /**
  49854. * Grain post process which add noise to the image
  49855. */
  49856. grain: GrainPostProcess;
  49857. private _grainEffect;
  49858. /**
  49859. * Glow post process which adds a glow to emmisive areas of the image
  49860. */
  49861. private _glowLayer;
  49862. /**
  49863. * Animations which can be used to tweak settings over a period of time
  49864. */
  49865. animations: Animation[];
  49866. private _imageProcessingConfigurationObserver;
  49867. private _sharpenEnabled;
  49868. private _bloomEnabled;
  49869. private _depthOfFieldEnabled;
  49870. private _depthOfFieldBlurLevel;
  49871. private _fxaaEnabled;
  49872. private _imageProcessingEnabled;
  49873. private _defaultPipelineTextureType;
  49874. private _bloomScale;
  49875. private _chromaticAberrationEnabled;
  49876. private _grainEnabled;
  49877. private _buildAllowed;
  49878. /**
  49879. * Enable or disable the sharpen process from the pipeline
  49880. */
  49881. sharpenEnabled: boolean;
  49882. private _resizeObserver;
  49883. private _hardwareScaleLevel;
  49884. private _bloomKernel;
  49885. /**
  49886. * Specifies the size of the bloom blur kernel, relative to the final output size
  49887. */
  49888. bloomKernel: number;
  49889. /**
  49890. * Specifies the weight of the bloom in the final rendering
  49891. */
  49892. private _bloomWeight;
  49893. /**
  49894. * Specifies the luma threshold for the area that will be blurred by the bloom
  49895. */
  49896. private _bloomThreshold;
  49897. private _hdr;
  49898. /**
  49899. * The strength of the bloom.
  49900. */
  49901. bloomWeight: number;
  49902. /**
  49903. * The strength of the bloom.
  49904. */
  49905. bloomThreshold: number;
  49906. /**
  49907. * The scale of the bloom, lower value will provide better performance.
  49908. */
  49909. bloomScale: number;
  49910. /**
  49911. * Enable or disable the bloom from the pipeline
  49912. */
  49913. bloomEnabled: boolean;
  49914. private _rebuildBloom;
  49915. /**
  49916. * If the depth of field is enabled.
  49917. */
  49918. depthOfFieldEnabled: boolean;
  49919. /**
  49920. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49921. */
  49922. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49923. /**
  49924. * If the anti aliasing is enabled.
  49925. */
  49926. fxaaEnabled: boolean;
  49927. private _samples;
  49928. /**
  49929. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49930. */
  49931. samples: number;
  49932. /**
  49933. * If image processing is enabled.
  49934. */
  49935. imageProcessingEnabled: boolean;
  49936. /**
  49937. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49938. */
  49939. glowLayerEnabled: boolean;
  49940. /**
  49941. * Enable or disable the chromaticAberration process from the pipeline
  49942. */
  49943. chromaticAberrationEnabled: boolean;
  49944. /**
  49945. * Enable or disable the grain process from the pipeline
  49946. */
  49947. grainEnabled: boolean;
  49948. /**
  49949. * @constructor
  49950. * @param name - The rendering pipeline name (default: "")
  49951. * @param hdr - If high dynamic range textures should be used (default: true)
  49952. * @param scene - The scene linked to this pipeline (default: the last created scene)
  49953. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  49954. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  49955. */
  49956. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  49957. /**
  49958. * Force the compilation of the entire pipeline.
  49959. */
  49960. prepare(): void;
  49961. private _hasCleared;
  49962. private _prevPostProcess;
  49963. private _prevPrevPostProcess;
  49964. private _setAutoClearAndTextureSharing;
  49965. private _depthOfFieldSceneObserver;
  49966. private _buildPipeline;
  49967. private _disposePostProcesses;
  49968. /**
  49969. * Adds a camera to the pipeline
  49970. * @param camera the camera to be added
  49971. */
  49972. addCamera(camera: Camera): void;
  49973. /**
  49974. * Removes a camera from the pipeline
  49975. * @param camera the camera to remove
  49976. */
  49977. removeCamera(camera: Camera): void;
  49978. /**
  49979. * Dispose of the pipeline and stop all post processes
  49980. */
  49981. dispose(): void;
  49982. /**
  49983. * Serialize the rendering pipeline (Used when exporting)
  49984. * @returns the serialized object
  49985. */
  49986. serialize(): any;
  49987. /**
  49988. * Parse the serialized pipeline
  49989. * @param source Source pipeline.
  49990. * @param scene The scene to load the pipeline to.
  49991. * @param rootUrl The URL of the serialized pipeline.
  49992. * @returns An instantiated pipeline from the serialized object.
  49993. */
  49994. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  49995. }
  49996. }
  49997. declare module BABYLON {
  49998. /**
  49999. * BABYLON.JS Chromatic Aberration GLSL Shader
  50000. * Author: Olivier Guyot
  50001. * Separates very slightly R, G and B colors on the edges of the screen
  50002. * Inspired by Francois Tarlier & Martins Upitis
  50003. */
  50004. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50005. /**
  50006. * @ignore
  50007. * The chromatic aberration PostProcess id in the pipeline
  50008. */
  50009. LensChromaticAberrationEffect: string;
  50010. /**
  50011. * @ignore
  50012. * The highlights enhancing PostProcess id in the pipeline
  50013. */
  50014. HighlightsEnhancingEffect: string;
  50015. /**
  50016. * @ignore
  50017. * The depth-of-field PostProcess id in the pipeline
  50018. */
  50019. LensDepthOfFieldEffect: string;
  50020. private _scene;
  50021. private _depthTexture;
  50022. private _grainTexture;
  50023. private _chromaticAberrationPostProcess;
  50024. private _highlightsPostProcess;
  50025. private _depthOfFieldPostProcess;
  50026. private _edgeBlur;
  50027. private _grainAmount;
  50028. private _chromaticAberration;
  50029. private _distortion;
  50030. private _highlightsGain;
  50031. private _highlightsThreshold;
  50032. private _dofDistance;
  50033. private _dofAperture;
  50034. private _dofDarken;
  50035. private _dofPentagon;
  50036. private _blurNoise;
  50037. /**
  50038. * @constructor
  50039. *
  50040. * Effect parameters are as follow:
  50041. * {
  50042. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50043. * edge_blur: number; // from 0 to x (1 for realism)
  50044. * distortion: number; // from 0 to x (1 for realism)
  50045. * grain_amount: number; // from 0 to 1
  50046. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50047. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50048. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50049. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50050. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50051. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50052. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50053. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50054. * }
  50055. * Note: if an effect parameter is unset, effect is disabled
  50056. *
  50057. * @param name The rendering pipeline name
  50058. * @param parameters - An object containing all parameters (see above)
  50059. * @param scene The scene linked to this pipeline
  50060. * @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)
  50061. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50062. */
  50063. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50064. /**
  50065. * Sets the amount of blur at the edges
  50066. * @param amount blur amount
  50067. */
  50068. setEdgeBlur(amount: number): void;
  50069. /**
  50070. * Sets edge blur to 0
  50071. */
  50072. disableEdgeBlur(): void;
  50073. /**
  50074. * Sets the amout of grain
  50075. * @param amount Amount of grain
  50076. */
  50077. setGrainAmount(amount: number): void;
  50078. /**
  50079. * Set grain amount to 0
  50080. */
  50081. disableGrain(): void;
  50082. /**
  50083. * Sets the chromatic aberration amount
  50084. * @param amount amount of chromatic aberration
  50085. */
  50086. setChromaticAberration(amount: number): void;
  50087. /**
  50088. * Sets chromatic aberration amount to 0
  50089. */
  50090. disableChromaticAberration(): void;
  50091. /**
  50092. * Sets the EdgeDistortion amount
  50093. * @param amount amount of EdgeDistortion
  50094. */
  50095. setEdgeDistortion(amount: number): void;
  50096. /**
  50097. * Sets edge distortion to 0
  50098. */
  50099. disableEdgeDistortion(): void;
  50100. /**
  50101. * Sets the FocusDistance amount
  50102. * @param amount amount of FocusDistance
  50103. */
  50104. setFocusDistance(amount: number): void;
  50105. /**
  50106. * Disables depth of field
  50107. */
  50108. disableDepthOfField(): void;
  50109. /**
  50110. * Sets the Aperture amount
  50111. * @param amount amount of Aperture
  50112. */
  50113. setAperture(amount: number): void;
  50114. /**
  50115. * Sets the DarkenOutOfFocus amount
  50116. * @param amount amount of DarkenOutOfFocus
  50117. */
  50118. setDarkenOutOfFocus(amount: number): void;
  50119. /**
  50120. * Creates a pentagon bokeh effect
  50121. */
  50122. enablePentagonBokeh(): void;
  50123. /**
  50124. * Disables the pentagon bokeh effect
  50125. */
  50126. disablePentagonBokeh(): void;
  50127. /**
  50128. * Enables noise blur
  50129. */
  50130. enableNoiseBlur(): void;
  50131. /**
  50132. * Disables noise blur
  50133. */
  50134. disableNoiseBlur(): void;
  50135. /**
  50136. * Sets the HighlightsGain amount
  50137. * @param amount amount of HighlightsGain
  50138. */
  50139. setHighlightsGain(amount: number): void;
  50140. /**
  50141. * Sets the HighlightsThreshold amount
  50142. * @param amount amount of HighlightsThreshold
  50143. */
  50144. setHighlightsThreshold(amount: number): void;
  50145. /**
  50146. * Disables highlights
  50147. */
  50148. disableHighlights(): void;
  50149. /**
  50150. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50151. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50152. */
  50153. dispose(disableDepthRender?: boolean): void;
  50154. private _createChromaticAberrationPostProcess;
  50155. private _createHighlightsPostProcess;
  50156. private _createDepthOfFieldPostProcess;
  50157. private _createGrainTexture;
  50158. }
  50159. }
  50160. declare module BABYLON {
  50161. /**
  50162. * Render pipeline to produce ssao effect
  50163. */
  50164. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50165. /**
  50166. * @ignore
  50167. * The PassPostProcess id in the pipeline that contains the original scene color
  50168. */
  50169. SSAOOriginalSceneColorEffect: string;
  50170. /**
  50171. * @ignore
  50172. * The SSAO PostProcess id in the pipeline
  50173. */
  50174. SSAORenderEffect: string;
  50175. /**
  50176. * @ignore
  50177. * The horizontal blur PostProcess id in the pipeline
  50178. */
  50179. SSAOBlurHRenderEffect: string;
  50180. /**
  50181. * @ignore
  50182. * The vertical blur PostProcess id in the pipeline
  50183. */
  50184. SSAOBlurVRenderEffect: string;
  50185. /**
  50186. * @ignore
  50187. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50188. */
  50189. SSAOCombineRenderEffect: string;
  50190. /**
  50191. * The output strength of the SSAO post-process. Default value is 1.0.
  50192. */
  50193. totalStrength: number;
  50194. /**
  50195. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50196. */
  50197. maxZ: number;
  50198. /**
  50199. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50200. */
  50201. minZAspect: number;
  50202. private _samples;
  50203. /**
  50204. * Number of samples used for the SSAO calculations. Default value is 8
  50205. */
  50206. samples: number;
  50207. private _textureSamples;
  50208. /**
  50209. * Number of samples to use for antialiasing
  50210. */
  50211. textureSamples: number;
  50212. /**
  50213. * Ratio object used for SSAO ratio and blur ratio
  50214. */
  50215. private _ratio;
  50216. /**
  50217. * Dynamically generated sphere sampler.
  50218. */
  50219. private _sampleSphere;
  50220. /**
  50221. * Blur filter offsets
  50222. */
  50223. private _samplerOffsets;
  50224. private _expensiveBlur;
  50225. /**
  50226. * If bilateral blur should be used
  50227. */
  50228. expensiveBlur: boolean;
  50229. /**
  50230. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50231. */
  50232. radius: number;
  50233. /**
  50234. * The base color of the SSAO post-process
  50235. * The final result is "base + ssao" between [0, 1]
  50236. */
  50237. base: number;
  50238. /**
  50239. * Support test.
  50240. */
  50241. static readonly IsSupported: boolean;
  50242. private _scene;
  50243. private _depthTexture;
  50244. private _normalTexture;
  50245. private _randomTexture;
  50246. private _originalColorPostProcess;
  50247. private _ssaoPostProcess;
  50248. private _blurHPostProcess;
  50249. private _blurVPostProcess;
  50250. private _ssaoCombinePostProcess;
  50251. private _firstUpdate;
  50252. /**
  50253. * @constructor
  50254. * @param name The rendering pipeline name
  50255. * @param scene The scene linked to this pipeline
  50256. * @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 }
  50257. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50258. */
  50259. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50260. /**
  50261. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50262. */
  50263. dispose(disableGeometryBufferRenderer?: boolean): void;
  50264. private _createBlurPostProcess;
  50265. /** @hidden */
  50266. _rebuild(): void;
  50267. private _bits;
  50268. private _radicalInverse_VdC;
  50269. private _hammersley;
  50270. private _hemisphereSample_uniform;
  50271. private _generateHemisphere;
  50272. private _createSSAOPostProcess;
  50273. private _createSSAOCombinePostProcess;
  50274. private _createRandomTexture;
  50275. /**
  50276. * Serialize the rendering pipeline (Used when exporting)
  50277. * @returns the serialized object
  50278. */
  50279. serialize(): any;
  50280. /**
  50281. * Parse the serialized pipeline
  50282. * @param source Source pipeline.
  50283. * @param scene The scene to load the pipeline to.
  50284. * @param rootUrl The URL of the serialized pipeline.
  50285. * @returns An instantiated pipeline from the serialized object.
  50286. */
  50287. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50288. }
  50289. }
  50290. declare module BABYLON {
  50291. /**
  50292. * Render pipeline to produce ssao effect
  50293. */
  50294. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50295. /**
  50296. * @ignore
  50297. * The PassPostProcess id in the pipeline that contains the original scene color
  50298. */
  50299. SSAOOriginalSceneColorEffect: string;
  50300. /**
  50301. * @ignore
  50302. * The SSAO PostProcess id in the pipeline
  50303. */
  50304. SSAORenderEffect: string;
  50305. /**
  50306. * @ignore
  50307. * The horizontal blur PostProcess id in the pipeline
  50308. */
  50309. SSAOBlurHRenderEffect: string;
  50310. /**
  50311. * @ignore
  50312. * The vertical blur PostProcess id in the pipeline
  50313. */
  50314. SSAOBlurVRenderEffect: string;
  50315. /**
  50316. * @ignore
  50317. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50318. */
  50319. SSAOCombineRenderEffect: string;
  50320. /**
  50321. * The output strength of the SSAO post-process. Default value is 1.0.
  50322. */
  50323. totalStrength: number;
  50324. /**
  50325. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50326. */
  50327. radius: number;
  50328. /**
  50329. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50330. * Must not be equal to fallOff and superior to fallOff.
  50331. * Default value is 0.975
  50332. */
  50333. area: number;
  50334. /**
  50335. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50336. * Must not be equal to area and inferior to area.
  50337. * Default value is 0.0
  50338. */
  50339. fallOff: number;
  50340. /**
  50341. * The base color of the SSAO post-process
  50342. * The final result is "base + ssao" between [0, 1]
  50343. */
  50344. base: number;
  50345. private _scene;
  50346. private _depthTexture;
  50347. private _randomTexture;
  50348. private _originalColorPostProcess;
  50349. private _ssaoPostProcess;
  50350. private _blurHPostProcess;
  50351. private _blurVPostProcess;
  50352. private _ssaoCombinePostProcess;
  50353. private _firstUpdate;
  50354. /**
  50355. * @constructor
  50356. * @param name - The rendering pipeline name
  50357. * @param scene - The scene linked to this pipeline
  50358. * @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 }
  50359. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50360. */
  50361. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50362. /**
  50363. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50364. */
  50365. dispose(disableDepthRender?: boolean): void;
  50366. private _createBlurPostProcess;
  50367. /** @hidden */
  50368. _rebuild(): void;
  50369. private _createSSAOPostProcess;
  50370. private _createSSAOCombinePostProcess;
  50371. private _createRandomTexture;
  50372. }
  50373. }
  50374. declare module BABYLON {
  50375. /**
  50376. * Standard rendering pipeline
  50377. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50378. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50379. */
  50380. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50381. /**
  50382. * Public members
  50383. */
  50384. /**
  50385. * Post-process which contains the original scene color before the pipeline applies all the effects
  50386. */
  50387. originalPostProcess: Nullable<PostProcess>;
  50388. /**
  50389. * Post-process used to down scale an image x4
  50390. */
  50391. downSampleX4PostProcess: Nullable<PostProcess>;
  50392. /**
  50393. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50394. */
  50395. brightPassPostProcess: Nullable<PostProcess>;
  50396. /**
  50397. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50398. */
  50399. blurHPostProcesses: PostProcess[];
  50400. /**
  50401. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50402. */
  50403. blurVPostProcesses: PostProcess[];
  50404. /**
  50405. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50406. */
  50407. textureAdderPostProcess: Nullable<PostProcess>;
  50408. /**
  50409. * Post-process used to create volumetric lighting effect
  50410. */
  50411. volumetricLightPostProcess: Nullable<PostProcess>;
  50412. /**
  50413. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50414. */
  50415. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50416. /**
  50417. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50418. */
  50419. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50420. /**
  50421. * Post-process used to merge the volumetric light effect and the real scene color
  50422. */
  50423. volumetricLightMergePostProces: Nullable<PostProcess>;
  50424. /**
  50425. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50426. */
  50427. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50428. /**
  50429. * Base post-process used to calculate the average luminance of the final image for HDR
  50430. */
  50431. luminancePostProcess: Nullable<PostProcess>;
  50432. /**
  50433. * Post-processes used to create down sample post-processes in order to get
  50434. * the average luminance of the final image for HDR
  50435. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50436. */
  50437. luminanceDownSamplePostProcesses: PostProcess[];
  50438. /**
  50439. * Post-process used to create a HDR effect (light adaptation)
  50440. */
  50441. hdrPostProcess: Nullable<PostProcess>;
  50442. /**
  50443. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50444. */
  50445. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50446. /**
  50447. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50448. */
  50449. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50450. /**
  50451. * Post-process used to merge the final HDR post-process and the real scene color
  50452. */
  50453. hdrFinalPostProcess: Nullable<PostProcess>;
  50454. /**
  50455. * Post-process used to create a lens flare effect
  50456. */
  50457. lensFlarePostProcess: Nullable<PostProcess>;
  50458. /**
  50459. * Post-process that merges the result of the lens flare post-process and the real scene color
  50460. */
  50461. lensFlareComposePostProcess: Nullable<PostProcess>;
  50462. /**
  50463. * Post-process used to create a motion blur effect
  50464. */
  50465. motionBlurPostProcess: Nullable<PostProcess>;
  50466. /**
  50467. * Post-process used to create a depth of field effect
  50468. */
  50469. depthOfFieldPostProcess: Nullable<PostProcess>;
  50470. /**
  50471. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50472. */
  50473. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50474. /**
  50475. * Represents the brightness threshold in order to configure the illuminated surfaces
  50476. */
  50477. brightThreshold: number;
  50478. /**
  50479. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50480. */
  50481. blurWidth: number;
  50482. /**
  50483. * Sets if the blur for highlighted surfaces must be only horizontal
  50484. */
  50485. horizontalBlur: boolean;
  50486. /**
  50487. * Sets the overall exposure used by the pipeline
  50488. */
  50489. exposure: number;
  50490. /**
  50491. * Texture used typically to simulate "dirty" on camera lens
  50492. */
  50493. lensTexture: Nullable<Texture>;
  50494. /**
  50495. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50496. */
  50497. volumetricLightCoefficient: number;
  50498. /**
  50499. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50500. */
  50501. volumetricLightPower: number;
  50502. /**
  50503. * Used the set the blur intensity to smooth the volumetric lights
  50504. */
  50505. volumetricLightBlurScale: number;
  50506. /**
  50507. * Light (spot or directional) used to generate the volumetric lights rays
  50508. * The source light must have a shadow generate so the pipeline can get its
  50509. * depth map
  50510. */
  50511. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50512. /**
  50513. * For eye adaptation, represents the minimum luminance the eye can see
  50514. */
  50515. hdrMinimumLuminance: number;
  50516. /**
  50517. * For eye adaptation, represents the decrease luminance speed
  50518. */
  50519. hdrDecreaseRate: number;
  50520. /**
  50521. * For eye adaptation, represents the increase luminance speed
  50522. */
  50523. hdrIncreaseRate: number;
  50524. /**
  50525. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50526. */
  50527. lensColorTexture: Nullable<Texture>;
  50528. /**
  50529. * The overall strengh for the lens flare effect
  50530. */
  50531. lensFlareStrength: number;
  50532. /**
  50533. * Dispersion coefficient for lens flare ghosts
  50534. */
  50535. lensFlareGhostDispersal: number;
  50536. /**
  50537. * Main lens flare halo width
  50538. */
  50539. lensFlareHaloWidth: number;
  50540. /**
  50541. * Based on the lens distortion effect, defines how much the lens flare result
  50542. * is distorted
  50543. */
  50544. lensFlareDistortionStrength: number;
  50545. /**
  50546. * Lens star texture must be used to simulate rays on the flares and is available
  50547. * in the documentation
  50548. */
  50549. lensStarTexture: Nullable<Texture>;
  50550. /**
  50551. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50552. * flare effect by taking account of the dirt texture
  50553. */
  50554. lensFlareDirtTexture: Nullable<Texture>;
  50555. /**
  50556. * Represents the focal length for the depth of field effect
  50557. */
  50558. depthOfFieldDistance: number;
  50559. /**
  50560. * Represents the blur intensity for the blurred part of the depth of field effect
  50561. */
  50562. depthOfFieldBlurWidth: number;
  50563. /**
  50564. * For motion blur, defines how much the image is blurred by the movement
  50565. */
  50566. motionStrength: number;
  50567. /**
  50568. * List of animations for the pipeline (IAnimatable implementation)
  50569. */
  50570. animations: Animation[];
  50571. /**
  50572. * Private members
  50573. */
  50574. private _scene;
  50575. private _currentDepthOfFieldSource;
  50576. private _basePostProcess;
  50577. private _hdrCurrentLuminance;
  50578. private _floatTextureType;
  50579. private _ratio;
  50580. private _bloomEnabled;
  50581. private _depthOfFieldEnabled;
  50582. private _vlsEnabled;
  50583. private _lensFlareEnabled;
  50584. private _hdrEnabled;
  50585. private _motionBlurEnabled;
  50586. private _fxaaEnabled;
  50587. private _motionBlurSamples;
  50588. private _volumetricLightStepsCount;
  50589. private _samples;
  50590. /**
  50591. * @ignore
  50592. * Specifies if the bloom pipeline is enabled
  50593. */
  50594. BloomEnabled: boolean;
  50595. /**
  50596. * @ignore
  50597. * Specifies if the depth of field pipeline is enabed
  50598. */
  50599. DepthOfFieldEnabled: boolean;
  50600. /**
  50601. * @ignore
  50602. * Specifies if the lens flare pipeline is enabed
  50603. */
  50604. LensFlareEnabled: boolean;
  50605. /**
  50606. * @ignore
  50607. * Specifies if the HDR pipeline is enabled
  50608. */
  50609. HDREnabled: boolean;
  50610. /**
  50611. * @ignore
  50612. * Specifies if the volumetric lights scattering effect is enabled
  50613. */
  50614. VLSEnabled: boolean;
  50615. /**
  50616. * @ignore
  50617. * Specifies if the motion blur effect is enabled
  50618. */
  50619. MotionBlurEnabled: boolean;
  50620. /**
  50621. * Specifies if anti-aliasing is enabled
  50622. */
  50623. fxaaEnabled: boolean;
  50624. /**
  50625. * Specifies the number of steps used to calculate the volumetric lights
  50626. * Typically in interval [50, 200]
  50627. */
  50628. volumetricLightStepsCount: number;
  50629. /**
  50630. * Specifies the number of samples used for the motion blur effect
  50631. * Typically in interval [16, 64]
  50632. */
  50633. motionBlurSamples: number;
  50634. /**
  50635. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50636. */
  50637. samples: number;
  50638. /**
  50639. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50640. * @constructor
  50641. * @param name The rendering pipeline name
  50642. * @param scene The scene linked to this pipeline
  50643. * @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)
  50644. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50645. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50646. */
  50647. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50648. private _buildPipeline;
  50649. private _createDownSampleX4PostProcess;
  50650. private _createBrightPassPostProcess;
  50651. private _createBlurPostProcesses;
  50652. private _createTextureAdderPostProcess;
  50653. private _createVolumetricLightPostProcess;
  50654. private _createLuminancePostProcesses;
  50655. private _createHdrPostProcess;
  50656. private _createLensFlarePostProcess;
  50657. private _createDepthOfFieldPostProcess;
  50658. private _createMotionBlurPostProcess;
  50659. private _getDepthTexture;
  50660. private _disposePostProcesses;
  50661. /**
  50662. * Dispose of the pipeline and stop all post processes
  50663. */
  50664. dispose(): void;
  50665. /**
  50666. * Serialize the rendering pipeline (Used when exporting)
  50667. * @returns the serialized object
  50668. */
  50669. serialize(): any;
  50670. /**
  50671. * Parse the serialized pipeline
  50672. * @param source Source pipeline.
  50673. * @param scene The scene to load the pipeline to.
  50674. * @param rootUrl The URL of the serialized pipeline.
  50675. * @returns An instantiated pipeline from the serialized object.
  50676. */
  50677. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50678. /**
  50679. * Luminance steps
  50680. */
  50681. static LuminanceSteps: number;
  50682. }
  50683. }