babylon.d.ts 2.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648
  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. * @see http://doc.babylonjs.com/babylon101/materials
  105. */
  106. materials: Material[];
  107. /**
  108. * The list of morph target managers added to the scene
  109. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110. */
  111. morphTargetManagers: MorphTargetManager[];
  112. /**
  113. * The list of geometries used in the scene.
  114. */
  115. geometries: Geometry[];
  116. /**
  117. * All of the tranform nodes added to this scene
  118. * @see http://doc.babylonjs.com/how_to/transformnode
  119. */
  120. transformNodes: TransformNode[];
  121. /**
  122. * ActionManagers available on the scene.
  123. */
  124. actionManagers: ActionManager[];
  125. /**
  126. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets;
  159. /**
  160. * Removes all the assets contained in the scene and adds them to the container.
  161. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  162. */
  163. moveAllFromScene(keepAssets?: KeepAssets): void;
  164. /**
  165. * 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.
  166. * @returns the root mesh
  167. */
  168. createRootMesh(): Mesh;
  169. }
  170. }
  171. interface Window {
  172. mozIndexedDB: IDBFactory;
  173. webkitIndexedDB: IDBFactory;
  174. msIndexedDB: IDBFactory;
  175. webkitURL: typeof URL;
  176. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  177. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  178. WebGLRenderingContext: WebGLRenderingContext;
  179. MSGesture: MSGesture;
  180. CANNON: any;
  181. AudioContext: AudioContext;
  182. webkitAudioContext: AudioContext;
  183. PointerEvent: any;
  184. Math: Math;
  185. Uint8Array: Uint8ArrayConstructor;
  186. Float32Array: Float32ArrayConstructor;
  187. mozURL: typeof URL;
  188. msURL: typeof URL;
  189. VRFrameData: any;
  190. DracoDecoderModule: any;
  191. }
  192. interface WebGLRenderingContext {
  193. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  194. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  195. vertexAttribDivisor(index: number, divisor: number): void;
  196. createVertexArray(): any;
  197. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  198. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  199. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  200. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  201. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  202. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  203. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  204. createQuery(): WebGLQuery;
  205. deleteQuery(query: WebGLQuery): void;
  206. beginQuery(target: number, query: WebGLQuery): void;
  207. endQuery(target: number): void;
  208. getQueryParameter(query: WebGLQuery, pname: number): any;
  209. getQuery(target: number, pname: number): any;
  210. MAX_SAMPLES: number;
  211. RGBA8: number;
  212. READ_FRAMEBUFFER: number;
  213. DRAW_FRAMEBUFFER: number;
  214. UNIFORM_BUFFER: number;
  215. HALF_FLOAT_OES: number;
  216. RGBA16F: number;
  217. RGBA32F: number;
  218. R32F: number;
  219. RG32F: number;
  220. RGB32F: number;
  221. R16F: number;
  222. RG16F: number;
  223. RGB16F: number;
  224. RED: number;
  225. RG: number;
  226. R8: number;
  227. RG8: number;
  228. UNSIGNED_INT_24_8: number;
  229. DEPTH24_STENCIL8: number;
  230. drawBuffers(buffers: number[]): void;
  231. readBuffer(src: number): void;
  232. readonly COLOR_ATTACHMENT0: number;
  233. readonly COLOR_ATTACHMENT1: number;
  234. readonly COLOR_ATTACHMENT2: number;
  235. readonly COLOR_ATTACHMENT3: number;
  236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  237. ANY_SAMPLES_PASSED: number;
  238. QUERY_RESULT_AVAILABLE: number;
  239. QUERY_RESULT: number;
  240. }
  241. interface Document {
  242. mozCancelFullScreen(): void;
  243. msCancelFullScreen(): void;
  244. mozFullScreen: boolean;
  245. msIsFullScreen: boolean;
  246. fullscreen: boolean;
  247. mozPointerLockElement: HTMLElement;
  248. msPointerLockElement: HTMLElement;
  249. webkitPointerLockElement: HTMLElement;
  250. }
  251. interface HTMLCanvasElement {
  252. msRequestPointerLock?(): void;
  253. mozRequestPointerLock?(): void;
  254. webkitRequestPointerLock?(): void;
  255. }
  256. interface CanvasRenderingContext2D {
  257. msImageSmoothingEnabled: boolean;
  258. }
  259. interface WebGLBuffer {
  260. references: number;
  261. capacity: number;
  262. is32Bits: boolean;
  263. }
  264. interface WebGLProgram {
  265. transformFeedback?: WebGLTransformFeedback | null;
  266. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  267. }
  268. interface MouseEvent {
  269. mozMovementX: number;
  270. mozMovementY: number;
  271. webkitMovementX: number;
  272. webkitMovementY: number;
  273. msMovementX: number;
  274. msMovementY: number;
  275. }
  276. interface Navigator {
  277. mozGetVRDevices: (any: any) => any;
  278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  281. webkitGetGamepads(): Gamepad[];
  282. msGetGamepads(): Gamepad[];
  283. webkitGamepads(): Gamepad[];
  284. }
  285. interface HTMLVideoElement {
  286. mozSrcObject: any;
  287. }
  288. interface Screen {
  289. orientation: string;
  290. mozOrientation: string;
  291. }
  292. interface Math {
  293. fround(x: number): number;
  294. imul(a: number, b: number): number;
  295. }
  296. interface EXT_disjoint_timer_query {
  297. QUERY_COUNTER_BITS_EXT: number;
  298. TIME_ELAPSED_EXT: number;
  299. TIMESTAMP_EXT: number;
  300. GPU_DISJOINT_EXT: number;
  301. QUERY_RESULT_EXT: number;
  302. QUERY_RESULT_AVAILABLE_EXT: number;
  303. queryCounterEXT(query: WebGLQuery, target: number): void;
  304. createQueryEXT(): WebGLQuery;
  305. beginQueryEXT(target: number, query: WebGLQuery): void;
  306. endQueryEXT(target: number): void;
  307. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  308. deleteQueryEXT(query: WebGLQuery): void;
  309. }
  310. interface WebGLUniformLocation {
  311. _currentState: any;
  312. }
  313. declare module BABYLON {
  314. /**
  315. * Defines how a node can be built from a string name.
  316. */
  317. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  318. /**
  319. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  320. */
  321. class Node implements IBehaviorAware<Node> {
  322. private static _NodeConstructors;
  323. /**
  324. * Add a new node constructor
  325. * @param type defines the type name of the node to construct
  326. * @param constructorFunc defines the constructor function
  327. */
  328. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  329. /**
  330. * Returns a node constructor based on type name
  331. * @param type defines the type name
  332. * @param name defines the new node name
  333. * @param scene defines the hosting scene
  334. * @param options defines optional options to transmit to constructors
  335. * @returns the new constructor or null
  336. */
  337. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  338. /**
  339. * Gets or sets the name of the node
  340. */
  341. name: string;
  342. /**
  343. * Gets or sets the id of the node
  344. */
  345. id: string;
  346. /**
  347. * Gets or sets the unique id of the node
  348. */
  349. uniqueId: number;
  350. /**
  351. * Gets or sets a string used to store user defined state for the node
  352. */
  353. state: string;
  354. /**
  355. * Gets or sets an object used to store user defined information for the node
  356. */
  357. metadata: any;
  358. /**
  359. * Gets or sets a boolean used to define if the node must be serialized
  360. */
  361. doNotSerialize: boolean;
  362. /** @hidden */
  363. _isDisposed: boolean;
  364. /**
  365. * Gets a list of Animations associated with the node
  366. */
  367. animations: Animation[];
  368. protected _ranges: {
  369. [name: string]: Nullable<AnimationRange>;
  370. };
  371. /**
  372. * Callback raised when the node is ready to be used
  373. */
  374. onReady: (node: Node) => void;
  375. private _isEnabled;
  376. private _isParentEnabled;
  377. private _isReady;
  378. /** @hidden */
  379. _currentRenderId: number;
  380. private _parentRenderId;
  381. protected _childRenderId: number;
  382. /** @hidden */
  383. _waitingParentId: Nullable<string>;
  384. /** @hidden */
  385. _scene: Scene;
  386. /** @hidden */
  387. _cache: any;
  388. private _parentNode;
  389. private _children;
  390. /** @hidden */
  391. _worldMatrix: Matrix;
  392. /** @hidden */
  393. _worldMatrixDeterminant: number;
  394. /** @hidden */
  395. private _sceneRootNodesIndex;
  396. /**
  397. * Gets a boolean indicating if the node has been disposed
  398. * @returns true if the node was disposed
  399. */
  400. isDisposed(): boolean;
  401. /**
  402. * Gets or sets the parent of the node
  403. */
  404. parent: Nullable<Node>;
  405. private addToSceneRootNodes;
  406. private removeFromSceneRootNodes;
  407. private _animationPropertiesOverride;
  408. /**
  409. * Gets or sets the animation properties override
  410. */
  411. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  412. /**
  413. * Gets a string idenfifying the name of the class
  414. * @returns "Node" string
  415. */
  416. getClassName(): string;
  417. /**
  418. * An event triggered when the mesh is disposed
  419. */
  420. onDisposeObservable: Observable<Node>;
  421. private _onDisposeObserver;
  422. /**
  423. * Sets a callback that will be raised when the node will be disposed
  424. */
  425. onDispose: () => void;
  426. /**
  427. * Creates a new Node
  428. * @param name the name and id to be given to this node
  429. * @param scene the scene this node will be added to
  430. */
  431. constructor(name: string, scene?: Nullable<Scene>);
  432. /**
  433. * Gets the scene of the node
  434. * @returns a scene
  435. */
  436. getScene(): Scene;
  437. /**
  438. * Gets the engine of the node
  439. * @returns a Engine
  440. */
  441. getEngine(): Engine;
  442. private _behaviors;
  443. /**
  444. * Attach a behavior to the node
  445. * @see http://doc.babylonjs.com/features/behaviour
  446. * @param behavior defines the behavior to attach
  447. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  448. * @returns the current Node
  449. */
  450. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  451. /**
  452. * Remove an attached behavior
  453. * @see http://doc.babylonjs.com/features/behaviour
  454. * @param behavior defines the behavior to attach
  455. * @returns the current Node
  456. */
  457. removeBehavior(behavior: Behavior<Node>): Node;
  458. /**
  459. * Gets the list of attached behaviors
  460. * @see http://doc.babylonjs.com/features/behaviour
  461. */
  462. readonly behaviors: Behavior<Node>[];
  463. /**
  464. * Gets an attached behavior by name
  465. * @param name defines the name of the behavior to look for
  466. * @see http://doc.babylonjs.com/features/behaviour
  467. * @returns null if behavior was not found else the requested behavior
  468. */
  469. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  470. /**
  471. * Returns the latest update of the World matrix
  472. * @returns a Matrix
  473. */
  474. getWorldMatrix(): Matrix;
  475. /** @hidden */
  476. _getWorldMatrixDeterminant(): number;
  477. /**
  478. * Returns directly the latest state of the mesh World matrix.
  479. * A Matrix is returned.
  480. */
  481. readonly worldMatrixFromCache: Matrix;
  482. /** @hidden */
  483. _initCache(): void;
  484. /** @hidden */
  485. updateCache(force?: boolean): void;
  486. /** @hidden */
  487. _updateCache(ignoreParentClass?: boolean): void;
  488. /** @hidden */
  489. _isSynchronized(): boolean;
  490. /** @hidden */
  491. _markSyncedWithParent(): void;
  492. /** @hidden */
  493. isSynchronizedWithParent(): boolean;
  494. /** @hidden */
  495. isSynchronized(): boolean;
  496. /**
  497. * Is this node ready to be used/rendered
  498. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  499. * @return true if the node is ready
  500. */
  501. isReady(completeCheck?: boolean): boolean;
  502. /**
  503. * Is this node enabled?
  504. * 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
  505. * @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
  506. * @return whether this node (and its parent) is enabled
  507. */
  508. isEnabled(checkAncestors?: boolean): boolean;
  509. /** @hidden */
  510. protected _syncParentEnabledState(): void;
  511. /**
  512. * Set the enabled state of this node
  513. * @param value defines the new enabled state
  514. */
  515. setEnabled(value: boolean): void;
  516. /**
  517. * Is this node a descendant of the given node?
  518. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  519. * @param ancestor defines the parent node to inspect
  520. * @returns a boolean indicating if this node is a descendant of the given node
  521. */
  522. isDescendantOf(ancestor: Node): boolean;
  523. /** @hidden */
  524. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  525. /**
  526. * Will return all nodes that have this node as ascendant
  527. * @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
  528. * @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
  529. * @return all children nodes of all types
  530. */
  531. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  532. /**
  533. * Get all child-meshes of this node
  534. * @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
  535. * @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
  536. * @returns an array of AbstractMesh
  537. */
  538. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  539. /**
  540. * Get all child-transformNodes of this node
  541. * @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
  542. * @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
  543. * @returns an array of TransformNode
  544. */
  545. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  546. /**
  547. * Get all direct children of this node
  548. * @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
  549. * @returns an array of Node
  550. */
  551. getChildren(predicate?: (node: Node) => boolean): Node[];
  552. /** @hidden */
  553. _setReady(state: boolean): void;
  554. /**
  555. * Get an animation by name
  556. * @param name defines the name of the animation to look for
  557. * @returns null if not found else the requested animation
  558. */
  559. getAnimationByName(name: string): Nullable<Animation>;
  560. /**
  561. * Creates an animation range for this node
  562. * @param name defines the name of the range
  563. * @param from defines the starting key
  564. * @param to defines the end key
  565. */
  566. createAnimationRange(name: string, from: number, to: number): void;
  567. /**
  568. * Delete a specific animation range
  569. * @param name defines the name of the range to delete
  570. * @param deleteFrames defines if animation frames from the range must be deleted as well
  571. */
  572. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  573. /**
  574. * Get an animation range by name
  575. * @param name defines the name of the animation range to look for
  576. * @returns null if not found else the requested animation range
  577. */
  578. getAnimationRange(name: string): Nullable<AnimationRange>;
  579. /**
  580. * Will start the animation sequence
  581. * @param name defines the range frames for animation sequence
  582. * @param loop defines if the animation should loop (false by default)
  583. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  584. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  585. * @returns the object created for this animation. If range does not exist, it will return null
  586. */
  587. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  588. /**
  589. * Serialize animation ranges into a JSON compatible object
  590. * @returns serialization object
  591. */
  592. serializeAnimationRanges(): any;
  593. /**
  594. * Computes the world matrix of the node
  595. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  596. * @returns the world matrix
  597. */
  598. computeWorldMatrix(force?: boolean): Matrix;
  599. /**
  600. * Releases resources associated with this node.
  601. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  602. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  603. */
  604. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  605. /**
  606. * Parse animation range data from a serialization object and store them into a given node
  607. * @param node defines where to store the animation ranges
  608. * @param parsedNode defines the serialization object to read data from
  609. * @param scene defines the hosting scene
  610. */
  611. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  612. }
  613. }
  614. declare module BABYLON {
  615. /**
  616. * Define an interface for all classes that will hold resources
  617. */
  618. interface IDisposable {
  619. /**
  620. * Releases all held resources
  621. */
  622. dispose(): void;
  623. }
  624. /**
  625. * This class is used by the onRenderingGroupObservable
  626. */
  627. class RenderingGroupInfo {
  628. /**
  629. * The Scene that being rendered
  630. */
  631. scene: Scene;
  632. /**
  633. * The camera currently used for the rendering pass
  634. */
  635. camera: Nullable<Camera>;
  636. /**
  637. * The ID of the renderingGroup being processed
  638. */
  639. renderingGroupId: number;
  640. }
  641. /**
  642. * Represents a scene to be rendered by the engine.
  643. * @see http://doc.babylonjs.com/features/scene
  644. */
  645. class Scene extends AbstractScene implements IAnimatable {
  646. private static _uniqueIdCounter;
  647. /** The fog is deactivated */
  648. static readonly FOGMODE_NONE: number;
  649. /** The fog density is following an exponential function */
  650. static readonly FOGMODE_EXP: number;
  651. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  652. static readonly FOGMODE_EXP2: number;
  653. /** The fog density is following a linear function. */
  654. static readonly FOGMODE_LINEAR: number;
  655. /**
  656. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  657. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  658. */
  659. static MinDeltaTime: number;
  660. /**
  661. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  662. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  663. */
  664. static MaxDeltaTime: number;
  665. /**
  666. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  667. */
  668. autoClear: boolean;
  669. /**
  670. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  671. */
  672. autoClearDepthAndStencil: boolean;
  673. /**
  674. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  675. */
  676. clearColor: Color4;
  677. /**
  678. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  679. */
  680. ambientColor: Color3;
  681. /** @hidden */
  682. _environmentBRDFTexture: BaseTexture;
  683. /** @hidden */
  684. protected _environmentTexture: BaseTexture;
  685. /**
  686. * Texture used in all pbr material as the reflection texture.
  687. * As in the majority of the scene they are the same (exception for multi room and so on),
  688. * this is easier to reference from here than from all the materials.
  689. */
  690. /**
  691. * Texture used in all pbr material as the reflection texture.
  692. * As in the majority of the scene they are the same (exception for multi room and so on),
  693. * this is easier to set here than in all the materials.
  694. */
  695. environmentTexture: BaseTexture;
  696. /** @hidden */
  697. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  698. /**
  699. * Default image processing configuration used either in the rendering
  700. * Forward main pass or through the imageProcessingPostProcess if present.
  701. * As in the majority of the scene they are the same (exception for multi camera),
  702. * this is easier to reference from here than from all the materials and post process.
  703. *
  704. * No setter as we it is a shared configuration, you can set the values instead.
  705. */
  706. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  707. private _forceWireframe;
  708. /**
  709. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  710. */
  711. forceWireframe: boolean;
  712. private _forcePointsCloud;
  713. /**
  714. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  715. */
  716. forcePointsCloud: boolean;
  717. /**
  718. * Gets or sets the active clipplane 1
  719. */
  720. clipPlane: Nullable<Plane>;
  721. /**
  722. * Gets or sets the active clipplane 2
  723. */
  724. clipPlane2: Nullable<Plane>;
  725. /**
  726. * Gets or sets the active clipplane 3
  727. */
  728. clipPlane3: Nullable<Plane>;
  729. /**
  730. * Gets or sets the active clipplane 4
  731. */
  732. clipPlane4: Nullable<Plane>;
  733. /**
  734. * Gets or sets a boolean indicating if animations are enabled
  735. */
  736. animationsEnabled: boolean;
  737. private _animationPropertiesOverride;
  738. /**
  739. * Gets or sets the animation properties override
  740. */
  741. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  742. /**
  743. * Gets or sets a boolean indicating if a constant deltatime has to be used
  744. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  745. */
  746. useConstantAnimationDeltaTime: boolean;
  747. /**
  748. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  749. * Please note that it requires to run a ray cast through the scene on every frame
  750. */
  751. constantlyUpdateMeshUnderPointer: boolean;
  752. /**
  753. * Defines the HTML cursor to use when hovering over interactive elements
  754. */
  755. hoverCursor: string;
  756. /**
  757. * Defines the HTML default cursor to use (empty by default)
  758. */
  759. defaultCursor: string;
  760. /**
  761. * This is used to call preventDefault() on pointer down
  762. * in order to block unwanted artifacts like system double clicks
  763. */
  764. preventDefaultOnPointerDown: boolean;
  765. /**
  766. * Gets or sets user defined metadata
  767. */
  768. metadata: any;
  769. /**
  770. * Gets the name of the plugin used to load this scene (null by default)
  771. */
  772. loadingPluginName: string;
  773. /**
  774. * Use this array to add regular expressions used to disable offline support for specific urls
  775. */
  776. disableOfflineSupportExceptionRules: RegExp[];
  777. /**
  778. * An event triggered when the scene is disposed.
  779. */
  780. onDisposeObservable: Observable<Scene>;
  781. private _onDisposeObserver;
  782. /** Sets a function to be executed when this scene is disposed. */
  783. onDispose: () => void;
  784. /**
  785. * An event triggered before rendering the scene (right after animations and physics)
  786. */
  787. onBeforeRenderObservable: Observable<Scene>;
  788. private _onBeforeRenderObserver;
  789. /** Sets a function to be executed before rendering this scene */
  790. beforeRender: Nullable<() => void>;
  791. /**
  792. * An event triggered after rendering the scene
  793. */
  794. onAfterRenderObservable: Observable<Scene>;
  795. private _onAfterRenderObserver;
  796. /** Sets a function to be executed after rendering this scene */
  797. afterRender: Nullable<() => void>;
  798. /**
  799. * An event triggered before animating the scene
  800. */
  801. onBeforeAnimationsObservable: Observable<Scene>;
  802. /**
  803. * An event triggered after animations processing
  804. */
  805. onAfterAnimationsObservable: Observable<Scene>;
  806. /**
  807. * An event triggered before draw calls are ready to be sent
  808. */
  809. onBeforeDrawPhaseObservable: Observable<Scene>;
  810. /**
  811. * An event triggered after draw calls have been sent
  812. */
  813. onAfterDrawPhaseObservable: Observable<Scene>;
  814. /**
  815. * An event triggered when the scene is ready
  816. */
  817. onReadyObservable: Observable<Scene>;
  818. /**
  819. * An event triggered before rendering a camera
  820. */
  821. onBeforeCameraRenderObservable: Observable<Camera>;
  822. private _onBeforeCameraRenderObserver;
  823. /** Sets a function to be executed before rendering a camera*/
  824. beforeCameraRender: () => void;
  825. /**
  826. * An event triggered after rendering a camera
  827. */
  828. onAfterCameraRenderObservable: Observable<Camera>;
  829. private _onAfterCameraRenderObserver;
  830. /** Sets a function to be executed after rendering a camera*/
  831. afterCameraRender: () => void;
  832. /**
  833. * An event triggered when active meshes evaluation is about to start
  834. */
  835. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  836. /**
  837. * An event triggered when active meshes evaluation is done
  838. */
  839. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  840. /**
  841. * An event triggered when particles rendering is about to start
  842. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  843. */
  844. onBeforeParticlesRenderingObservable: Observable<Scene>;
  845. /**
  846. * An event triggered when particles rendering is done
  847. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  848. */
  849. onAfterParticlesRenderingObservable: Observable<Scene>;
  850. /**
  851. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  852. */
  853. onDataLoadedObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when a camera is created
  856. */
  857. onNewCameraAddedObservable: Observable<Camera>;
  858. /**
  859. * An event triggered when a camera is removed
  860. */
  861. onCameraRemovedObservable: Observable<Camera>;
  862. /**
  863. * An event triggered when a light is created
  864. */
  865. onNewLightAddedObservable: Observable<Light>;
  866. /**
  867. * An event triggered when a light is removed
  868. */
  869. onLightRemovedObservable: Observable<Light>;
  870. /**
  871. * An event triggered when a geometry is created
  872. */
  873. onNewGeometryAddedObservable: Observable<Geometry>;
  874. /**
  875. * An event triggered when a geometry is removed
  876. */
  877. onGeometryRemovedObservable: Observable<Geometry>;
  878. /**
  879. * An event triggered when a transform node is created
  880. */
  881. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  882. /**
  883. * An event triggered when a transform node is removed
  884. */
  885. onTransformNodeRemovedObservable: Observable<TransformNode>;
  886. /**
  887. * An event triggered when a mesh is created
  888. */
  889. onNewMeshAddedObservable: Observable<AbstractMesh>;
  890. /**
  891. * An event triggered when a mesh is removed
  892. */
  893. onMeshRemovedObservable: Observable<AbstractMesh>;
  894. /**
  895. * An event triggered when a material is created
  896. */
  897. onNewMaterialAddedObservable: Observable<Material>;
  898. /**
  899. * An event triggered when a material is removed
  900. */
  901. onMaterialRemovedObservable: Observable<Material>;
  902. /**
  903. * An event triggered when a texture is created
  904. */
  905. onNewTextureAddedObservable: Observable<BaseTexture>;
  906. /**
  907. * An event triggered when a texture is removed
  908. */
  909. onTextureRemovedObservable: Observable<BaseTexture>;
  910. /**
  911. * An event triggered when render targets are about to be rendered
  912. * Can happen multiple times per frame.
  913. */
  914. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  915. /**
  916. * An event triggered when render targets were rendered.
  917. * Can happen multiple times per frame.
  918. */
  919. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  920. /**
  921. * An event triggered before calculating deterministic simulation step
  922. */
  923. onBeforeStepObservable: Observable<Scene>;
  924. /**
  925. * An event triggered after calculating deterministic simulation step
  926. */
  927. onAfterStepObservable: Observable<Scene>;
  928. /**
  929. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  930. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  931. * 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)
  932. */
  933. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  934. /**
  935. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  936. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  937. * 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)
  938. */
  939. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  940. /**
  941. * This Observable will when a mesh has been imported into the scene.
  942. */
  943. onMeshImportedObservable: Observable<AbstractMesh>;
  944. private _registeredForLateAnimationBindings;
  945. /**
  946. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  947. */
  948. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  949. /**
  950. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  951. */
  952. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  953. /**
  954. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  955. */
  956. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  957. private _onPointerMove;
  958. private _onPointerDown;
  959. private _onPointerUp;
  960. /** Deprecated. Use onPointerObservable instead */
  961. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  962. /** Deprecated. Use onPointerObservable instead */
  963. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  964. /** Deprecated. Use onPointerObservable instead */
  965. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  966. /** Deprecated. Use onPointerObservable instead */
  967. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  968. /**
  969. * 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).
  970. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  971. */
  972. onPrePointerObservable: Observable<PointerInfoPre>;
  973. /**
  974. * Observable event triggered each time an input event is received from the rendering canvas
  975. */
  976. onPointerObservable: Observable<PointerInfo>;
  977. /**
  978. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  979. */
  980. readonly unTranslatedPointer: Vector2;
  981. /** The distance in pixel that you have to move to prevent some events */
  982. static DragMovementThreshold: number;
  983. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  984. static LongPressDelay: number;
  985. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  986. static DoubleClickDelay: number;
  987. /** If you need to check double click without raising a single click at first click, enable this flag */
  988. static ExclusiveDoubleClickMode: boolean;
  989. private _initClickEvent;
  990. private _initActionManager;
  991. private _delayedSimpleClick;
  992. private _delayedSimpleClickTimeout;
  993. private _previousDelayedSimpleClickTimeout;
  994. private _meshPickProceed;
  995. private _previousButtonPressed;
  996. private _currentPickResult;
  997. private _previousPickResult;
  998. private _totalPointersPressed;
  999. private _doubleClickOccured;
  1000. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1001. cameraToUseForPointers: Nullable<Camera>;
  1002. private _pointerX;
  1003. private _pointerY;
  1004. private _unTranslatedPointerX;
  1005. private _unTranslatedPointerY;
  1006. private _startingPointerPosition;
  1007. private _previousStartingPointerPosition;
  1008. private _startingPointerTime;
  1009. private _previousStartingPointerTime;
  1010. private _pointerCaptures;
  1011. private _timeAccumulator;
  1012. private _currentStepId;
  1013. private _currentInternalStep;
  1014. /** @hidden */
  1015. _mirroredCameraPosition: Nullable<Vector3>;
  1016. /**
  1017. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1018. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1019. */
  1020. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1021. /**
  1022. * Observable event triggered each time an keyboard event is received from the hosting window
  1023. */
  1024. onKeyboardObservable: Observable<KeyboardInfo>;
  1025. private _onKeyDown;
  1026. private _onKeyUp;
  1027. private _onCanvasFocusObserver;
  1028. private _onCanvasBlurObserver;
  1029. private _useRightHandedSystem;
  1030. /**
  1031. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1032. */
  1033. useRightHandedSystem: boolean;
  1034. /**
  1035. * Sets the step Id used by deterministic lock step
  1036. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1037. * @param newStepId defines the step Id
  1038. */
  1039. setStepId(newStepId: number): void;
  1040. /**
  1041. * Gets the step Id used by deterministic lock step
  1042. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1043. * @returns the step Id
  1044. */
  1045. getStepId(): number;
  1046. /**
  1047. * Gets the internal step used by deterministic lock step
  1048. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1049. * @returns the internal step
  1050. */
  1051. getInternalStep(): number;
  1052. private _fogEnabled;
  1053. /**
  1054. * Gets or sets a boolean indicating if fog is enabled on this scene
  1055. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1056. * (Default is true)
  1057. */
  1058. fogEnabled: boolean;
  1059. private _fogMode;
  1060. /**
  1061. * Gets or sets the fog mode to use
  1062. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1063. * | mode | value |
  1064. * | --- | --- |
  1065. * | FOGMODE_NONE | 0 |
  1066. * | FOGMODE_EXP | 1 |
  1067. * | FOGMODE_EXP2 | 2 |
  1068. * | FOGMODE_LINEAR | 3 |
  1069. */
  1070. fogMode: number;
  1071. /**
  1072. * Gets or sets the fog color to use
  1073. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1074. * (Default is Color3(0.2, 0.2, 0.3))
  1075. */
  1076. fogColor: Color3;
  1077. /**
  1078. * Gets or sets the fog density to use
  1079. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1080. * (Default is 0.1)
  1081. */
  1082. fogDensity: number;
  1083. /**
  1084. * Gets or sets the fog start distance to use
  1085. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1086. * (Default is 0)
  1087. */
  1088. fogStart: number;
  1089. /**
  1090. * Gets or sets the fog end distance to use
  1091. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1092. * (Default is 1000)
  1093. */
  1094. fogEnd: number;
  1095. private _shadowsEnabled;
  1096. /**
  1097. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1098. */
  1099. shadowsEnabled: boolean;
  1100. private _lightsEnabled;
  1101. /**
  1102. * Gets or sets a boolean indicating if lights are enabled on this scene
  1103. */
  1104. lightsEnabled: boolean;
  1105. /** All of the active cameras added to this scene. */
  1106. activeCameras: Camera[];
  1107. /** The current active camera */
  1108. activeCamera: Nullable<Camera>;
  1109. private _defaultMaterial;
  1110. /** The default material used on meshes when no material is affected */
  1111. /** The default material used on meshes when no material is affected */
  1112. defaultMaterial: Material;
  1113. private _texturesEnabled;
  1114. /**
  1115. * Gets or sets a boolean indicating if textures are enabled on this scene
  1116. */
  1117. texturesEnabled: boolean;
  1118. /**
  1119. * Gets or sets a boolean indicating if particles are enabled on this scene
  1120. */
  1121. particlesEnabled: boolean;
  1122. /**
  1123. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1124. */
  1125. spritesEnabled: boolean;
  1126. private _skeletonsEnabled;
  1127. /**
  1128. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1129. */
  1130. skeletonsEnabled: boolean;
  1131. /**
  1132. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1133. */
  1134. lensFlaresEnabled: boolean;
  1135. /**
  1136. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1137. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1138. */
  1139. collisionsEnabled: boolean;
  1140. private _workerCollisions;
  1141. /** @hidden */
  1142. collisionCoordinator: ICollisionCoordinator;
  1143. /**
  1144. * Defines the gravity applied to this scene (used only for collisions)
  1145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1146. */
  1147. gravity: Vector3;
  1148. /**
  1149. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1150. */
  1151. postProcessesEnabled: boolean;
  1152. /**
  1153. * The list of postprocesses added to the scene
  1154. */
  1155. postProcesses: PostProcess[];
  1156. /**
  1157. * Gets the current postprocess manager
  1158. */
  1159. postProcessManager: PostProcessManager;
  1160. /**
  1161. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1162. */
  1163. renderTargetsEnabled: boolean;
  1164. /**
  1165. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1166. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1167. */
  1168. dumpNextRenderTargets: boolean;
  1169. /**
  1170. * The list of user defined render targets added to the scene
  1171. */
  1172. customRenderTargets: RenderTargetTexture[];
  1173. /**
  1174. * Defines if texture loading must be delayed
  1175. * If true, textures will only be loaded when they need to be rendered
  1176. */
  1177. useDelayedTextureLoading: boolean;
  1178. /**
  1179. * Gets the list of meshes imported to the scene through SceneLoader
  1180. */
  1181. importedMeshesFiles: String[];
  1182. /**
  1183. * Gets or sets a boolean indicating if probes are enabled on this scene
  1184. */
  1185. probesEnabled: boolean;
  1186. /**
  1187. * @hidden
  1188. */
  1189. database: Database;
  1190. /**
  1191. * Gets or sets the action manager associated with the scene
  1192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1193. */
  1194. actionManager: ActionManager;
  1195. private _meshesForIntersections;
  1196. /**
  1197. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1198. */
  1199. proceduralTexturesEnabled: boolean;
  1200. private _engine;
  1201. private _totalVertices;
  1202. /** @hidden */
  1203. _activeIndices: PerfCounter;
  1204. /** @hidden */
  1205. _activeParticles: PerfCounter;
  1206. /** @hidden */
  1207. _activeBones: PerfCounter;
  1208. private _animationRatio;
  1209. private _animationTimeLast;
  1210. private _animationTime;
  1211. /**
  1212. * Gets or sets a general scale for animation speed
  1213. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1214. */
  1215. animationTimeScale: number;
  1216. /** @hidden */
  1217. _cachedMaterial: Nullable<Material>;
  1218. /** @hidden */
  1219. _cachedEffect: Nullable<Effect>;
  1220. /** @hidden */
  1221. _cachedVisibility: Nullable<number>;
  1222. private _renderId;
  1223. private _frameId;
  1224. private _executeWhenReadyTimeoutId;
  1225. private _intermediateRendering;
  1226. private _viewUpdateFlag;
  1227. private _projectionUpdateFlag;
  1228. private _alternateViewUpdateFlag;
  1229. private _alternateProjectionUpdateFlag;
  1230. /** @hidden */
  1231. _toBeDisposed: Nullable<IDisposable>[];
  1232. private _activeRequests;
  1233. private _pendingData;
  1234. private _isDisposed;
  1235. /**
  1236. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1237. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1238. */
  1239. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1240. private _activeMeshes;
  1241. private _processedMaterials;
  1242. private _renderTargets;
  1243. /** @hidden */
  1244. _activeParticleSystems: SmartArray<IParticleSystem>;
  1245. private _activeSkeletons;
  1246. private _softwareSkinnedMeshes;
  1247. private _renderingManager;
  1248. /** @hidden */
  1249. _activeAnimatables: Animatable[];
  1250. private _transformMatrix;
  1251. private _sceneUbo;
  1252. private _alternateSceneUbo;
  1253. private _pickWithRayInverseMatrix;
  1254. private _viewMatrix;
  1255. private _projectionMatrix;
  1256. private _alternateViewMatrix;
  1257. private _alternateProjectionMatrix;
  1258. private _alternateTransformMatrix;
  1259. private _useAlternateCameraConfiguration;
  1260. private _alternateRendering;
  1261. /** @hidden */
  1262. _forcedViewPosition: Nullable<Vector3>;
  1263. /** @hidden */
  1264. readonly _isAlternateRenderingEnabled: boolean;
  1265. private _frustumPlanes;
  1266. /**
  1267. * Gets the list of frustum planes (built from the active camera)
  1268. */
  1269. readonly frustumPlanes: Plane[];
  1270. /**
  1271. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1272. * This is useful if there are more lights that the maximum simulteanous authorized
  1273. */
  1274. requireLightSorting: boolean;
  1275. private _pointerOverMesh;
  1276. private _pickedDownMesh;
  1277. private _pickedUpMesh;
  1278. private _externalData;
  1279. private _uid;
  1280. /**
  1281. * @hidden
  1282. * Backing store of defined scene components.
  1283. */
  1284. _components: ISceneComponent[];
  1285. /**
  1286. * @hidden
  1287. * Backing store of defined scene components.
  1288. */
  1289. _serializableComponents: ISceneSerializableComponent[];
  1290. /**
  1291. * List of components to register on the next registration step.
  1292. */
  1293. private _transientComponents;
  1294. /**
  1295. * Registers the transient components if needed.
  1296. */
  1297. private _registerTransientComponents;
  1298. /**
  1299. * @hidden
  1300. * Add a component to the scene.
  1301. * Note that the ccomponent could be registered on th next frame if this is called after
  1302. * the register component stage.
  1303. * @param component Defines the component to add to the scene
  1304. */
  1305. _addComponent(component: ISceneComponent): void;
  1306. /**
  1307. * @hidden
  1308. * Gets a component from the scene.
  1309. * @param name defines the name of the component to retrieve
  1310. * @returns the component or null if not present
  1311. */
  1312. _getComponent(name: string): Nullable<ISceneComponent>;
  1313. /**
  1314. * @hidden
  1315. * Defines the actions happening before camera updates.
  1316. */
  1317. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1318. /**
  1319. * @hidden
  1320. * Defines the actions happening before clear the canvas.
  1321. */
  1322. _beforeClearStage: Stage<SimpleStageAction>;
  1323. /**
  1324. * @hidden
  1325. * Defines the actions when collecting render targets for the frame.
  1326. */
  1327. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1328. /**
  1329. * @hidden
  1330. * Defines the actions happening for one camera in the frame.
  1331. */
  1332. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1333. /**
  1334. * @hidden
  1335. * Defines the actions happening during the per mesh ready checks.
  1336. */
  1337. _isReadyForMeshStage: Stage<MeshStageAction>;
  1338. /**
  1339. * @hidden
  1340. * Defines the actions happening before evaluate active mesh checks.
  1341. */
  1342. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1343. /**
  1344. * @hidden
  1345. * Defines the actions happening during the evaluate sub mesh checks.
  1346. */
  1347. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1348. /**
  1349. * @hidden
  1350. * Defines the actions happening during the active mesh stage.
  1351. */
  1352. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1353. /**
  1354. * @hidden
  1355. * Defines the actions happening during the per camera render target step.
  1356. */
  1357. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1358. /**
  1359. * @hidden
  1360. * Defines the actions happening just before the active camera is drawing.
  1361. */
  1362. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1363. /**
  1364. * @hidden
  1365. * Defines the actions happening just before a rendering group is drawing.
  1366. */
  1367. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1368. /**
  1369. * @hidden
  1370. * Defines the actions happening just before a mesh is drawing.
  1371. */
  1372. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1373. /**
  1374. * @hidden
  1375. * Defines the actions happening just after a mesh has been drawn.
  1376. */
  1377. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1378. /**
  1379. * @hidden
  1380. * Defines the actions happening just after a rendering group has been drawn.
  1381. */
  1382. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1383. /**
  1384. * @hidden
  1385. * Defines the actions happening just after the active camera has been drawn.
  1386. */
  1387. _afterCameraDrawStage: Stage<CameraStageAction>;
  1388. /**
  1389. * @hidden
  1390. * Defines the actions happening just after rendering all cameras and computing intersections.
  1391. */
  1392. _afterRenderStage: Stage<SimpleStageAction>;
  1393. /**
  1394. * @hidden
  1395. * Defines the actions happening when a pointer move event happens.
  1396. */
  1397. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1398. /**
  1399. * @hidden
  1400. * Defines the actions happening when a pointer down event happens.
  1401. */
  1402. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1403. /**
  1404. * @hidden
  1405. * Defines the actions happening when a pointer up event happens.
  1406. */
  1407. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1408. /**
  1409. * Creates a new Scene
  1410. * @param engine defines the engine to use to render this scene
  1411. */
  1412. constructor(engine: Engine);
  1413. private _defaultMeshCandidates;
  1414. /**
  1415. * @hidden
  1416. */
  1417. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1418. private _defaultSubMeshCandidates;
  1419. /**
  1420. * @hidden
  1421. */
  1422. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1423. /**
  1424. * Sets the default candidate providers for the scene.
  1425. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1426. * and getCollidingSubMeshCandidates to their default function
  1427. */
  1428. setDefaultCandidateProviders(): void;
  1429. /**
  1430. * Gets a boolean indicating if collisions are processed on a web worker
  1431. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1432. */
  1433. workerCollisions: boolean;
  1434. /**
  1435. * Gets the mesh that is currently under the pointer
  1436. */
  1437. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1438. /**
  1439. * Gets the current on-screen X position of the pointer
  1440. */
  1441. readonly pointerX: number;
  1442. /**
  1443. * Gets the current on-screen Y position of the pointer
  1444. */
  1445. readonly pointerY: number;
  1446. /**
  1447. * Gets the cached material (ie. the latest rendered one)
  1448. * @returns the cached material
  1449. */
  1450. getCachedMaterial(): Nullable<Material>;
  1451. /**
  1452. * Gets the cached effect (ie. the latest rendered one)
  1453. * @returns the cached effect
  1454. */
  1455. getCachedEffect(): Nullable<Effect>;
  1456. /**
  1457. * Gets the cached visibility state (ie. the latest rendered one)
  1458. * @returns the cached visibility state
  1459. */
  1460. getCachedVisibility(): Nullable<number>;
  1461. /**
  1462. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1463. * @param material defines the current material
  1464. * @param effect defines the current effect
  1465. * @param visibility defines the current visibility state
  1466. * @returns true if one parameter is not cached
  1467. */
  1468. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1469. /**
  1470. * Gets the engine associated with the scene
  1471. * @returns an Engine
  1472. */
  1473. getEngine(): Engine;
  1474. /**
  1475. * Gets the total number of vertices rendered per frame
  1476. * @returns the total number of vertices rendered per frame
  1477. */
  1478. getTotalVertices(): number;
  1479. /**
  1480. * Gets the performance counter for total vertices
  1481. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1482. */
  1483. readonly totalVerticesPerfCounter: PerfCounter;
  1484. /**
  1485. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1486. * @returns the total number of active indices rendered per frame
  1487. */
  1488. getActiveIndices(): number;
  1489. /**
  1490. * Gets the performance counter for active indices
  1491. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1492. */
  1493. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1494. /**
  1495. * Gets the total number of active particles rendered per frame
  1496. * @returns the total number of active particles rendered per frame
  1497. */
  1498. getActiveParticles(): number;
  1499. /**
  1500. * Gets the performance counter for active particles
  1501. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1502. */
  1503. readonly activeParticlesPerfCounter: PerfCounter;
  1504. /**
  1505. * Gets the total number of active bones rendered per frame
  1506. * @returns the total number of active bones rendered per frame
  1507. */
  1508. getActiveBones(): number;
  1509. /**
  1510. * Gets the performance counter for active bones
  1511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1512. */
  1513. readonly activeBonesPerfCounter: PerfCounter;
  1514. /** @hidden */
  1515. getInterFramePerfCounter(): number;
  1516. /** @hidden */
  1517. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1518. /** @hidden */
  1519. getLastFrameDuration(): number;
  1520. /** @hidden */
  1521. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1522. /** @hidden */
  1523. getEvaluateActiveMeshesDuration(): number;
  1524. /** @hidden */
  1525. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1526. /**
  1527. * Gets the array of active meshes
  1528. * @returns an array of AbstractMesh
  1529. */
  1530. getActiveMeshes(): SmartArray<AbstractMesh>;
  1531. /** @hidden */
  1532. getRenderTargetsDuration(): number;
  1533. /** @hidden */
  1534. getRenderDuration(): number;
  1535. /** @hidden */
  1536. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1537. /** @hidden */
  1538. getParticlesDuration(): number;
  1539. /** @hidden */
  1540. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1541. /** @hidden */
  1542. getSpritesDuration(): number;
  1543. /** @hidden */
  1544. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1545. /**
  1546. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1547. * @returns a number
  1548. */
  1549. getAnimationRatio(): number;
  1550. /**
  1551. * Gets an unique Id for the current render phase
  1552. * @returns a number
  1553. */
  1554. getRenderId(): number;
  1555. /**
  1556. * Gets an unique Id for the current frame
  1557. * @returns a number
  1558. */
  1559. getFrameId(): number;
  1560. /** Call this function if you want to manually increment the render Id*/
  1561. incrementRenderId(): void;
  1562. private _updatePointerPosition;
  1563. private _createUbo;
  1564. private _createAlternateUbo;
  1565. private _setRayOnPointerInfo;
  1566. /**
  1567. * Use this method to simulate a pointer move on a mesh
  1568. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1569. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1570. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1571. * @returns the current scene
  1572. */
  1573. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1574. private _processPointerMove;
  1575. private _checkPrePointerObservable;
  1576. /**
  1577. * Use this method to simulate a pointer down on a mesh
  1578. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1579. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1580. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1581. * @returns the current scene
  1582. */
  1583. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1584. private _processPointerDown;
  1585. /**
  1586. * Use this method to simulate a pointer up on a mesh
  1587. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1588. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1589. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1590. * @returns the current scene
  1591. */
  1592. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1593. private _processPointerUp;
  1594. /**
  1595. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1596. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1597. * @returns true if the pointer was captured
  1598. */
  1599. isPointerCaptured(pointerId?: number): boolean;
  1600. /** @hidden */
  1601. _isPointerSwiping(): boolean;
  1602. /**
  1603. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1604. * @param attachUp defines if you want to attach events to pointerup
  1605. * @param attachDown defines if you want to attach events to pointerdown
  1606. * @param attachMove defines if you want to attach events to pointermove
  1607. */
  1608. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1609. /** Detaches all event handlers*/
  1610. detachControl(): void;
  1611. /**
  1612. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1613. * Delay loaded resources are not taking in account
  1614. * @return true if all required resources are ready
  1615. */
  1616. isReady(): boolean;
  1617. /** Resets all cached information relative to material (including effect and visibility) */
  1618. resetCachedMaterial(): void;
  1619. /**
  1620. * Registers a function to be called before every frame render
  1621. * @param func defines the function to register
  1622. */
  1623. registerBeforeRender(func: () => void): void;
  1624. /**
  1625. * Unregisters a function called before every frame render
  1626. * @param func defines the function to unregister
  1627. */
  1628. unregisterBeforeRender(func: () => void): void;
  1629. /**
  1630. * Registers a function to be called after every frame render
  1631. * @param func defines the function to register
  1632. */
  1633. registerAfterRender(func: () => void): void;
  1634. /**
  1635. * Unregisters a function called after every frame render
  1636. * @param func defines the function to unregister
  1637. */
  1638. unregisterAfterRender(func: () => void): void;
  1639. private _executeOnceBeforeRender;
  1640. /**
  1641. * The provided function will run before render once and will be disposed afterwards.
  1642. * A timeout delay can be provided so that the function will be executed in N ms.
  1643. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1644. * @param func The function to be executed.
  1645. * @param timeout optional delay in ms
  1646. */
  1647. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1648. /** @hidden */
  1649. _addPendingData(data: any): void;
  1650. /** @hidden */
  1651. _removePendingData(data: any): void;
  1652. /**
  1653. * Returns the number of items waiting to be loaded
  1654. * @returns the number of items waiting to be loaded
  1655. */
  1656. getWaitingItemsCount(): number;
  1657. /**
  1658. * Returns a boolean indicating if the scene is still loading data
  1659. */
  1660. readonly isLoading: boolean;
  1661. /**
  1662. * Registers a function to be executed when the scene is ready
  1663. * @param {Function} func - the function to be executed
  1664. */
  1665. executeWhenReady(func: () => void): void;
  1666. /**
  1667. * Returns a promise that resolves when the scene is ready
  1668. * @returns A promise that resolves when the scene is ready
  1669. */
  1670. whenReadyAsync(): Promise<void>;
  1671. /** @hidden */
  1672. _checkIsReady(): void;
  1673. /**
  1674. * Will start the animation sequence of a given target
  1675. * @param target defines the target
  1676. * @param from defines from which frame should animation start
  1677. * @param to defines until which frame should animation run.
  1678. * @param weight defines the weight to apply to the animation (1.0 by default)
  1679. * @param loop defines if the animation loops
  1680. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1681. * @param onAnimationEnd defines the function to be executed when the animation ends
  1682. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1683. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1684. * @returns the animatable object created for this animation
  1685. */
  1686. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1687. /**
  1688. * Will start the animation sequence of a given target
  1689. * @param target defines the target
  1690. * @param from defines from which frame should animation start
  1691. * @param to defines until which frame should animation run.
  1692. * @param loop defines if the animation loops
  1693. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1694. * @param onAnimationEnd defines the function to be executed when the animation ends
  1695. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1696. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1697. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1698. * @returns the animatable object created for this animation
  1699. */
  1700. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1701. /**
  1702. * Begin a new animation on a given node
  1703. * @param target defines the target where the animation will take place
  1704. * @param animations defines the list of animations to start
  1705. * @param from defines the initial value
  1706. * @param to defines the final value
  1707. * @param loop defines if you want animation to loop (off by default)
  1708. * @param speedRatio defines the speed ratio to apply to all animations
  1709. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1710. * @returns the list of created animatables
  1711. */
  1712. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1713. /**
  1714. * Begin a new animation on a given node and its hierarchy
  1715. * @param target defines the root node where the animation will take place
  1716. * @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.
  1717. * @param animations defines the list of animations to start
  1718. * @param from defines the initial value
  1719. * @param to defines the final value
  1720. * @param loop defines if you want animation to loop (off by default)
  1721. * @param speedRatio defines the speed ratio to apply to all animations
  1722. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1723. * @returns the list of animatables created for all nodes
  1724. */
  1725. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1726. /**
  1727. * Gets the animatable associated with a specific target
  1728. * @param target defines the target of the animatable
  1729. * @returns the required animatable if found
  1730. */
  1731. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1732. /**
  1733. * Gets all animatables associated with a given target
  1734. * @param target defines the target to look animatables for
  1735. * @returns an array of Animatables
  1736. */
  1737. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1738. /**
  1739. * Gets all animatable attached to the scene
  1740. */
  1741. readonly animatables: Animatable[];
  1742. /**
  1743. * Will stop the animation of the given target
  1744. * @param target - the target
  1745. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1746. * @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)
  1747. */
  1748. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1749. /**
  1750. * Stops and removes all animations that have been applied to the scene
  1751. */
  1752. stopAllAnimations(): void;
  1753. private _animate;
  1754. /** @hidden */
  1755. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1756. private _processLateAnimationBindingsForMatrices;
  1757. private _processLateAnimationBindingsForQuaternions;
  1758. private _processLateAnimationBindings;
  1759. /** @hidden */
  1760. _switchToAlternateCameraConfiguration(active: boolean): void;
  1761. /**
  1762. * Gets the current view matrix
  1763. * @returns a Matrix
  1764. */
  1765. getViewMatrix(): Matrix;
  1766. /**
  1767. * Gets the current projection matrix
  1768. * @returns a Matrix
  1769. */
  1770. getProjectionMatrix(): Matrix;
  1771. /**
  1772. * Gets the current transform matrix
  1773. * @returns a Matrix made of View * Projection
  1774. */
  1775. getTransformMatrix(): Matrix;
  1776. /**
  1777. * Sets the current transform matrix
  1778. * @param view defines the View matrix to use
  1779. * @param projection defines the Projection matrix to use
  1780. */
  1781. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1782. /** @hidden */
  1783. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1784. /**
  1785. * Gets the uniform buffer used to store scene data
  1786. * @returns a UniformBuffer
  1787. */
  1788. getSceneUniformBuffer(): UniformBuffer;
  1789. /**
  1790. * Gets an unique (relatively to the current scene) Id
  1791. * @returns an unique number for the scene
  1792. */
  1793. getUniqueId(): number;
  1794. /**
  1795. * Add a mesh to the list of scene's meshes
  1796. * @param newMesh defines the mesh to add
  1797. * @param recursive if all child meshes should also be added to the scene
  1798. */
  1799. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1800. /**
  1801. * Remove a mesh for the list of scene's meshes
  1802. * @param toRemove defines the mesh to remove
  1803. * @param recursive if all child meshes should also be removed from the scene
  1804. * @returns the index where the mesh was in the mesh list
  1805. */
  1806. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1807. /**
  1808. * Add a transform node to the list of scene's transform nodes
  1809. * @param newTransformNode defines the transform node to add
  1810. */
  1811. addTransformNode(newTransformNode: TransformNode): void;
  1812. /**
  1813. * Remove a transform node for the list of scene's transform nodes
  1814. * @param toRemove defines the transform node to remove
  1815. * @returns the index where the transform node was in the transform node list
  1816. */
  1817. removeTransformNode(toRemove: TransformNode): number;
  1818. /**
  1819. * Remove a skeleton for the list of scene's skeletons
  1820. * @param toRemove defines the skeleton to remove
  1821. * @returns the index where the skeleton was in the skeleton list
  1822. */
  1823. removeSkeleton(toRemove: Skeleton): number;
  1824. /**
  1825. * Remove a morph target for the list of scene's morph targets
  1826. * @param toRemove defines the morph target to remove
  1827. * @returns the index where the morph target was in the morph target list
  1828. */
  1829. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1830. /**
  1831. * Remove a light for the list of scene's lights
  1832. * @param toRemove defines the light to remove
  1833. * @returns the index where the light was in the light list
  1834. */
  1835. removeLight(toRemove: Light): number;
  1836. /**
  1837. * Remove a camera for the list of scene's cameras
  1838. * @param toRemove defines the camera to remove
  1839. * @returns the index where the camera was in the camera list
  1840. */
  1841. removeCamera(toRemove: Camera): number;
  1842. /**
  1843. * Remove a particle system for the list of scene's particle systems
  1844. * @param toRemove defines the particle system to remove
  1845. * @returns the index where the particle system was in the particle system list
  1846. */
  1847. removeParticleSystem(toRemove: IParticleSystem): number;
  1848. /**
  1849. * Remove a animation for the list of scene's animations
  1850. * @param toRemove defines the animation to remove
  1851. * @returns the index where the animation was in the animation list
  1852. */
  1853. removeAnimation(toRemove: Animation): number;
  1854. /**
  1855. * Removes the given animation group from this scene.
  1856. * @param toRemove The animation group to remove
  1857. * @returns The index of the removed animation group
  1858. */
  1859. removeAnimationGroup(toRemove: AnimationGroup): number;
  1860. /**
  1861. * Removes the given multi-material from this scene.
  1862. * @param toRemove The multi-material to remove
  1863. * @returns The index of the removed multi-material
  1864. */
  1865. removeMultiMaterial(toRemove: MultiMaterial): number;
  1866. /**
  1867. * Removes the given material from this scene.
  1868. * @param toRemove The material to remove
  1869. * @returns The index of the removed material
  1870. */
  1871. removeMaterial(toRemove: Material): number;
  1872. /**
  1873. * Removes the given action manager from this scene.
  1874. * @param toRemove The action manager to remove
  1875. * @returns The index of the removed action manager
  1876. */
  1877. removeActionManager(toRemove: ActionManager): number;
  1878. /**
  1879. * Removes the given texture from this scene.
  1880. * @param toRemove The texture to remove
  1881. * @returns The index of the removed texture
  1882. */
  1883. removeTexture(toRemove: BaseTexture): number;
  1884. /**
  1885. * Adds the given light to this scene
  1886. * @param newLight The light to add
  1887. */
  1888. addLight(newLight: Light): void;
  1889. /**
  1890. * Sorts the list list based on light priorities
  1891. */
  1892. sortLightsByPriority(): void;
  1893. /**
  1894. * Adds the given camera to this scene
  1895. * @param newCamera The camera to add
  1896. */
  1897. addCamera(newCamera: Camera): void;
  1898. /**
  1899. * Adds the given skeleton to this scene
  1900. * @param newSkeleton The skeleton to add
  1901. */
  1902. addSkeleton(newSkeleton: Skeleton): void;
  1903. /**
  1904. * Adds the given particle system to this scene
  1905. * @param newParticleSystem The particle system to add
  1906. */
  1907. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1908. /**
  1909. * Adds the given animation to this scene
  1910. * @param newAnimation The animation to add
  1911. */
  1912. addAnimation(newAnimation: Animation): void;
  1913. /**
  1914. * Adds the given animation group to this scene.
  1915. * @param newAnimationGroup The animation group to add
  1916. */
  1917. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1918. /**
  1919. * Adds the given multi-material to this scene
  1920. * @param newMultiMaterial The multi-material to add
  1921. */
  1922. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1923. /**
  1924. * Adds the given material to this scene
  1925. * @param newMaterial The material to add
  1926. */
  1927. addMaterial(newMaterial: Material): void;
  1928. /**
  1929. * Adds the given morph target to this scene
  1930. * @param newMorphTargetManager The morph target to add
  1931. */
  1932. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1933. /**
  1934. * Adds the given geometry to this scene
  1935. * @param newGeometry The geometry to add
  1936. */
  1937. addGeometry(newGeometry: Geometry): void;
  1938. /**
  1939. * Adds the given action manager to this scene
  1940. * @param newActionManager The action manager to add
  1941. */
  1942. addActionManager(newActionManager: ActionManager): void;
  1943. /**
  1944. * Adds the given texture to this scene.
  1945. * @param newTexture The texture to add
  1946. */
  1947. addTexture(newTexture: BaseTexture): void;
  1948. /**
  1949. * Switch active camera
  1950. * @param newCamera defines the new active camera
  1951. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1952. */
  1953. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1954. /**
  1955. * sets the active camera of the scene using its ID
  1956. * @param id defines the camera's ID
  1957. * @return the new active camera or null if none found.
  1958. */
  1959. setActiveCameraByID(id: string): Nullable<Camera>;
  1960. /**
  1961. * sets the active camera of the scene using its name
  1962. * @param name defines the camera's name
  1963. * @returns the new active camera or null if none found.
  1964. */
  1965. setActiveCameraByName(name: string): Nullable<Camera>;
  1966. /**
  1967. * get an animation group using its name
  1968. * @param name defines the material's name
  1969. * @return the animation group or null if none found.
  1970. */
  1971. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1972. /**
  1973. * get a material using its id
  1974. * @param id defines the material's ID
  1975. * @return the material or null if none found.
  1976. */
  1977. getMaterialByID(id: string): Nullable<Material>;
  1978. /**
  1979. * Gets a material using its name
  1980. * @param name defines the material's name
  1981. * @return the material or null if none found.
  1982. */
  1983. getMaterialByName(name: string): Nullable<Material>;
  1984. /**
  1985. * Gets a camera using its id
  1986. * @param id defines the id to look for
  1987. * @returns the camera or null if not found
  1988. */
  1989. getCameraByID(id: string): Nullable<Camera>;
  1990. /**
  1991. * Gets a camera using its unique id
  1992. * @param uniqueId defines the unique id to look for
  1993. * @returns the camera or null if not found
  1994. */
  1995. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1996. /**
  1997. * Gets a camera using its name
  1998. * @param name defines the camera's name
  1999. * @return the camera or null if none found.
  2000. */
  2001. getCameraByName(name: string): Nullable<Camera>;
  2002. /**
  2003. * Gets a bone using its id
  2004. * @param id defines the bone's id
  2005. * @return the bone or null if not found
  2006. */
  2007. getBoneByID(id: string): Nullable<Bone>;
  2008. /**
  2009. * Gets a bone using its id
  2010. * @param name defines the bone's name
  2011. * @return the bone or null if not found
  2012. */
  2013. getBoneByName(name: string): Nullable<Bone>;
  2014. /**
  2015. * Gets a light node using its name
  2016. * @param name defines the the light's name
  2017. * @return the light or null if none found.
  2018. */
  2019. getLightByName(name: string): Nullable<Light>;
  2020. /**
  2021. * Gets a light node using its id
  2022. * @param id defines the light's id
  2023. * @return the light or null if none found.
  2024. */
  2025. getLightByID(id: string): Nullable<Light>;
  2026. /**
  2027. * Gets a light node using its scene-generated unique ID
  2028. * @param uniqueId defines the light's unique id
  2029. * @return the light or null if none found.
  2030. */
  2031. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2032. /**
  2033. * Gets a particle system by id
  2034. * @param id defines the particle system id
  2035. * @return the corresponding system or null if none found
  2036. */
  2037. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2038. /**
  2039. * Gets a geometry using its ID
  2040. * @param id defines the geometry's id
  2041. * @return the geometry or null if none found.
  2042. */
  2043. getGeometryByID(id: string): Nullable<Geometry>;
  2044. /**
  2045. * Add a new geometry to this scene
  2046. * @param geometry defines the geometry to be added to the scene.
  2047. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2048. * @return a boolean defining if the geometry was added or not
  2049. */
  2050. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2051. /**
  2052. * Removes an existing geometry
  2053. * @param geometry defines the geometry to be removed from the scene
  2054. * @return a boolean defining if the geometry was removed or not
  2055. */
  2056. removeGeometry(geometry: Geometry): boolean;
  2057. /**
  2058. * Gets the list of geometries attached to the scene
  2059. * @returns an array of Geometry
  2060. */
  2061. getGeometries(): Geometry[];
  2062. /**
  2063. * Gets the first added mesh found of a given ID
  2064. * @param id defines the id to search for
  2065. * @return the mesh found or null if not found at all
  2066. */
  2067. getMeshByID(id: string): Nullable<AbstractMesh>;
  2068. /**
  2069. * Gets a list of meshes using their id
  2070. * @param id defines the id to search for
  2071. * @returns a list of meshes
  2072. */
  2073. getMeshesByID(id: string): Array<AbstractMesh>;
  2074. /**
  2075. * Gets the first added transform node found of a given ID
  2076. * @param id defines the id to search for
  2077. * @return the found transform node or null if not found at all.
  2078. */
  2079. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2080. /**
  2081. * Gets a list of transform nodes using their id
  2082. * @param id defines the id to search for
  2083. * @returns a list of transform nodes
  2084. */
  2085. getTransformNodesByID(id: string): Array<TransformNode>;
  2086. /**
  2087. * Gets a mesh with its auto-generated unique id
  2088. * @param uniqueId defines the unique id to search for
  2089. * @return the found mesh or null if not found at all.
  2090. */
  2091. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2092. /**
  2093. * Gets a the last added mesh using a given id
  2094. * @param id defines the id to search for
  2095. * @return the found mesh or null if not found at all.
  2096. */
  2097. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2098. /**
  2099. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2100. * @param id defines the id to search for
  2101. * @return the found node or null if not found at all
  2102. */
  2103. getLastEntryByID(id: string): Nullable<Node>;
  2104. /**
  2105. * Gets a node (Mesh, Camera, Light) using a given id
  2106. * @param id defines the id to search for
  2107. * @return the found node or null if not found at all
  2108. */
  2109. getNodeByID(id: string): Nullable<Node>;
  2110. /**
  2111. * Gets a node (Mesh, Camera, Light) using a given name
  2112. * @param name defines the name to search for
  2113. * @return the found node or null if not found at all.
  2114. */
  2115. getNodeByName(name: string): Nullable<Node>;
  2116. /**
  2117. * Gets a mesh using a given name
  2118. * @param name defines the name to search for
  2119. * @return the found mesh or null if not found at all.
  2120. */
  2121. getMeshByName(name: string): Nullable<AbstractMesh>;
  2122. /**
  2123. * Gets a transform node using a given name
  2124. * @param name defines the name to search for
  2125. * @return the found transform node or null if not found at all.
  2126. */
  2127. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2128. /**
  2129. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2130. * @param id defines the id to search for
  2131. * @return the found skeleton or null if not found at all.
  2132. */
  2133. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2134. /**
  2135. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2136. * @param id defines the id to search for
  2137. * @return the found skeleton or null if not found at all.
  2138. */
  2139. getSkeletonById(id: string): Nullable<Skeleton>;
  2140. /**
  2141. * Gets a skeleton using a given name
  2142. * @param name defines the name to search for
  2143. * @return the found skeleton or null if not found at all.
  2144. */
  2145. getSkeletonByName(name: string): Nullable<Skeleton>;
  2146. /**
  2147. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2148. * @param id defines the id to search for
  2149. * @return the found morph target manager or null if not found at all.
  2150. */
  2151. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2152. /**
  2153. * Gets a boolean indicating if the given mesh is active
  2154. * @param mesh defines the mesh to look for
  2155. * @returns true if the mesh is in the active list
  2156. */
  2157. isActiveMesh(mesh: AbstractMesh): boolean;
  2158. /**
  2159. * Return a unique id as a string which can serve as an identifier for the scene
  2160. */
  2161. readonly uid: string;
  2162. /**
  2163. * Add an externaly attached data from its key.
  2164. * This method call will fail and return false, if such key already exists.
  2165. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2166. * @param key the unique key that identifies the data
  2167. * @param data the data object to associate to the key for this Engine instance
  2168. * @return true if no such key were already present and the data was added successfully, false otherwise
  2169. */
  2170. addExternalData<T>(key: string, data: T): boolean;
  2171. /**
  2172. * Get an externaly attached data from its key
  2173. * @param key the unique key that identifies the data
  2174. * @return the associated data, if present (can be null), or undefined if not present
  2175. */
  2176. getExternalData<T>(key: string): Nullable<T>;
  2177. /**
  2178. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2179. * @param key the unique key that identifies the data
  2180. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2181. * @return the associated data, can be null if the factory returned null.
  2182. */
  2183. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2184. /**
  2185. * Remove an externaly attached data from the Engine instance
  2186. * @param key the unique key that identifies the data
  2187. * @return true if the data was successfully removed, false if it doesn't exist
  2188. */
  2189. removeExternalData(key: string): boolean;
  2190. private _evaluateSubMesh;
  2191. /**
  2192. * Clear the processed materials smart array preventing retention point in material dispose.
  2193. */
  2194. freeProcessedMaterials(): void;
  2195. /**
  2196. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2197. */
  2198. freeActiveMeshes(): void;
  2199. /**
  2200. * Clear the info related to rendering groups preventing retention points during dispose.
  2201. */
  2202. freeRenderingGroups(): void;
  2203. /** @hidden */
  2204. _isInIntermediateRendering(): boolean;
  2205. /**
  2206. * Lambda returning the list of potentially active meshes.
  2207. */
  2208. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2209. /**
  2210. * Lambda returning the list of potentially active sub meshes.
  2211. */
  2212. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2213. /**
  2214. * Lambda returning the list of potentially intersecting sub meshes.
  2215. */
  2216. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2217. /**
  2218. * Lambda returning the list of potentially colliding sub meshes.
  2219. */
  2220. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2221. private _activeMeshesFrozen;
  2222. /**
  2223. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2224. * @returns the current scene
  2225. */
  2226. freezeActiveMeshes(): Scene;
  2227. /**
  2228. * Use this function to restart evaluating active meshes on every frame
  2229. * @returns the current scene
  2230. */
  2231. unfreezeActiveMeshes(): Scene;
  2232. private _evaluateActiveMeshes;
  2233. private _activeMesh;
  2234. /**
  2235. * Update the transform matrix to update from the current active camera
  2236. * @param force defines a boolean used to force the update even if cache is up to date
  2237. */
  2238. updateTransformMatrix(force?: boolean): void;
  2239. /**
  2240. * 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)
  2241. * @param alternateCamera defines the camera to use
  2242. */
  2243. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2244. /** @hidden */
  2245. _allowPostProcessClearColor: boolean;
  2246. private _renderForCamera;
  2247. private _processSubCameras;
  2248. private _checkIntersections;
  2249. /** @hidden */
  2250. _advancePhysicsEngineStep(step: number): void;
  2251. /**
  2252. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2253. */
  2254. getDeterministicFrameTime: () => number;
  2255. /**
  2256. * Render the scene
  2257. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2258. */
  2259. render(updateCameras?: boolean): void;
  2260. /**
  2261. * Freeze all materials
  2262. * A frozen material will not be updatable but should be faster to render
  2263. */
  2264. freezeMaterials(): void;
  2265. /**
  2266. * Unfreeze all materials
  2267. * A frozen material will not be updatable but should be faster to render
  2268. */
  2269. unfreezeMaterials(): void;
  2270. /**
  2271. * Releases all held ressources
  2272. */
  2273. dispose(): void;
  2274. /**
  2275. * Gets if the scene is already disposed
  2276. */
  2277. readonly isDisposed: boolean;
  2278. /**
  2279. * Call this function to reduce memory footprint of the scene.
  2280. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2281. */
  2282. clearCachedVertexData(): void;
  2283. /**
  2284. * This function will remove the local cached buffer data from texture.
  2285. * It will save memory but will prevent the texture from being rebuilt
  2286. */
  2287. cleanCachedTextureBuffer(): void;
  2288. /**
  2289. * Get the world extend vectors with an optional filter
  2290. *
  2291. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2292. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2293. */
  2294. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2295. min: Vector3;
  2296. max: Vector3;
  2297. };
  2298. /**
  2299. * Creates a ray that can be used to pick in the scene
  2300. * @param x defines the x coordinate of the origin (on-screen)
  2301. * @param y defines the y coordinate of the origin (on-screen)
  2302. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2303. * @param camera defines the camera to use for the picking
  2304. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2305. * @returns a Ray
  2306. */
  2307. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2308. /**
  2309. * Creates a ray that can be used to pick in the scene
  2310. * @param x defines the x coordinate of the origin (on-screen)
  2311. * @param y defines the y coordinate of the origin (on-screen)
  2312. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2313. * @param result defines the ray where to store the picking ray
  2314. * @param camera defines the camera to use for the picking
  2315. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2316. * @returns the current scene
  2317. */
  2318. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2319. /**
  2320. * Creates a ray that can be used to pick in the scene
  2321. * @param x defines the x coordinate of the origin (on-screen)
  2322. * @param y defines the y coordinate of the origin (on-screen)
  2323. * @param camera defines the camera to use for the picking
  2324. * @returns a Ray
  2325. */
  2326. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2327. /**
  2328. * Creates a ray that can be used to pick in the scene
  2329. * @param x defines the x coordinate of the origin (on-screen)
  2330. * @param y defines the y coordinate of the origin (on-screen)
  2331. * @param result defines the ray where to store the picking ray
  2332. * @param camera defines the camera to use for the picking
  2333. * @returns the current scene
  2334. */
  2335. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2336. private _internalPick;
  2337. private _internalMultiPick;
  2338. private _tempPickingRay;
  2339. /** Launch a ray to try to pick a mesh in the scene
  2340. * @param x position on screen
  2341. * @param y position on screen
  2342. * @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
  2343. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2344. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2345. * @returns a PickingInfo
  2346. */
  2347. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2348. private _cachedRayForTransform;
  2349. /** Use the given ray to pick a mesh in the scene
  2350. * @param ray The ray to use to pick meshes
  2351. * @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
  2352. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2353. * @returns a PickingInfo
  2354. */
  2355. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2356. /**
  2357. * Launch a ray to try to pick a mesh in the scene
  2358. * @param x X position on screen
  2359. * @param y Y position on screen
  2360. * @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
  2361. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2362. * @returns an array of PickingInfo
  2363. */
  2364. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2365. /**
  2366. * Launch a ray to try to pick a mesh in the scene
  2367. * @param ray Ray to use
  2368. * @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
  2369. * @returns an array of PickingInfo
  2370. */
  2371. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2372. /**
  2373. * Force the value of meshUnderPointer
  2374. * @param mesh defines the mesh to use
  2375. */
  2376. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2377. /**
  2378. * Gets the mesh under the pointer
  2379. * @returns a Mesh or null if no mesh is under the pointer
  2380. */
  2381. getPointerOverMesh(): Nullable<AbstractMesh>;
  2382. /** @hidden */
  2383. _rebuildGeometries(): void;
  2384. /** @hidden */
  2385. _rebuildTextures(): void;
  2386. private _getByTags;
  2387. /**
  2388. * Get a list of meshes by tags
  2389. * @param tagsQuery defines the tags query to use
  2390. * @param forEach defines a predicate used to filter results
  2391. * @returns an array of Mesh
  2392. */
  2393. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2394. /**
  2395. * Get a list of cameras by tags
  2396. * @param tagsQuery defines the tags query to use
  2397. * @param forEach defines a predicate used to filter results
  2398. * @returns an array of Camera
  2399. */
  2400. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2401. /**
  2402. * Get a list of lights by tags
  2403. * @param tagsQuery defines the tags query to use
  2404. * @param forEach defines a predicate used to filter results
  2405. * @returns an array of Light
  2406. */
  2407. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2408. /**
  2409. * Get a list of materials by tags
  2410. * @param tagsQuery defines the tags query to use
  2411. * @param forEach defines a predicate used to filter results
  2412. * @returns an array of Material
  2413. */
  2414. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2415. /**
  2416. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2417. * This allowed control for front to back rendering or reversly depending of the special needs.
  2418. *
  2419. * @param renderingGroupId The rendering group id corresponding to its index
  2420. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2421. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2422. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2423. */
  2424. 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;
  2425. /**
  2426. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2427. *
  2428. * @param renderingGroupId The rendering group id corresponding to its index
  2429. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2430. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2431. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2432. */
  2433. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2434. /**
  2435. * Gets the current auto clear configuration for one rendering group of the rendering
  2436. * manager.
  2437. * @param index the rendering group index to get the information for
  2438. * @returns The auto clear setup for the requested rendering group
  2439. */
  2440. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2441. private _blockMaterialDirtyMechanism;
  2442. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2443. blockMaterialDirtyMechanism: boolean;
  2444. /**
  2445. * Will flag all materials as dirty to trigger new shader compilation
  2446. * @param flag defines the flag used to specify which material part must be marked as dirty
  2447. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2448. */
  2449. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2450. /** @hidden */
  2451. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useDatabase?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2452. /** @hidden */
  2453. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2454. }
  2455. }
  2456. declare module BABYLON {
  2457. /**
  2458. * Groups all the scene component constants in one place to ease maintenance.
  2459. * @hidden
  2460. */
  2461. class SceneComponentConstants {
  2462. static readonly NAME_EFFECTLAYER: string;
  2463. static readonly NAME_LAYER: string;
  2464. static readonly NAME_LENSFLARESYSTEM: string;
  2465. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2466. static readonly NAME_PARTICLESYSTEM: string;
  2467. static readonly NAME_GAMEPAD: string;
  2468. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2469. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2470. static readonly NAME_DEPTHRENDERER: string;
  2471. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2472. static readonly NAME_SPRITE: string;
  2473. static readonly NAME_OUTLINERENDERER: string;
  2474. static readonly NAME_PROCEDURALTEXTURE: string;
  2475. static readonly NAME_SHADOWGENERATOR: string;
  2476. static readonly NAME_OCTREE: string;
  2477. static readonly NAME_PHYSICSENGINE: string;
  2478. static readonly NAME_AUDIO: string;
  2479. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2480. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2481. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2482. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2483. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2484. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2485. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2486. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2487. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2488. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2489. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2490. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2491. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2492. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2493. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2494. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2495. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2496. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2497. static readonly STEP_AFTERRENDER_AUDIO: number;
  2498. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2499. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2500. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2501. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2502. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2503. static readonly STEP_POINTERMOVE_SPRITE: number;
  2504. static readonly STEP_POINTERDOWN_SPRITE: number;
  2505. static readonly STEP_POINTERUP_SPRITE: number;
  2506. }
  2507. /**
  2508. * This represents a scene component.
  2509. *
  2510. * This is used to decouple the dependency the scene is having on the different workloads like
  2511. * layers, post processes...
  2512. */
  2513. interface ISceneComponent {
  2514. /**
  2515. * The name of the component. Each component must have a unique name.
  2516. */
  2517. name: string;
  2518. /**
  2519. * The scene the component belongs to.
  2520. */
  2521. scene: Scene;
  2522. /**
  2523. * Register the component to one instance of a scene.
  2524. */
  2525. register(): void;
  2526. /**
  2527. * Rebuilds the elements related to this component in case of
  2528. * context lost for instance.
  2529. */
  2530. rebuild(): void;
  2531. /**
  2532. * Disposes the component and the associated ressources.
  2533. */
  2534. dispose(): void;
  2535. }
  2536. /**
  2537. * This represents a SERIALIZABLE scene component.
  2538. *
  2539. * This extends Scene Component to add Serialization methods on top.
  2540. */
  2541. interface ISceneSerializableComponent extends ISceneComponent {
  2542. /**
  2543. * Adds all the element from the container to the scene
  2544. * @param container the container holding the elements
  2545. */
  2546. addFromContainer(container: AbstractScene): void;
  2547. /**
  2548. * Removes all the elements in the container from the scene
  2549. * @param container contains the elements to remove
  2550. */
  2551. removeFromContainer(container: AbstractScene): void;
  2552. /**
  2553. * Serializes the component data to the specified json object
  2554. * @param serializationObject The object to serialize to
  2555. */
  2556. serialize(serializationObject: any): void;
  2557. }
  2558. /**
  2559. * Strong typing of a Mesh related stage step action
  2560. */
  2561. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2562. /**
  2563. * Strong typing of a Evaluate Sub Mesh related stage step action
  2564. */
  2565. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2566. /**
  2567. * Strong typing of a Active Mesh related stage step action
  2568. */
  2569. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2570. /**
  2571. * Strong typing of a Camera related stage step action
  2572. */
  2573. type CameraStageAction = (camera: Camera) => void;
  2574. /**
  2575. * Strong typing of a RenderingGroup related stage step action
  2576. */
  2577. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2578. /**
  2579. * Strong typing of a Mesh Render related stage step action
  2580. */
  2581. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2582. /**
  2583. * Strong typing of a simple stage step action
  2584. */
  2585. type SimpleStageAction = () => void;
  2586. /**
  2587. * Strong typing of a render target action.
  2588. */
  2589. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2590. /**
  2591. * Strong typing of a pointer move action.
  2592. */
  2593. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2594. /**
  2595. * Strong typing of a pointer up/down action.
  2596. */
  2597. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2598. /**
  2599. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2600. * @hidden
  2601. */
  2602. class Stage<T extends Function> extends Array<{
  2603. index: number;
  2604. component: ISceneComponent;
  2605. action: T;
  2606. }> {
  2607. /**
  2608. * Hide ctor from the rest of the world.
  2609. * @param items The items to add.
  2610. */
  2611. private constructor();
  2612. /**
  2613. * Creates a new Stage.
  2614. * @returns A new instance of a Stage
  2615. */
  2616. static Create<T extends Function>(): Stage<T>;
  2617. /**
  2618. * Registers a step in an ordered way in the targeted stage.
  2619. * @param index Defines the position to register the step in
  2620. * @param component Defines the component attached to the step
  2621. * @param action Defines the action to launch during the step
  2622. */
  2623. registerStep(index: number, component: ISceneComponent, action: T): void;
  2624. /**
  2625. * Clears all the steps from the stage.
  2626. */
  2627. clear(): void;
  2628. }
  2629. }
  2630. declare module BABYLON {
  2631. /** Alias type for value that can be null */
  2632. type Nullable<T> = T | null;
  2633. /**
  2634. * Alias type for number that are floats
  2635. * @ignorenaming
  2636. */
  2637. type float = number;
  2638. /**
  2639. * Alias type for number that are doubles.
  2640. * @ignorenaming
  2641. */
  2642. type double = number;
  2643. /**
  2644. * Alias type for number that are integer
  2645. * @ignorenaming
  2646. */
  2647. type int = number;
  2648. /** Alias type for number array or Float32Array */
  2649. type FloatArray = number[] | Float32Array;
  2650. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2651. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2652. /**
  2653. * Alias for types that can be used by a Buffer or VertexBuffer.
  2654. */
  2655. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2656. }
  2657. declare module BABYLON {
  2658. /**
  2659. * The action to be carried out following a trigger
  2660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2661. */
  2662. class Action {
  2663. /** the trigger, with or without parameters, for the action */
  2664. triggerOptions: any;
  2665. /**
  2666. * Trigger for the action
  2667. */
  2668. trigger: number;
  2669. /**
  2670. * Internal only - manager for action
  2671. * @hidden
  2672. */
  2673. _actionManager: ActionManager;
  2674. private _nextActiveAction;
  2675. private _child;
  2676. private _condition?;
  2677. private _triggerParameter;
  2678. /**
  2679. * An event triggered prior to action being executed.
  2680. */
  2681. onBeforeExecuteObservable: Observable<Action>;
  2682. /**
  2683. * Creates a new Action
  2684. * @param triggerOptions the trigger, with or without parameters, for the action
  2685. * @param condition an optional determinant of action
  2686. */
  2687. constructor(
  2688. /** the trigger, with or without parameters, for the action */
  2689. triggerOptions: any, condition?: Condition);
  2690. /**
  2691. * Internal only
  2692. * @hidden
  2693. */
  2694. _prepare(): void;
  2695. /**
  2696. * Gets the trigger parameters
  2697. * @returns the trigger parameters
  2698. */
  2699. getTriggerParameter(): any;
  2700. /**
  2701. * Internal only - executes current action event
  2702. * @hidden
  2703. */
  2704. _executeCurrent(evt?: ActionEvent): void;
  2705. /**
  2706. * Execute placeholder for child classes
  2707. * @param evt optional action event
  2708. */
  2709. execute(evt?: ActionEvent): void;
  2710. /**
  2711. * Skips to next active action
  2712. */
  2713. skipToNextActiveAction(): void;
  2714. /**
  2715. * Adds action to chain of actions, may be a DoNothingAction
  2716. * @param action defines the next action to execute
  2717. * @returns The action passed in
  2718. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2719. */
  2720. then(action: Action): Action;
  2721. /**
  2722. * Internal only
  2723. * @hidden
  2724. */
  2725. _getProperty(propertyPath: string): string;
  2726. /**
  2727. * Internal only
  2728. * @hidden
  2729. */
  2730. _getEffectiveTarget(target: any, propertyPath: string): any;
  2731. /**
  2732. * Serialize placeholder for child classes
  2733. * @param parent of child
  2734. * @returns the serialized object
  2735. */
  2736. serialize(parent: any): any;
  2737. /**
  2738. * Internal only called by serialize
  2739. * @hidden
  2740. */
  2741. protected _serialize(serializedAction: any, parent?: any): any;
  2742. /**
  2743. * Internal only
  2744. * @hidden
  2745. */
  2746. static _SerializeValueAsString: (value: any) => string;
  2747. /**
  2748. * Internal only
  2749. * @hidden
  2750. */
  2751. static _GetTargetProperty: (target: Scene | Node) => {
  2752. name: string;
  2753. targetType: string;
  2754. value: string;
  2755. };
  2756. }
  2757. }
  2758. declare module BABYLON {
  2759. /**
  2760. * ActionEvent is the event being sent when an action is triggered.
  2761. */
  2762. class ActionEvent {
  2763. /** The mesh or sprite that triggered the action */
  2764. source: any;
  2765. /** The X mouse cursor position at the time of the event */
  2766. pointerX: number;
  2767. /** The Y mouse cursor position at the time of the event */
  2768. pointerY: number;
  2769. /** The mesh that is currently pointed at (can be null) */
  2770. meshUnderPointer: Nullable<AbstractMesh>;
  2771. /** the original (browser) event that triggered the ActionEvent */
  2772. sourceEvent?: any;
  2773. /** additional data for the event */
  2774. additionalData?: any;
  2775. /**
  2776. * Creates a new ActionEvent
  2777. * @param source The mesh or sprite that triggered the action
  2778. * @param pointerX The X mouse cursor position at the time of the event
  2779. * @param pointerY The Y mouse cursor position at the time of the event
  2780. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2781. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2782. * @param additionalData additional data for the event
  2783. */
  2784. constructor(
  2785. /** The mesh or sprite that triggered the action */
  2786. source: any,
  2787. /** The X mouse cursor position at the time of the event */
  2788. pointerX: number,
  2789. /** The Y mouse cursor position at the time of the event */
  2790. pointerY: number,
  2791. /** The mesh that is currently pointed at (can be null) */
  2792. meshUnderPointer: Nullable<AbstractMesh>,
  2793. /** the original (browser) event that triggered the ActionEvent */
  2794. sourceEvent?: any,
  2795. /** additional data for the event */
  2796. additionalData?: any);
  2797. /**
  2798. * Helper function to auto-create an ActionEvent from a source mesh.
  2799. * @param source The source mesh that triggered the event
  2800. * @param evt The original (browser) event
  2801. * @param additionalData additional data for the event
  2802. * @returns the new ActionEvent
  2803. */
  2804. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2805. /**
  2806. * Helper function to auto-create an ActionEvent from a source sprite
  2807. * @param source The source sprite that triggered the event
  2808. * @param scene Scene associated with the sprite
  2809. * @param evt The original (browser) event
  2810. * @param additionalData additional data for the event
  2811. * @returns the new ActionEvent
  2812. */
  2813. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2814. /**
  2815. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2816. * @param scene the scene where the event occurred
  2817. * @param evt The original (browser) event
  2818. * @returns the new ActionEvent
  2819. */
  2820. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2821. /**
  2822. * Helper function to auto-create an ActionEvent from a primitive
  2823. * @param prim defines the target primitive
  2824. * @param pointerPos defines the pointer position
  2825. * @param evt The original (browser) event
  2826. * @param additionalData additional data for the event
  2827. * @returns the new ActionEvent
  2828. */
  2829. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2830. }
  2831. /**
  2832. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2833. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2835. */
  2836. class ActionManager {
  2837. /**
  2838. * Nothing
  2839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2840. */
  2841. static readonly NothingTrigger: number;
  2842. /**
  2843. * On pick
  2844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2845. */
  2846. static readonly OnPickTrigger: number;
  2847. /**
  2848. * On left pick
  2849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2850. */
  2851. static readonly OnLeftPickTrigger: number;
  2852. /**
  2853. * On right pick
  2854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2855. */
  2856. static readonly OnRightPickTrigger: number;
  2857. /**
  2858. * On center pick
  2859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2860. */
  2861. static readonly OnCenterPickTrigger: number;
  2862. /**
  2863. * On pick down
  2864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2865. */
  2866. static readonly OnPickDownTrigger: number;
  2867. /**
  2868. * On double pick
  2869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2870. */
  2871. static readonly OnDoublePickTrigger: number;
  2872. /**
  2873. * On pick up
  2874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2875. */
  2876. static readonly OnPickUpTrigger: number;
  2877. /**
  2878. * On pick out.
  2879. * This trigger will only be raised if you also declared a OnPickDown
  2880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2881. */
  2882. static readonly OnPickOutTrigger: number;
  2883. /**
  2884. * On long press
  2885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2886. */
  2887. static readonly OnLongPressTrigger: number;
  2888. /**
  2889. * On pointer over
  2890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2891. */
  2892. static readonly OnPointerOverTrigger: number;
  2893. /**
  2894. * On pointer out
  2895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2896. */
  2897. static readonly OnPointerOutTrigger: number;
  2898. /**
  2899. * On every frame
  2900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2901. */
  2902. static readonly OnEveryFrameTrigger: number;
  2903. /**
  2904. * On intersection enter
  2905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2906. */
  2907. static readonly OnIntersectionEnterTrigger: number;
  2908. /**
  2909. * On intersection exit
  2910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2911. */
  2912. static readonly OnIntersectionExitTrigger: number;
  2913. /**
  2914. * On key down
  2915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2916. */
  2917. static readonly OnKeyDownTrigger: number;
  2918. /**
  2919. * On key up
  2920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2921. */
  2922. static readonly OnKeyUpTrigger: number;
  2923. /** Gets the list of active triggers */
  2924. static Triggers: {
  2925. [key: string]: number;
  2926. };
  2927. /** Gets the list of actions */
  2928. actions: Action[];
  2929. /** Gets the cursor to use when hovering items */
  2930. hoverCursor: string;
  2931. private _scene;
  2932. /**
  2933. * Creates a new action manager
  2934. * @param scene defines the hosting scene
  2935. */
  2936. constructor(scene: Scene);
  2937. /**
  2938. * Releases all associated resources
  2939. */
  2940. dispose(): void;
  2941. /**
  2942. * Gets hosting scene
  2943. * @returns the hosting scene
  2944. */
  2945. getScene(): Scene;
  2946. /**
  2947. * Does this action manager handles actions of any of the given triggers
  2948. * @param triggers defines the triggers to be tested
  2949. * @return a boolean indicating whether one (or more) of the triggers is handled
  2950. */
  2951. hasSpecificTriggers(triggers: number[]): boolean;
  2952. /**
  2953. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  2954. * speed.
  2955. * @param triggerA defines the trigger to be tested
  2956. * @param triggerB defines the trigger to be tested
  2957. * @return a boolean indicating whether one (or more) of the triggers is handled
  2958. */
  2959. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  2960. /**
  2961. * Does this action manager handles actions of a given trigger
  2962. * @param trigger defines the trigger to be tested
  2963. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2964. * @return whether the trigger is handled
  2965. */
  2966. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2967. /**
  2968. * Does this action manager has pointer triggers
  2969. */
  2970. readonly hasPointerTriggers: boolean;
  2971. /**
  2972. * Does this action manager has pick triggers
  2973. */
  2974. readonly hasPickTriggers: boolean;
  2975. /**
  2976. * Does exist one action manager with at least one trigger
  2977. **/
  2978. static readonly HasTriggers: boolean;
  2979. /**
  2980. * Does exist one action manager with at least one pick trigger
  2981. **/
  2982. static readonly HasPickTriggers: boolean;
  2983. /**
  2984. * Does exist one action manager that handles actions of a given trigger
  2985. * @param trigger defines the trigger to be tested
  2986. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2987. **/
  2988. static HasSpecificTrigger(trigger: number): boolean;
  2989. /**
  2990. * Registers an action to this action manager
  2991. * @param action defines the action to be registered
  2992. * @return the action amended (prepared) after registration
  2993. */
  2994. registerAction(action: Action): Nullable<Action>;
  2995. /**
  2996. * Unregisters an action to this action manager
  2997. * @param action defines the action to be unregistered
  2998. * @return a boolean indicating whether the action has been unregistered
  2999. */
  3000. unregisterAction(action: Action): Boolean;
  3001. /**
  3002. * Process a specific trigger
  3003. * @param trigger defines the trigger to process
  3004. * @param evt defines the event details to be processed
  3005. */
  3006. processTrigger(trigger: number, evt?: ActionEvent): void;
  3007. /** @hidden */
  3008. _getEffectiveTarget(target: any, propertyPath: string): any;
  3009. /** @hidden */
  3010. _getProperty(propertyPath: string): string;
  3011. /**
  3012. * Serialize this manager to a JSON object
  3013. * @param name defines the property name to store this manager
  3014. * @returns a JSON representation of this manager
  3015. */
  3016. serialize(name: string): any;
  3017. /**
  3018. * Creates a new ActionManager from a JSON data
  3019. * @param parsedActions defines the JSON data to read from
  3020. * @param object defines the hosting mesh
  3021. * @param scene defines the hosting scene
  3022. */
  3023. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3024. /**
  3025. * Get a trigger name by index
  3026. * @param trigger defines the trigger index
  3027. * @returns a trigger name
  3028. */
  3029. static GetTriggerName(trigger: number): string;
  3030. }
  3031. }
  3032. declare module BABYLON {
  3033. /**
  3034. * A Condition applied to an Action
  3035. */
  3036. class Condition {
  3037. /**
  3038. * Internal only - manager for action
  3039. * @hidden
  3040. */
  3041. _actionManager: ActionManager;
  3042. /**
  3043. * Internal only
  3044. * @hidden
  3045. */
  3046. _evaluationId: number;
  3047. /**
  3048. * Internal only
  3049. * @hidden
  3050. */
  3051. _currentResult: boolean;
  3052. /**
  3053. * Creates a new Condition
  3054. * @param actionManager the manager of the action the condition is applied to
  3055. */
  3056. constructor(actionManager: ActionManager);
  3057. /**
  3058. * Check if the current condition is valid
  3059. * @returns a boolean
  3060. */
  3061. isValid(): boolean;
  3062. /**
  3063. * Internal only
  3064. * @hidden
  3065. */
  3066. _getProperty(propertyPath: string): string;
  3067. /**
  3068. * Internal only
  3069. * @hidden
  3070. */
  3071. _getEffectiveTarget(target: any, propertyPath: string): any;
  3072. /**
  3073. * Serialize placeholder for child classes
  3074. * @returns the serialized object
  3075. */
  3076. serialize(): any;
  3077. /**
  3078. * Internal only
  3079. * @hidden
  3080. */
  3081. protected _serialize(serializedCondition: any): any;
  3082. }
  3083. /**
  3084. * Defines specific conditional operators as extensions of Condition
  3085. */
  3086. class ValueCondition extends Condition {
  3087. /** path to specify the property of the target the conditional operator uses */
  3088. propertyPath: string;
  3089. /** the value compared by the conditional operator against the current value of the property */
  3090. value: any;
  3091. /** the conditional operator, default ValueCondition.IsEqual */
  3092. operator: number;
  3093. /**
  3094. * Internal only
  3095. * @hidden
  3096. */
  3097. private static _IsEqual;
  3098. /**
  3099. * Internal only
  3100. * @hidden
  3101. */
  3102. private static _IsDifferent;
  3103. /**
  3104. * Internal only
  3105. * @hidden
  3106. */
  3107. private static _IsGreater;
  3108. /**
  3109. * Internal only
  3110. * @hidden
  3111. */
  3112. private static _IsLesser;
  3113. /**
  3114. * returns the number for IsEqual
  3115. */
  3116. static readonly IsEqual: number;
  3117. /**
  3118. * Returns the number for IsDifferent
  3119. */
  3120. static readonly IsDifferent: number;
  3121. /**
  3122. * Returns the number for IsGreater
  3123. */
  3124. static readonly IsGreater: number;
  3125. /**
  3126. * Returns the number for IsLesser
  3127. */
  3128. static readonly IsLesser: number;
  3129. /**
  3130. * Internal only The action manager for the condition
  3131. * @hidden
  3132. */
  3133. _actionManager: ActionManager;
  3134. /**
  3135. * Internal only
  3136. * @hidden
  3137. */
  3138. private _target;
  3139. /**
  3140. * Internal only
  3141. * @hidden
  3142. */
  3143. private _effectiveTarget;
  3144. /**
  3145. * Internal only
  3146. * @hidden
  3147. */
  3148. private _property;
  3149. /**
  3150. * Creates a new ValueCondition
  3151. * @param actionManager manager for the action the condition applies to
  3152. * @param target for the action
  3153. * @param propertyPath path to specify the property of the target the conditional operator uses
  3154. * @param value the value compared by the conditional operator against the current value of the property
  3155. * @param operator the conditional operator, default ValueCondition.IsEqual
  3156. */
  3157. constructor(actionManager: ActionManager, target: any,
  3158. /** path to specify the property of the target the conditional operator uses */
  3159. propertyPath: string,
  3160. /** the value compared by the conditional operator against the current value of the property */
  3161. value: any,
  3162. /** the conditional operator, default ValueCondition.IsEqual */
  3163. operator?: number);
  3164. /**
  3165. * Compares the given value with the property value for the specified conditional operator
  3166. * @returns the result of the comparison
  3167. */
  3168. isValid(): boolean;
  3169. /**
  3170. * Serialize the ValueCondition into a JSON compatible object
  3171. * @returns serialization object
  3172. */
  3173. serialize(): any;
  3174. /**
  3175. * Gets the name of the conditional operator for the ValueCondition
  3176. * @param operator the conditional operator
  3177. * @returns the name
  3178. */
  3179. static GetOperatorName(operator: number): string;
  3180. }
  3181. /**
  3182. * Defines a predicate condition as an extension of Condition
  3183. */
  3184. class PredicateCondition extends Condition {
  3185. /** defines the predicate function used to validate the condition */
  3186. predicate: () => boolean;
  3187. /**
  3188. * Internal only - manager for action
  3189. * @hidden
  3190. */
  3191. _actionManager: ActionManager;
  3192. /**
  3193. * Creates a new PredicateCondition
  3194. * @param actionManager manager for the action the condition applies to
  3195. * @param predicate defines the predicate function used to validate the condition
  3196. */
  3197. constructor(actionManager: ActionManager,
  3198. /** defines the predicate function used to validate the condition */
  3199. predicate: () => boolean);
  3200. /**
  3201. * @returns the validity of the predicate condition
  3202. */
  3203. isValid(): boolean;
  3204. }
  3205. /**
  3206. * Defines a state condition as an extension of Condition
  3207. */
  3208. class StateCondition extends Condition {
  3209. /** Value to compare with target state */
  3210. value: string;
  3211. /**
  3212. * Internal only - manager for action
  3213. * @hidden
  3214. */
  3215. _actionManager: ActionManager;
  3216. /**
  3217. * Internal only
  3218. * @hidden
  3219. */
  3220. private _target;
  3221. /**
  3222. * Creates a new StateCondition
  3223. * @param actionManager manager for the action the condition applies to
  3224. * @param target of the condition
  3225. * @param value to compare with target state
  3226. */
  3227. constructor(actionManager: ActionManager, target: any,
  3228. /** Value to compare with target state */
  3229. value: string);
  3230. /**
  3231. * Gets a boolean indicating if the current condition is met
  3232. * @returns the validity of the state
  3233. */
  3234. isValid(): boolean;
  3235. /**
  3236. * Serialize the StateCondition into a JSON compatible object
  3237. * @returns serialization object
  3238. */
  3239. serialize(): any;
  3240. }
  3241. }
  3242. declare module BABYLON {
  3243. /**
  3244. * This defines an action responsible to toggle a boolean once triggered.
  3245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3246. */
  3247. class SwitchBooleanAction extends Action {
  3248. /**
  3249. * The path to the boolean property in the target object
  3250. */
  3251. propertyPath: string;
  3252. private _target;
  3253. private _effectiveTarget;
  3254. private _property;
  3255. /**
  3256. * Instantiate the action
  3257. * @param triggerOptions defines the trigger options
  3258. * @param target defines the object containing the boolean
  3259. * @param propertyPath defines the path to the boolean property in the target object
  3260. * @param condition defines the trigger related conditions
  3261. */
  3262. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3263. /** @hidden */
  3264. _prepare(): void;
  3265. /**
  3266. * Execute the action toggle the boolean value.
  3267. */
  3268. execute(): void;
  3269. /**
  3270. * Serializes the actions and its related information.
  3271. * @param parent defines the object to serialize in
  3272. * @returns the serialized object
  3273. */
  3274. serialize(parent: any): any;
  3275. }
  3276. /**
  3277. * This defines an action responsible to set a the state field of the target
  3278. * to a desired value once triggered.
  3279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3280. */
  3281. class SetStateAction extends Action {
  3282. /**
  3283. * The value to store in the state field.
  3284. */
  3285. value: string;
  3286. private _target;
  3287. /**
  3288. * Instantiate the action
  3289. * @param triggerOptions defines the trigger options
  3290. * @param target defines the object containing the state property
  3291. * @param value defines the value to store in the state field
  3292. * @param condition defines the trigger related conditions
  3293. */
  3294. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3295. /**
  3296. * Execute the action and store the value on the target state property.
  3297. */
  3298. execute(): void;
  3299. /**
  3300. * Serializes the actions and its related information.
  3301. * @param parent defines the object to serialize in
  3302. * @returns the serialized object
  3303. */
  3304. serialize(parent: any): any;
  3305. }
  3306. /**
  3307. * This defines an action responsible to set a property of the target
  3308. * to a desired value once triggered.
  3309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3310. */
  3311. class SetValueAction extends Action {
  3312. /**
  3313. * The path of the property to set in the target.
  3314. */
  3315. propertyPath: string;
  3316. /**
  3317. * The value to set in the property
  3318. */
  3319. value: any;
  3320. private _target;
  3321. private _effectiveTarget;
  3322. private _property;
  3323. /**
  3324. * Instantiate the action
  3325. * @param triggerOptions defines the trigger options
  3326. * @param target defines the object containing the property
  3327. * @param propertyPath defines the path of the property to set in the target
  3328. * @param value defines the value to set in the property
  3329. * @param condition defines the trigger related conditions
  3330. */
  3331. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3332. /** @hidden */
  3333. _prepare(): void;
  3334. /**
  3335. * Execute the action and set the targetted property to the desired value.
  3336. */
  3337. execute(): void;
  3338. /**
  3339. * Serializes the actions and its related information.
  3340. * @param parent defines the object to serialize in
  3341. * @returns the serialized object
  3342. */
  3343. serialize(parent: any): any;
  3344. }
  3345. /**
  3346. * This defines an action responsible to increment the target value
  3347. * to a desired value once triggered.
  3348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3349. */
  3350. class IncrementValueAction extends Action {
  3351. /**
  3352. * The path of the property to increment in the target.
  3353. */
  3354. propertyPath: string;
  3355. /**
  3356. * The value we should increment the property by.
  3357. */
  3358. value: any;
  3359. private _target;
  3360. private _effectiveTarget;
  3361. private _property;
  3362. /**
  3363. * Instantiate the action
  3364. * @param triggerOptions defines the trigger options
  3365. * @param target defines the object containing the property
  3366. * @param propertyPath defines the path of the property to increment in the target
  3367. * @param value defines the value value we should increment the property by
  3368. * @param condition defines the trigger related conditions
  3369. */
  3370. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3371. /** @hidden */
  3372. _prepare(): void;
  3373. /**
  3374. * Execute the action and increment the target of the value amount.
  3375. */
  3376. execute(): void;
  3377. /**
  3378. * Serializes the actions and its related information.
  3379. * @param parent defines the object to serialize in
  3380. * @returns the serialized object
  3381. */
  3382. serialize(parent: any): any;
  3383. }
  3384. /**
  3385. * This defines an action responsible to start an animation once triggered.
  3386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3387. */
  3388. class PlayAnimationAction extends Action {
  3389. /**
  3390. * Where the animation should start (animation frame)
  3391. */
  3392. from: number;
  3393. /**
  3394. * Where the animation should stop (animation frame)
  3395. */
  3396. to: number;
  3397. /**
  3398. * Define if the animation should loop or stop after the first play.
  3399. */
  3400. loop?: boolean;
  3401. private _target;
  3402. /**
  3403. * Instantiate the action
  3404. * @param triggerOptions defines the trigger options
  3405. * @param target defines the target animation or animation name
  3406. * @param from defines from where the animation should start (animation frame)
  3407. * @param end defines where the animation should stop (animation frame)
  3408. * @param loop defines if the animation should loop or stop after the first play
  3409. * @param condition defines the trigger related conditions
  3410. */
  3411. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3412. /** @hidden */
  3413. _prepare(): void;
  3414. /**
  3415. * Execute the action and play the animation.
  3416. */
  3417. execute(): void;
  3418. /**
  3419. * Serializes the actions and its related information.
  3420. * @param parent defines the object to serialize in
  3421. * @returns the serialized object
  3422. */
  3423. serialize(parent: any): any;
  3424. }
  3425. /**
  3426. * This defines an action responsible to stop an animation once triggered.
  3427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3428. */
  3429. class StopAnimationAction extends Action {
  3430. private _target;
  3431. /**
  3432. * Instantiate the action
  3433. * @param triggerOptions defines the trigger options
  3434. * @param target defines the target animation or animation name
  3435. * @param condition defines the trigger related conditions
  3436. */
  3437. constructor(triggerOptions: any, target: any, condition?: Condition);
  3438. /** @hidden */
  3439. _prepare(): void;
  3440. /**
  3441. * Execute the action and stop the animation.
  3442. */
  3443. execute(): void;
  3444. /**
  3445. * Serializes the actions and its related information.
  3446. * @param parent defines the object to serialize in
  3447. * @returns the serialized object
  3448. */
  3449. serialize(parent: any): any;
  3450. }
  3451. /**
  3452. * This defines an action responsible that does nothing once triggered.
  3453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3454. */
  3455. class DoNothingAction extends Action {
  3456. /**
  3457. * Instantiate the action
  3458. * @param triggerOptions defines the trigger options
  3459. * @param condition defines the trigger related conditions
  3460. */
  3461. constructor(triggerOptions?: any, condition?: Condition);
  3462. /**
  3463. * Execute the action and do nothing.
  3464. */
  3465. execute(): void;
  3466. /**
  3467. * Serializes the actions and its related information.
  3468. * @param parent defines the object to serialize in
  3469. * @returns the serialized object
  3470. */
  3471. serialize(parent: any): any;
  3472. }
  3473. /**
  3474. * This defines an action responsible to trigger several actions once triggered.
  3475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3476. */
  3477. class CombineAction extends Action {
  3478. /**
  3479. * The list of aggregated animations to run.
  3480. */
  3481. children: Action[];
  3482. /**
  3483. * Instantiate the action
  3484. * @param triggerOptions defines the trigger options
  3485. * @param children defines the list of aggregated animations to run
  3486. * @param condition defines the trigger related conditions
  3487. */
  3488. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3489. /** @hidden */
  3490. _prepare(): void;
  3491. /**
  3492. * Execute the action and executes all the aggregated actions.
  3493. */
  3494. execute(evt: ActionEvent): void;
  3495. /**
  3496. * Serializes the actions and its related information.
  3497. * @param parent defines the object to serialize in
  3498. * @returns the serialized object
  3499. */
  3500. serialize(parent: any): any;
  3501. }
  3502. /**
  3503. * This defines an action responsible to run code (external event) once triggered.
  3504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3505. */
  3506. class ExecuteCodeAction extends Action {
  3507. /**
  3508. * The callback function to run.
  3509. */
  3510. func: (evt: ActionEvent) => void;
  3511. /**
  3512. * Instantiate the action
  3513. * @param triggerOptions defines the trigger options
  3514. * @param func defines the callback function to run
  3515. * @param condition defines the trigger related conditions
  3516. */
  3517. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3518. /**
  3519. * Execute the action and run the attached code.
  3520. */
  3521. execute(evt: ActionEvent): void;
  3522. }
  3523. /**
  3524. * This defines an action responsible to set the parent property of the target once triggered.
  3525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3526. */
  3527. class SetParentAction extends Action {
  3528. private _parent;
  3529. private _target;
  3530. /**
  3531. * Instantiate the action
  3532. * @param triggerOptions defines the trigger options
  3533. * @param target defines the target containing the parent property
  3534. * @param parent defines from where the animation should start (animation frame)
  3535. * @param condition defines the trigger related conditions
  3536. */
  3537. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3538. /** @hidden */
  3539. _prepare(): void;
  3540. /**
  3541. * Execute the action and set the parent property.
  3542. */
  3543. execute(): void;
  3544. /**
  3545. * Serializes the actions and its related information.
  3546. * @param parent defines the object to serialize in
  3547. * @returns the serialized object
  3548. */
  3549. serialize(parent: any): any;
  3550. }
  3551. }
  3552. declare module BABYLON {
  3553. /**
  3554. * This defines an action helpful to play a defined sound on a triggered action.
  3555. */
  3556. class PlaySoundAction extends Action {
  3557. private _sound;
  3558. /**
  3559. * Instantiate the action
  3560. * @param triggerOptions defines the trigger options
  3561. * @param sound defines the sound to play
  3562. * @param condition defines the trigger related conditions
  3563. */
  3564. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3565. /** @hidden */
  3566. _prepare(): void;
  3567. /**
  3568. * Execute the action and play the sound.
  3569. */
  3570. execute(): void;
  3571. /**
  3572. * Serializes the actions and its related information.
  3573. * @param parent defines the object to serialize in
  3574. * @returns the serialized object
  3575. */
  3576. serialize(parent: any): any;
  3577. }
  3578. /**
  3579. * This defines an action helpful to stop a defined sound on a triggered action.
  3580. */
  3581. class StopSoundAction extends Action {
  3582. private _sound;
  3583. /**
  3584. * Instantiate the action
  3585. * @param triggerOptions defines the trigger options
  3586. * @param sound defines the sound to stop
  3587. * @param condition defines the trigger related conditions
  3588. */
  3589. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3590. /** @hidden */
  3591. _prepare(): void;
  3592. /**
  3593. * Execute the action and stop the sound.
  3594. */
  3595. execute(): void;
  3596. /**
  3597. * Serializes the actions and its related information.
  3598. * @param parent defines the object to serialize in
  3599. * @returns the serialized object
  3600. */
  3601. serialize(parent: any): any;
  3602. }
  3603. }
  3604. declare module BABYLON {
  3605. /**
  3606. * This defines an action responsible to change the value of a property
  3607. * by interpolating between its current value and the newly set one once triggered.
  3608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3609. */
  3610. class InterpolateValueAction extends Action {
  3611. /**
  3612. * Defines the path of the property where the value should be interpolated
  3613. */
  3614. propertyPath: string;
  3615. /**
  3616. * Defines the target value at the end of the interpolation.
  3617. */
  3618. value: any;
  3619. /**
  3620. * Defines the time it will take for the property to interpolate to the value.
  3621. */
  3622. duration: number;
  3623. /**
  3624. * Defines if the other scene animations should be stopped when the action has been triggered
  3625. */
  3626. stopOtherAnimations?: boolean;
  3627. /**
  3628. * Defines a callback raised once the interpolation animation has been done.
  3629. */
  3630. onInterpolationDone?: () => void;
  3631. /**
  3632. * Observable triggered once the interpolation animation has been done.
  3633. */
  3634. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3635. private _target;
  3636. private _effectiveTarget;
  3637. private _property;
  3638. /**
  3639. * Instantiate the action
  3640. * @param triggerOptions defines the trigger options
  3641. * @param target defines the object containing the value to interpolate
  3642. * @param propertyPath defines the path to the property in the target object
  3643. * @param value defines the target value at the end of the interpolation
  3644. * @param duration deines the time it will take for the property to interpolate to the value.
  3645. * @param condition defines the trigger related conditions
  3646. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3647. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3648. */
  3649. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3650. /** @hidden */
  3651. _prepare(): void;
  3652. /**
  3653. * Execute the action starts the value interpolation.
  3654. */
  3655. execute(): void;
  3656. /**
  3657. * Serializes the actions and its related information.
  3658. * @param parent defines the object to serialize in
  3659. * @returns the serialized object
  3660. */
  3661. serialize(parent: any): any;
  3662. }
  3663. }
  3664. declare module BABYLON {
  3665. /**
  3666. * Class used to store an actual running animation
  3667. */
  3668. class Animatable {
  3669. /** defines the target object */
  3670. target: any;
  3671. /** defines the starting frame number (default is 0) */
  3672. fromFrame: number;
  3673. /** defines the ending frame number (default is 100) */
  3674. toFrame: number;
  3675. /** defines if the animation must loop (default is false) */
  3676. loopAnimation: boolean;
  3677. /** defines a callback to call when animation ends if it is not looping */
  3678. onAnimationEnd?: (() => void) | null | undefined;
  3679. private _localDelayOffset;
  3680. private _pausedDelay;
  3681. private _runtimeAnimations;
  3682. private _paused;
  3683. private _scene;
  3684. private _speedRatio;
  3685. private _weight;
  3686. private _syncRoot;
  3687. /**
  3688. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3689. * This will only apply for non looping animation (default is true)
  3690. */
  3691. disposeOnEnd: boolean;
  3692. /**
  3693. * Gets a boolean indicating if the animation has started
  3694. */
  3695. animationStarted: boolean;
  3696. /**
  3697. * Observer raised when the animation ends
  3698. */
  3699. onAnimationEndObservable: Observable<Animatable>;
  3700. /**
  3701. * Gets the root Animatable used to synchronize and normalize animations
  3702. */
  3703. readonly syncRoot: Animatable;
  3704. /**
  3705. * Gets the current frame of the first RuntimeAnimation
  3706. * Used to synchronize Animatables
  3707. */
  3708. readonly masterFrame: number;
  3709. /**
  3710. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3711. */
  3712. weight: number;
  3713. /**
  3714. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3715. */
  3716. speedRatio: number;
  3717. /**
  3718. * Creates a new Animatable
  3719. * @param scene defines the hosting scene
  3720. * @param target defines the target object
  3721. * @param fromFrame defines the starting frame number (default is 0)
  3722. * @param toFrame defines the ending frame number (default is 100)
  3723. * @param loopAnimation defines if the animation must loop (default is false)
  3724. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3725. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3726. * @param animations defines a group of animation to add to the new Animatable
  3727. */
  3728. constructor(scene: Scene,
  3729. /** defines the target object */
  3730. target: any,
  3731. /** defines the starting frame number (default is 0) */
  3732. fromFrame?: number,
  3733. /** defines the ending frame number (default is 100) */
  3734. toFrame?: number,
  3735. /** defines if the animation must loop (default is false) */
  3736. loopAnimation?: boolean, speedRatio?: number,
  3737. /** defines a callback to call when animation ends if it is not looping */
  3738. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3739. /**
  3740. * Synchronize and normalize current Animatable with a source Animatable
  3741. * This is useful when using animation weights and when animations are not of the same length
  3742. * @param root defines the root Animatable to synchronize with
  3743. * @returns the current Animatable
  3744. */
  3745. syncWith(root: Animatable): Animatable;
  3746. /**
  3747. * Gets the list of runtime animations
  3748. * @returns an array of RuntimeAnimation
  3749. */
  3750. getAnimations(): RuntimeAnimation[];
  3751. /**
  3752. * Adds more animations to the current animatable
  3753. * @param target defines the target of the animations
  3754. * @param animations defines the new animations to add
  3755. */
  3756. appendAnimations(target: any, animations: Animation[]): void;
  3757. /**
  3758. * Gets the source animation for a specific property
  3759. * @param property defines the propertyu to look for
  3760. * @returns null or the source animation for the given property
  3761. */
  3762. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3763. /**
  3764. * Gets the runtime animation for a specific property
  3765. * @param property defines the propertyu to look for
  3766. * @returns null or the runtime animation for the given property
  3767. */
  3768. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3769. /**
  3770. * Resets the animatable to its original state
  3771. */
  3772. reset(): void;
  3773. /**
  3774. * Allows the animatable to blend with current running animations
  3775. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3776. * @param blendingSpeed defines the blending speed to use
  3777. */
  3778. enableBlending(blendingSpeed: number): void;
  3779. /**
  3780. * Disable animation blending
  3781. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3782. */
  3783. disableBlending(): void;
  3784. /**
  3785. * Jump directly to a given frame
  3786. * @param frame defines the frame to jump to
  3787. */
  3788. goToFrame(frame: number): void;
  3789. /**
  3790. * Pause the animation
  3791. */
  3792. pause(): void;
  3793. /**
  3794. * Restart the animation
  3795. */
  3796. restart(): void;
  3797. private _raiseOnAnimationEnd;
  3798. /**
  3799. * Stop and delete the current animation
  3800. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3801. * @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)
  3802. */
  3803. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3804. /**
  3805. * Wait asynchronously for the animation to end
  3806. * @returns a promise which will be fullfilled when the animation ends
  3807. */
  3808. waitAsync(): Promise<Animatable>;
  3809. /** @hidden */
  3810. _animate(delay: number): boolean;
  3811. }
  3812. }
  3813. declare module BABYLON {
  3814. /**
  3815. * Represents the range of an animation
  3816. */
  3817. class AnimationRange {
  3818. /**The name of the animation range**/
  3819. name: string;
  3820. /**The starting frame of the animation */
  3821. from: number;
  3822. /**The ending frame of the animation*/
  3823. to: number;
  3824. /**
  3825. * Initializes the range of an animation
  3826. * @param name The name of the animation range
  3827. * @param from The starting frame of the animation
  3828. * @param to The ending frame of the animation
  3829. */
  3830. constructor(
  3831. /**The name of the animation range**/
  3832. name: string,
  3833. /**The starting frame of the animation */
  3834. from: number,
  3835. /**The ending frame of the animation*/
  3836. to: number);
  3837. /**
  3838. * Makes a copy of the animation range
  3839. * @returns A copy of the animation range
  3840. */
  3841. clone(): AnimationRange;
  3842. }
  3843. /**
  3844. * Composed of a frame, and an action function
  3845. */
  3846. class AnimationEvent {
  3847. /** The frame for which the event is triggered **/
  3848. frame: number;
  3849. /** The event to perform when triggered **/
  3850. action: (currentFrame: number) => void;
  3851. /** Specifies if the event should be triggered only once**/
  3852. onlyOnce?: boolean | undefined;
  3853. /**
  3854. * Specifies if the animation event is done
  3855. */
  3856. isDone: boolean;
  3857. /**
  3858. * Initializes the animation event
  3859. * @param frame The frame for which the event is triggered
  3860. * @param action The event to perform when triggered
  3861. * @param onlyOnce Specifies if the event should be triggered only once
  3862. */
  3863. constructor(
  3864. /** The frame for which the event is triggered **/
  3865. frame: number,
  3866. /** The event to perform when triggered **/
  3867. action: (currentFrame: number) => void,
  3868. /** Specifies if the event should be triggered only once**/
  3869. onlyOnce?: boolean | undefined);
  3870. /** @hidden */
  3871. _clone(): AnimationEvent;
  3872. }
  3873. /**
  3874. * A cursor which tracks a point on a path
  3875. */
  3876. class PathCursor {
  3877. private path;
  3878. /**
  3879. * Stores path cursor callbacks for when an onchange event is triggered
  3880. */
  3881. private _onchange;
  3882. /**
  3883. * The value of the path cursor
  3884. */
  3885. value: number;
  3886. /**
  3887. * The animation array of the path cursor
  3888. */
  3889. animations: Animation[];
  3890. /**
  3891. * Initializes the path cursor
  3892. * @param path The path to track
  3893. */
  3894. constructor(path: Path2);
  3895. /**
  3896. * Gets the cursor point on the path
  3897. * @returns A point on the path cursor at the cursor location
  3898. */
  3899. getPoint(): Vector3;
  3900. /**
  3901. * Moves the cursor ahead by the step amount
  3902. * @param step The amount to move the cursor forward
  3903. * @returns This path cursor
  3904. */
  3905. moveAhead(step?: number): PathCursor;
  3906. /**
  3907. * Moves the cursor behind by the step amount
  3908. * @param step The amount to move the cursor back
  3909. * @returns This path cursor
  3910. */
  3911. moveBack(step?: number): PathCursor;
  3912. /**
  3913. * Moves the cursor by the step amount
  3914. * If the step amount is greater than one, an exception is thrown
  3915. * @param step The amount to move the cursor
  3916. * @returns This path cursor
  3917. */
  3918. move(step: number): PathCursor;
  3919. /**
  3920. * Ensures that the value is limited between zero and one
  3921. * @returns This path cursor
  3922. */
  3923. private ensureLimits;
  3924. /**
  3925. * Runs onchange callbacks on change (used by the animation engine)
  3926. * @returns This path cursor
  3927. */
  3928. private raiseOnChange;
  3929. /**
  3930. * Executes a function on change
  3931. * @param f A path cursor onchange callback
  3932. * @returns This path cursor
  3933. */
  3934. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3935. }
  3936. /**
  3937. * Defines an interface which represents an animation key frame
  3938. */
  3939. interface IAnimationKey {
  3940. /**
  3941. * Frame of the key frame
  3942. */
  3943. frame: number;
  3944. /**
  3945. * Value at the specifies key frame
  3946. */
  3947. value: any;
  3948. /**
  3949. * The input tangent for the cubic hermite spline
  3950. */
  3951. inTangent?: any;
  3952. /**
  3953. * The output tangent for the cubic hermite spline
  3954. */
  3955. outTangent?: any;
  3956. /**
  3957. * The animation interpolation type
  3958. */
  3959. interpolation?: AnimationKeyInterpolation;
  3960. }
  3961. /**
  3962. * Enum for the animation key frame interpolation type
  3963. */
  3964. enum AnimationKeyInterpolation {
  3965. /**
  3966. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3967. */
  3968. STEP = 1
  3969. }
  3970. /**
  3971. * Class used to store any kind of animation
  3972. */
  3973. class Animation {
  3974. /**Name of the animation */
  3975. name: string;
  3976. /**Property to animate */
  3977. targetProperty: string;
  3978. /**The frames per second of the animation */
  3979. framePerSecond: number;
  3980. /**The data type of the animation */
  3981. dataType: number;
  3982. /**The loop mode of the animation */
  3983. loopMode?: number | undefined;
  3984. /**Specifies if blending should be enabled */
  3985. enableBlending?: boolean | undefined;
  3986. /**
  3987. * Use matrix interpolation instead of using direct key value when animating matrices
  3988. */
  3989. static AllowMatricesInterpolation: boolean;
  3990. /**
  3991. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3992. */
  3993. static AllowMatrixDecomposeForInterpolation: boolean;
  3994. /**
  3995. * Stores the key frames of the animation
  3996. */
  3997. private _keys;
  3998. /**
  3999. * Stores the easing function of the animation
  4000. */
  4001. private _easingFunction;
  4002. /**
  4003. * @hidden Internal use only
  4004. */
  4005. _runtimeAnimations: RuntimeAnimation[];
  4006. /**
  4007. * The set of event that will be linked to this animation
  4008. */
  4009. private _events;
  4010. /**
  4011. * Stores an array of target property paths
  4012. */
  4013. targetPropertyPath: string[];
  4014. /**
  4015. * Stores the blending speed of the animation
  4016. */
  4017. blendingSpeed: number;
  4018. /**
  4019. * Stores the animation ranges for the animation
  4020. */
  4021. private _ranges;
  4022. /**
  4023. * @hidden Internal use
  4024. */
  4025. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4026. /**
  4027. * Sets up an animation
  4028. * @param property The property to animate
  4029. * @param animationType The animation type to apply
  4030. * @param framePerSecond The frames per second of the animation
  4031. * @param easingFunction The easing function used in the animation
  4032. * @returns The created animation
  4033. */
  4034. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4035. /**
  4036. * Create and start an animation on a node
  4037. * @param name defines the name of the global animation that will be run on all nodes
  4038. * @param node defines the root node where the animation will take place
  4039. * @param targetProperty defines property to animate
  4040. * @param framePerSecond defines the number of frame per second yo use
  4041. * @param totalFrame defines the number of frames in total
  4042. * @param from defines the initial value
  4043. * @param to defines the final value
  4044. * @param loopMode defines which loop mode you want to use (off by default)
  4045. * @param easingFunction defines the easing function to use (linear by default)
  4046. * @param onAnimationEnd defines the callback to call when animation end
  4047. * @returns the animatable created for this animation
  4048. */
  4049. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4050. /**
  4051. * Create and start an animation on a node and its descendants
  4052. * @param name defines the name of the global animation that will be run on all nodes
  4053. * @param node defines the root node where the animation will take place
  4054. * @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
  4055. * @param targetProperty defines property to animate
  4056. * @param framePerSecond defines the number of frame per second to use
  4057. * @param totalFrame defines the number of frames in total
  4058. * @param from defines the initial value
  4059. * @param to defines the final value
  4060. * @param loopMode defines which loop mode you want to use (off by default)
  4061. * @param easingFunction defines the easing function to use (linear by default)
  4062. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4063. * @returns the list of animatables created for all nodes
  4064. * @example https://www.babylonjs-playground.com/#MH0VLI
  4065. */
  4066. 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[]>;
  4067. /**
  4068. * Creates a new animation, merges it with the existing animations and starts it
  4069. * @param name Name of the animation
  4070. * @param node Node which contains the scene that begins the animations
  4071. * @param targetProperty Specifies which property to animate
  4072. * @param framePerSecond The frames per second of the animation
  4073. * @param totalFrame The total number of frames
  4074. * @param from The frame at the beginning of the animation
  4075. * @param to The frame at the end of the animation
  4076. * @param loopMode Specifies the loop mode of the animation
  4077. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4078. * @param onAnimationEnd Callback to run once the animation is complete
  4079. * @returns Nullable animation
  4080. */
  4081. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4082. /**
  4083. * Transition property of an host to the target Value
  4084. * @param property The property to transition
  4085. * @param targetValue The target Value of the property
  4086. * @param host The object where the property to animate belongs
  4087. * @param scene Scene used to run the animation
  4088. * @param frameRate Framerate (in frame/s) to use
  4089. * @param transition The transition type we want to use
  4090. * @param duration The duration of the animation, in milliseconds
  4091. * @param onAnimationEnd Callback trigger at the end of the animation
  4092. * @returns Nullable animation
  4093. */
  4094. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4095. /**
  4096. * Return the array of runtime animations currently using this animation
  4097. */
  4098. readonly runtimeAnimations: RuntimeAnimation[];
  4099. /**
  4100. * Specifies if any of the runtime animations are currently running
  4101. */
  4102. readonly hasRunningRuntimeAnimations: boolean;
  4103. /**
  4104. * Initializes the animation
  4105. * @param name Name of the animation
  4106. * @param targetProperty Property to animate
  4107. * @param framePerSecond The frames per second of the animation
  4108. * @param dataType The data type of the animation
  4109. * @param loopMode The loop mode of the animation
  4110. * @param enableBlendings Specifies if blending should be enabled
  4111. */
  4112. constructor(
  4113. /**Name of the animation */
  4114. name: string,
  4115. /**Property to animate */
  4116. targetProperty: string,
  4117. /**The frames per second of the animation */
  4118. framePerSecond: number,
  4119. /**The data type of the animation */
  4120. dataType: number,
  4121. /**The loop mode of the animation */
  4122. loopMode?: number | undefined,
  4123. /**Specifies if blending should be enabled */
  4124. enableBlending?: boolean | undefined);
  4125. /**
  4126. * Converts the animation to a string
  4127. * @param fullDetails support for multiple levels of logging within scene loading
  4128. * @returns String form of the animation
  4129. */
  4130. toString(fullDetails?: boolean): string;
  4131. /**
  4132. * Add an event to this animation
  4133. * @param event Event to add
  4134. */
  4135. addEvent(event: AnimationEvent): void;
  4136. /**
  4137. * Remove all events found at the given frame
  4138. * @param frame The frame to remove events from
  4139. */
  4140. removeEvents(frame: number): void;
  4141. /**
  4142. * Retrieves all the events from the animation
  4143. * @returns Events from the animation
  4144. */
  4145. getEvents(): AnimationEvent[];
  4146. /**
  4147. * Creates an animation range
  4148. * @param name Name of the animation range
  4149. * @param from Starting frame of the animation range
  4150. * @param to Ending frame of the animation
  4151. */
  4152. createRange(name: string, from: number, to: number): void;
  4153. /**
  4154. * Deletes an animation range by name
  4155. * @param name Name of the animation range to delete
  4156. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4157. */
  4158. deleteRange(name: string, deleteFrames?: boolean): void;
  4159. /**
  4160. * Gets the animation range by name, or null if not defined
  4161. * @param name Name of the animation range
  4162. * @returns Nullable animation range
  4163. */
  4164. getRange(name: string): Nullable<AnimationRange>;
  4165. /**
  4166. * Gets the key frames from the animation
  4167. * @returns The key frames of the animation
  4168. */
  4169. getKeys(): Array<IAnimationKey>;
  4170. /**
  4171. * Gets the highest frame rate of the animation
  4172. * @returns Highest frame rate of the animation
  4173. */
  4174. getHighestFrame(): number;
  4175. /**
  4176. * Gets the easing function of the animation
  4177. * @returns Easing function of the animation
  4178. */
  4179. getEasingFunction(): IEasingFunction;
  4180. /**
  4181. * Sets the easing function of the animation
  4182. * @param easingFunction A custom mathematical formula for animation
  4183. */
  4184. setEasingFunction(easingFunction: EasingFunction): void;
  4185. /**
  4186. * Interpolates a scalar linearly
  4187. * @param startValue Start value of the animation curve
  4188. * @param endValue End value of the animation curve
  4189. * @param gradient Scalar amount to interpolate
  4190. * @returns Interpolated scalar value
  4191. */
  4192. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4193. /**
  4194. * Interpolates a scalar cubically
  4195. * @param startValue Start value of the animation curve
  4196. * @param outTangent End tangent of the animation
  4197. * @param endValue End value of the animation curve
  4198. * @param inTangent Start tangent of the animation curve
  4199. * @param gradient Scalar amount to interpolate
  4200. * @returns Interpolated scalar value
  4201. */
  4202. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4203. /**
  4204. * Interpolates a quaternion using a spherical linear interpolation
  4205. * @param startValue Start value of the animation curve
  4206. * @param endValue End value of the animation curve
  4207. * @param gradient Scalar amount to interpolate
  4208. * @returns Interpolated quaternion value
  4209. */
  4210. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4211. /**
  4212. * Interpolates a quaternion cubically
  4213. * @param startValue Start value of the animation curve
  4214. * @param outTangent End tangent of the animation curve
  4215. * @param endValue End value of the animation curve
  4216. * @param inTangent Start tangent of the animation curve
  4217. * @param gradient Scalar amount to interpolate
  4218. * @returns Interpolated quaternion value
  4219. */
  4220. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4221. /**
  4222. * Interpolates a Vector3 linearl
  4223. * @param startValue Start value of the animation curve
  4224. * @param endValue End value of the animation curve
  4225. * @param gradient Scalar amount to interpolate
  4226. * @returns Interpolated scalar value
  4227. */
  4228. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4229. /**
  4230. * Interpolates a Vector3 cubically
  4231. * @param startValue Start value of the animation curve
  4232. * @param outTangent End tangent of the animation
  4233. * @param endValue End value of the animation curve
  4234. * @param inTangent Start tangent of the animation curve
  4235. * @param gradient Scalar amount to interpolate
  4236. * @returns InterpolatedVector3 value
  4237. */
  4238. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4239. /**
  4240. * Interpolates a Vector2 linearly
  4241. * @param startValue Start value of the animation curve
  4242. * @param endValue End value of the animation curve
  4243. * @param gradient Scalar amount to interpolate
  4244. * @returns Interpolated Vector2 value
  4245. */
  4246. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4247. /**
  4248. * Interpolates a Vector2 cubically
  4249. * @param startValue Start value of the animation curve
  4250. * @param outTangent End tangent of the animation
  4251. * @param endValue End value of the animation curve
  4252. * @param inTangent Start tangent of the animation curve
  4253. * @param gradient Scalar amount to interpolate
  4254. * @returns Interpolated Vector2 value
  4255. */
  4256. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4257. /**
  4258. * Interpolates a size linearly
  4259. * @param startValue Start value of the animation curve
  4260. * @param endValue End value of the animation curve
  4261. * @param gradient Scalar amount to interpolate
  4262. * @returns Interpolated Size value
  4263. */
  4264. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4265. /**
  4266. * Interpolates a Color3 linearly
  4267. * @param startValue Start value of the animation curve
  4268. * @param endValue End value of the animation curve
  4269. * @param gradient Scalar amount to interpolate
  4270. * @returns Interpolated Color3 value
  4271. */
  4272. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4273. /**
  4274. * @hidden Internal use only
  4275. */
  4276. _getKeyValue(value: any): any;
  4277. /**
  4278. * @hidden Internal use only
  4279. */
  4280. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4281. /**
  4282. * Defines the function to use to interpolate matrices
  4283. * @param startValue defines the start matrix
  4284. * @param endValue defines the end matrix
  4285. * @param gradient defines the gradient between both matrices
  4286. * @param result defines an optional target matrix where to store the interpolation
  4287. * @returns the interpolated matrix
  4288. */
  4289. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4290. /**
  4291. * Makes a copy of the animation
  4292. * @returns Cloned animation
  4293. */
  4294. clone(): Animation;
  4295. /**
  4296. * Sets the key frames of the animation
  4297. * @param values The animation key frames to set
  4298. */
  4299. setKeys(values: Array<IAnimationKey>): void;
  4300. /**
  4301. * Serializes the animation to an object
  4302. * @returns Serialized object
  4303. */
  4304. serialize(): any;
  4305. /**
  4306. * Float animation type
  4307. */
  4308. private static _ANIMATIONTYPE_FLOAT;
  4309. /**
  4310. * Vector3 animation type
  4311. */
  4312. private static _ANIMATIONTYPE_VECTOR3;
  4313. /**
  4314. * Quaternion animation type
  4315. */
  4316. private static _ANIMATIONTYPE_QUATERNION;
  4317. /**
  4318. * Matrix animation type
  4319. */
  4320. private static _ANIMATIONTYPE_MATRIX;
  4321. /**
  4322. * Color3 animation type
  4323. */
  4324. private static _ANIMATIONTYPE_COLOR3;
  4325. /**
  4326. * Vector2 animation type
  4327. */
  4328. private static _ANIMATIONTYPE_VECTOR2;
  4329. /**
  4330. * Size animation type
  4331. */
  4332. private static _ANIMATIONTYPE_SIZE;
  4333. /**
  4334. * Relative Loop Mode
  4335. */
  4336. private static _ANIMATIONLOOPMODE_RELATIVE;
  4337. /**
  4338. * Cycle Loop Mode
  4339. */
  4340. private static _ANIMATIONLOOPMODE_CYCLE;
  4341. /**
  4342. * Constant Loop Mode
  4343. */
  4344. private static _ANIMATIONLOOPMODE_CONSTANT;
  4345. /**
  4346. * Get the float animation type
  4347. */
  4348. static readonly ANIMATIONTYPE_FLOAT: number;
  4349. /**
  4350. * Get the Vector3 animation type
  4351. */
  4352. static readonly ANIMATIONTYPE_VECTOR3: number;
  4353. /**
  4354. * Get the Vector2 animation type
  4355. */
  4356. static readonly ANIMATIONTYPE_VECTOR2: number;
  4357. /**
  4358. * Get the Size animation type
  4359. */
  4360. static readonly ANIMATIONTYPE_SIZE: number;
  4361. /**
  4362. * Get the Quaternion animation type
  4363. */
  4364. static readonly ANIMATIONTYPE_QUATERNION: number;
  4365. /**
  4366. * Get the Matrix animation type
  4367. */
  4368. static readonly ANIMATIONTYPE_MATRIX: number;
  4369. /**
  4370. * Get the Color3 animation type
  4371. */
  4372. static readonly ANIMATIONTYPE_COLOR3: number;
  4373. /**
  4374. * Get the Relative Loop Mode
  4375. */
  4376. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4377. /**
  4378. * Get the Cycle Loop Mode
  4379. */
  4380. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4381. /**
  4382. * Get the Constant Loop Mode
  4383. */
  4384. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4385. /** @hidden */
  4386. static _UniversalLerp(left: any, right: any, amount: number): any;
  4387. /**
  4388. * Parses an animation object and creates an animation
  4389. * @param parsedAnimation Parsed animation object
  4390. * @returns Animation object
  4391. */
  4392. static Parse(parsedAnimation: any): Animation;
  4393. /**
  4394. * Appends the serialized animations from the source animations
  4395. * @param source Source containing the animations
  4396. * @param destination Target to store the animations
  4397. */
  4398. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4399. }
  4400. }
  4401. declare module BABYLON {
  4402. /**
  4403. * This class defines the direct association between an animation and a target
  4404. */
  4405. class TargetedAnimation {
  4406. /**
  4407. * Animation to perform
  4408. */
  4409. animation: Animation;
  4410. /**
  4411. * Target to animate
  4412. */
  4413. target: any;
  4414. }
  4415. /**
  4416. * Use this class to create coordinated animations on multiple targets
  4417. */
  4418. class AnimationGroup implements IDisposable {
  4419. /** The name of the animation group */
  4420. name: string;
  4421. private _scene;
  4422. private _targetedAnimations;
  4423. private _animatables;
  4424. private _from;
  4425. private _to;
  4426. private _isStarted;
  4427. private _speedRatio;
  4428. /**
  4429. * This observable will notify when one animation have ended.
  4430. */
  4431. onAnimationEndObservable: Observable<TargetedAnimation>;
  4432. /**
  4433. * This observable will notify when all animations have ended.
  4434. */
  4435. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4436. /**
  4437. * This observable will notify when all animations have paused.
  4438. */
  4439. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4440. /**
  4441. * Gets the first frame
  4442. */
  4443. readonly from: number;
  4444. /**
  4445. * Gets the last frame
  4446. */
  4447. readonly to: number;
  4448. /**
  4449. * Define if the animations are started
  4450. */
  4451. readonly isStarted: boolean;
  4452. /**
  4453. * Gets or sets the speed ratio to use for all animations
  4454. */
  4455. /**
  4456. * Gets or sets the speed ratio to use for all animations
  4457. */
  4458. speedRatio: number;
  4459. /**
  4460. * Gets the targeted animations for this animation group
  4461. */
  4462. readonly targetedAnimations: Array<TargetedAnimation>;
  4463. /**
  4464. * returning the list of animatables controlled by this animation group.
  4465. */
  4466. readonly animatables: Array<Animatable>;
  4467. /**
  4468. * Instantiates a new Animation Group.
  4469. * This helps managing several animations at once.
  4470. * @see http://doc.babylonjs.com/how_to/group
  4471. * @param name Defines the name of the group
  4472. * @param scene Defines the scene the group belongs to
  4473. */
  4474. constructor(
  4475. /** The name of the animation group */
  4476. name: string, scene?: Nullable<Scene>);
  4477. /**
  4478. * Add an animation (with its target) in the group
  4479. * @param animation defines the animation we want to add
  4480. * @param target defines the target of the animation
  4481. * @returns the TargetedAnimation object
  4482. */
  4483. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4484. /**
  4485. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4486. * It can add constant keys at begin or end
  4487. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4488. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4489. * @returns the animation group
  4490. */
  4491. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4492. /**
  4493. * Start all animations on given targets
  4494. * @param loop defines if animations must loop
  4495. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4496. * @param from defines the from key (optional)
  4497. * @param to defines the to key (optional)
  4498. * @returns the current animation group
  4499. */
  4500. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4501. /**
  4502. * Pause all animations
  4503. * @returns the animation group
  4504. */
  4505. pause(): AnimationGroup;
  4506. /**
  4507. * Play all animations to initial state
  4508. * This function will start() the animations if they were not started or will restart() them if they were paused
  4509. * @param loop defines if animations must loop
  4510. * @returns the animation group
  4511. */
  4512. play(loop?: boolean): AnimationGroup;
  4513. /**
  4514. * Reset all animations to initial state
  4515. * @returns the animation group
  4516. */
  4517. reset(): AnimationGroup;
  4518. /**
  4519. * Restart animations from key 0
  4520. * @returns the animation group
  4521. */
  4522. restart(): AnimationGroup;
  4523. /**
  4524. * Stop all animations
  4525. * @returns the animation group
  4526. */
  4527. stop(): AnimationGroup;
  4528. /**
  4529. * Set animation weight for all animatables
  4530. * @param weight defines the weight to use
  4531. * @return the animationGroup
  4532. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4533. */
  4534. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4535. /**
  4536. * Synchronize and normalize all animatables with a source animatable
  4537. * @param root defines the root animatable to synchronize with
  4538. * @return the animationGroup
  4539. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4540. */
  4541. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4542. /**
  4543. * Goes to a specific frame in this animation group
  4544. * @param frame the frame number to go to
  4545. * @return the animationGroup
  4546. */
  4547. goToFrame(frame: number): AnimationGroup;
  4548. /**
  4549. * Dispose all associated resources
  4550. */
  4551. dispose(): void;
  4552. private _checkAnimationGroupEnded;
  4553. /**
  4554. * Returns a new AnimationGroup object parsed from the source provided.
  4555. * @param parsedAnimationGroup defines the source
  4556. * @param scene defines the scene that will receive the animationGroup
  4557. * @returns a new AnimationGroup
  4558. */
  4559. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4560. /**
  4561. * Returns the string "AnimationGroup"
  4562. * @returns "AnimationGroup"
  4563. */
  4564. getClassName(): string;
  4565. /**
  4566. * Creates a detailled string about the object
  4567. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4568. * @returns a string representing the object
  4569. */
  4570. toString(fullDetails?: boolean): string;
  4571. }
  4572. }
  4573. declare module BABYLON {
  4574. /**
  4575. * Class used to override all child animations of a given target
  4576. */
  4577. class AnimationPropertiesOverride {
  4578. /**
  4579. * Gets or sets a value indicating if animation blending must be used
  4580. */
  4581. enableBlending: boolean;
  4582. /**
  4583. * Gets or sets the blending speed to use when enableBlending is true
  4584. */
  4585. blendingSpeed: number;
  4586. /**
  4587. * Gets or sets the default loop mode to use
  4588. */
  4589. loopMode: number;
  4590. }
  4591. }
  4592. declare module BABYLON {
  4593. /**
  4594. * This represents the main contract an easing function should follow.
  4595. * Easing functions are used throughout the animation system.
  4596. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4597. */
  4598. interface IEasingFunction {
  4599. /**
  4600. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4601. * of the easing function.
  4602. * The link below provides some of the most common examples of easing functions.
  4603. * @see https://easings.net/
  4604. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4605. * @returns the corresponding value on the curve defined by the easing function
  4606. */
  4607. ease(gradient: number): number;
  4608. }
  4609. /**
  4610. * Base class used for every default easing function.
  4611. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4612. */
  4613. class EasingFunction implements IEasingFunction {
  4614. /**
  4615. * Interpolation follows the mathematical formula associated with the easing function.
  4616. */
  4617. static readonly EASINGMODE_EASEIN: number;
  4618. /**
  4619. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4620. */
  4621. static readonly EASINGMODE_EASEOUT: number;
  4622. /**
  4623. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4624. */
  4625. static readonly EASINGMODE_EASEINOUT: number;
  4626. private _easingMode;
  4627. /**
  4628. * Sets the easing mode of the current function.
  4629. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4630. */
  4631. setEasingMode(easingMode: number): void;
  4632. /**
  4633. * Gets the current easing mode.
  4634. * @returns the easing mode
  4635. */
  4636. getEasingMode(): number;
  4637. /**
  4638. * @hidden
  4639. */
  4640. easeInCore(gradient: number): number;
  4641. /**
  4642. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4643. * of the easing function.
  4644. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4645. * @returns the corresponding value on the curve defined by the easing function
  4646. */
  4647. ease(gradient: number): number;
  4648. }
  4649. /**
  4650. * Easing function with a circle shape (see link below).
  4651. * @see https://easings.net/#easeInCirc
  4652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4653. */
  4654. class CircleEase extends EasingFunction implements IEasingFunction {
  4655. /** @hidden */
  4656. easeInCore(gradient: number): number;
  4657. }
  4658. /**
  4659. * Easing function with a ease back shape (see link below).
  4660. * @see https://easings.net/#easeInBack
  4661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4662. */
  4663. class BackEase extends EasingFunction implements IEasingFunction {
  4664. /** Defines the amplitude of the function */
  4665. amplitude: number;
  4666. /**
  4667. * Instantiates a back ease easing
  4668. * @see https://easings.net/#easeInBack
  4669. * @param amplitude Defines the amplitude of the function
  4670. */
  4671. constructor(
  4672. /** Defines the amplitude of the function */
  4673. amplitude?: number);
  4674. /** @hidden */
  4675. easeInCore(gradient: number): number;
  4676. }
  4677. /**
  4678. * Easing function with a bouncing shape (see link below).
  4679. * @see https://easings.net/#easeInBounce
  4680. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4681. */
  4682. class BounceEase extends EasingFunction implements IEasingFunction {
  4683. /** Defines the number of bounces */
  4684. bounces: number;
  4685. /** Defines the amplitude of the bounce */
  4686. bounciness: number;
  4687. /**
  4688. * Instantiates a bounce easing
  4689. * @see https://easings.net/#easeInBounce
  4690. * @param bounces Defines the number of bounces
  4691. * @param bounciness Defines the amplitude of the bounce
  4692. */
  4693. constructor(
  4694. /** Defines the number of bounces */
  4695. bounces?: number,
  4696. /** Defines the amplitude of the bounce */
  4697. bounciness?: number);
  4698. /** @hidden */
  4699. easeInCore(gradient: number): number;
  4700. }
  4701. /**
  4702. * Easing function with a power of 3 shape (see link below).
  4703. * @see https://easings.net/#easeInCubic
  4704. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4705. */
  4706. class CubicEase extends EasingFunction implements IEasingFunction {
  4707. /** @hidden */
  4708. easeInCore(gradient: number): number;
  4709. }
  4710. /**
  4711. * Easing function with an elastic shape (see link below).
  4712. * @see https://easings.net/#easeInElastic
  4713. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4714. */
  4715. class ElasticEase extends EasingFunction implements IEasingFunction {
  4716. /** Defines the number of oscillations*/
  4717. oscillations: number;
  4718. /** Defines the amplitude of the oscillations*/
  4719. springiness: number;
  4720. /**
  4721. * Instantiates an elastic easing function
  4722. * @see https://easings.net/#easeInElastic
  4723. * @param oscillations Defines the number of oscillations
  4724. * @param springiness Defines the amplitude of the oscillations
  4725. */
  4726. constructor(
  4727. /** Defines the number of oscillations*/
  4728. oscillations?: number,
  4729. /** Defines the amplitude of the oscillations*/
  4730. springiness?: number);
  4731. /** @hidden */
  4732. easeInCore(gradient: number): number;
  4733. }
  4734. /**
  4735. * Easing function with an exponential shape (see link below).
  4736. * @see https://easings.net/#easeInExpo
  4737. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4738. */
  4739. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4740. /** Defines the exponent of the function */
  4741. exponent: number;
  4742. /**
  4743. * Instantiates an exponential easing function
  4744. * @see https://easings.net/#easeInExpo
  4745. * @param exponent Defines the exponent of the function
  4746. */
  4747. constructor(
  4748. /** Defines the exponent of the function */
  4749. exponent?: number);
  4750. /** @hidden */
  4751. easeInCore(gradient: number): number;
  4752. }
  4753. /**
  4754. * Easing function with a power shape (see link below).
  4755. * @see https://easings.net/#easeInQuad
  4756. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4757. */
  4758. class PowerEase extends EasingFunction implements IEasingFunction {
  4759. /** Defines the power of the function */
  4760. power: number;
  4761. /**
  4762. * Instantiates an power base easing function
  4763. * @see https://easings.net/#easeInQuad
  4764. * @param power Defines the power of the function
  4765. */
  4766. constructor(
  4767. /** Defines the power of the function */
  4768. power?: number);
  4769. /** @hidden */
  4770. easeInCore(gradient: number): number;
  4771. }
  4772. /**
  4773. * Easing function with a power of 2 shape (see link below).
  4774. * @see https://easings.net/#easeInQuad
  4775. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4776. */
  4777. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4778. /** @hidden */
  4779. easeInCore(gradient: number): number;
  4780. }
  4781. /**
  4782. * Easing function with a power of 4 shape (see link below).
  4783. * @see https://easings.net/#easeInQuart
  4784. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4785. */
  4786. class QuarticEase extends EasingFunction implements IEasingFunction {
  4787. /** @hidden */
  4788. easeInCore(gradient: number): number;
  4789. }
  4790. /**
  4791. * Easing function with a power of 5 shape (see link below).
  4792. * @see https://easings.net/#easeInQuint
  4793. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4794. */
  4795. class QuinticEase extends EasingFunction implements IEasingFunction {
  4796. /** @hidden */
  4797. easeInCore(gradient: number): number;
  4798. }
  4799. /**
  4800. * Easing function with a sin shape (see link below).
  4801. * @see https://easings.net/#easeInSine
  4802. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4803. */
  4804. class SineEase extends EasingFunction implements IEasingFunction {
  4805. /** @hidden */
  4806. easeInCore(gradient: number): number;
  4807. }
  4808. /**
  4809. * Easing function with a bezier shape (see link below).
  4810. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4811. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4812. */
  4813. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4814. /** Defines the x component of the start tangent in the bezier curve */
  4815. x1: number;
  4816. /** Defines the y component of the start tangent in the bezier curve */
  4817. y1: number;
  4818. /** Defines the x component of the end tangent in the bezier curve */
  4819. x2: number;
  4820. /** Defines the y component of the end tangent in the bezier curve */
  4821. y2: number;
  4822. /**
  4823. * Instantiates a bezier function
  4824. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4825. * @param x1 Defines the x component of the start tangent in the bezier curve
  4826. * @param y1 Defines the y component of the start tangent in the bezier curve
  4827. * @param x2 Defines the x component of the end tangent in the bezier curve
  4828. * @param y2 Defines the y component of the end tangent in the bezier curve
  4829. */
  4830. constructor(
  4831. /** Defines the x component of the start tangent in the bezier curve */
  4832. x1?: number,
  4833. /** Defines the y component of the start tangent in the bezier curve */
  4834. y1?: number,
  4835. /** Defines the x component of the end tangent in the bezier curve */
  4836. x2?: number,
  4837. /** Defines the y component of the end tangent in the bezier curve */
  4838. y2?: number);
  4839. /** @hidden */
  4840. easeInCore(gradient: number): number;
  4841. }
  4842. }
  4843. declare module BABYLON {
  4844. /**
  4845. * Defines a runtime animation
  4846. */
  4847. class RuntimeAnimation {
  4848. private _events;
  4849. /**
  4850. * The current frame of the runtime animation
  4851. */
  4852. private _currentFrame;
  4853. /**
  4854. * The animation used by the runtime animation
  4855. */
  4856. private _animation;
  4857. /**
  4858. * The target of the runtime animation
  4859. */
  4860. private _target;
  4861. /**
  4862. * The initiating animatable
  4863. */
  4864. private _host;
  4865. /**
  4866. * The original value of the runtime animation
  4867. */
  4868. private _originalValue;
  4869. /**
  4870. * The original blend value of the runtime animation
  4871. */
  4872. private _originalBlendValue;
  4873. /**
  4874. * The offsets cache of the runtime animation
  4875. */
  4876. private _offsetsCache;
  4877. /**
  4878. * The high limits cache of the runtime animation
  4879. */
  4880. private _highLimitsCache;
  4881. /**
  4882. * Specifies if the runtime animation has been stopped
  4883. */
  4884. private _stopped;
  4885. /**
  4886. * The blending factor of the runtime animation
  4887. */
  4888. private _blendingFactor;
  4889. /**
  4890. * The BabylonJS scene
  4891. */
  4892. private _scene;
  4893. /**
  4894. * The current value of the runtime animation
  4895. */
  4896. private _currentValue;
  4897. /** @hidden */
  4898. _workValue: any;
  4899. /**
  4900. * The active target of the runtime animation
  4901. */
  4902. private _activeTarget;
  4903. /**
  4904. * The target path of the runtime animation
  4905. */
  4906. private _targetPath;
  4907. /**
  4908. * The weight of the runtime animation
  4909. */
  4910. private _weight;
  4911. /**
  4912. * The ratio offset of the runtime animation
  4913. */
  4914. private _ratioOffset;
  4915. /**
  4916. * The previous delay of the runtime animation
  4917. */
  4918. private _previousDelay;
  4919. /**
  4920. * The previous ratio of the runtime animation
  4921. */
  4922. private _previousRatio;
  4923. /**
  4924. * Gets the current frame of the runtime animation
  4925. */
  4926. readonly currentFrame: number;
  4927. /**
  4928. * Gets the weight of the runtime animation
  4929. */
  4930. readonly weight: number;
  4931. /**
  4932. * Gets the current value of the runtime animation
  4933. */
  4934. readonly currentValue: any;
  4935. /**
  4936. * Gets the target path of the runtime animation
  4937. */
  4938. readonly targetPath: string;
  4939. /**
  4940. * Gets the actual target of the runtime animation
  4941. */
  4942. readonly target: any;
  4943. /**
  4944. * Create a new RuntimeAnimation object
  4945. * @param target defines the target of the animation
  4946. * @param animation defines the source animation object
  4947. * @param scene defines the hosting scene
  4948. * @param host defines the initiating Animatable
  4949. */
  4950. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4951. /**
  4952. * Gets the animation from the runtime animation
  4953. */
  4954. readonly animation: Animation;
  4955. /**
  4956. * Resets the runtime animation to the beginning
  4957. * @param restoreOriginal defines whether to restore the target property to the original value
  4958. */
  4959. reset(restoreOriginal?: boolean): void;
  4960. /**
  4961. * Specifies if the runtime animation is stopped
  4962. * @returns Boolean specifying if the runtime animation is stopped
  4963. */
  4964. isStopped(): boolean;
  4965. /**
  4966. * Disposes of the runtime animation
  4967. */
  4968. dispose(): void;
  4969. /**
  4970. * Interpolates the animation from the current frame
  4971. * @param currentFrame The frame to interpolate the animation to
  4972. * @param repeatCount The number of times that the animation should loop
  4973. * @param loopMode The type of looping mode to use
  4974. * @param offsetValue Animation offset value
  4975. * @param highLimitValue The high limit value
  4976. * @returns The interpolated value
  4977. */
  4978. private _interpolate;
  4979. /**
  4980. * Apply the interpolated value to the target
  4981. * @param currentValue defines the value computed by the animation
  4982. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4983. */
  4984. setValue(currentValue: any, weight?: number): void;
  4985. private _setValue;
  4986. /**
  4987. * Gets the loop pmode of the runtime animation
  4988. * @returns Loop Mode
  4989. */
  4990. private _getCorrectLoopMode;
  4991. /**
  4992. * Move the current animation to a given frame
  4993. * @param frame defines the frame to move to
  4994. */
  4995. goToFrame(frame: number): void;
  4996. /**
  4997. * @hidden Internal use only
  4998. */
  4999. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5000. /**
  5001. * Execute the current animation
  5002. * @param delay defines the delay to add to the current frame
  5003. * @param from defines the lower bound of the animation range
  5004. * @param to defines the upper bound of the animation range
  5005. * @param loop defines if the current animation must loop
  5006. * @param speedRatio defines the current speed ratio
  5007. * @param weight defines the weight of the animation (default is -1 so no weight)
  5008. * @returns a boolean indicating if the animation is running
  5009. */
  5010. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5011. }
  5012. }
  5013. declare module BABYLON {
  5014. /**
  5015. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5017. */
  5018. class Analyser {
  5019. /**
  5020. * Gets or sets the smoothing
  5021. * @ignorenaming
  5022. */
  5023. SMOOTHING: number;
  5024. /**
  5025. * Gets or sets the FFT table size
  5026. * @ignorenaming
  5027. */
  5028. FFT_SIZE: number;
  5029. /**
  5030. * Gets or sets the bar graph amplitude
  5031. * @ignorenaming
  5032. */
  5033. BARGRAPHAMPLITUDE: number;
  5034. /**
  5035. * Gets or sets the position of the debug canvas
  5036. * @ignorenaming
  5037. */
  5038. DEBUGCANVASPOS: {
  5039. x: number;
  5040. y: number;
  5041. };
  5042. /**
  5043. * Gets or sets the debug canvas size
  5044. * @ignorenaming
  5045. */
  5046. DEBUGCANVASSIZE: {
  5047. width: number;
  5048. height: number;
  5049. };
  5050. private _byteFreqs;
  5051. private _byteTime;
  5052. private _floatFreqs;
  5053. private _webAudioAnalyser;
  5054. private _debugCanvas;
  5055. private _debugCanvasContext;
  5056. private _scene;
  5057. private _registerFunc;
  5058. private _audioEngine;
  5059. /**
  5060. * Creates a new analyser
  5061. * @param scene defines hosting scene
  5062. */
  5063. constructor(scene: Scene);
  5064. /**
  5065. * Get the number of data values you will have to play with for the visualization
  5066. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5067. * @returns a number
  5068. */
  5069. getFrequencyBinCount(): number;
  5070. /**
  5071. * Gets the current frequency data as a byte array
  5072. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5073. * @returns a Uint8Array
  5074. */
  5075. getByteFrequencyData(): Uint8Array;
  5076. /**
  5077. * Gets the current waveform as a byte array
  5078. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5079. * @returns a Uint8Array
  5080. */
  5081. getByteTimeDomainData(): Uint8Array;
  5082. /**
  5083. * Gets the current frequency data as a float array
  5084. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5085. * @returns a Float32Array
  5086. */
  5087. getFloatFrequencyData(): Float32Array;
  5088. /**
  5089. * Renders the debug canvas
  5090. */
  5091. drawDebugCanvas(): void;
  5092. /**
  5093. * Stops rendering the debug canvas and removes it
  5094. */
  5095. stopDebugCanvas(): void;
  5096. /**
  5097. * Connects two audio nodes
  5098. * @param inputAudioNode defines first node to connect
  5099. * @param outputAudioNode defines second node to connect
  5100. */
  5101. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5102. /**
  5103. * Releases all associated resources
  5104. */
  5105. dispose(): void;
  5106. }
  5107. }
  5108. declare module BABYLON {
  5109. /**
  5110. * This represents an audio engine and it is responsible
  5111. * to play, synchronize and analyse sounds throughout the application.
  5112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5113. */
  5114. interface IAudioEngine extends IDisposable {
  5115. /**
  5116. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5117. */
  5118. readonly canUseWebAudio: boolean;
  5119. /**
  5120. * Gets the current AudioContext if available.
  5121. */
  5122. readonly audioContext: Nullable<AudioContext>;
  5123. /**
  5124. * The master gain node defines the global audio volume of your audio engine.
  5125. */
  5126. readonly masterGain: GainNode;
  5127. /**
  5128. * Gets whether or not mp3 are supported by your browser.
  5129. */
  5130. readonly isMP3supported: boolean;
  5131. /**
  5132. * Gets whether or not ogg are supported by your browser.
  5133. */
  5134. readonly isOGGsupported: boolean;
  5135. /**
  5136. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5137. * @ignoreNaming
  5138. */
  5139. WarnedWebAudioUnsupported: boolean;
  5140. /**
  5141. * Defines if the audio engine relies on a custom unlocked button.
  5142. * In this case, the embedded button will not be displayed.
  5143. */
  5144. useCustomUnlockedButton: boolean;
  5145. /**
  5146. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5147. */
  5148. readonly unlocked: boolean;
  5149. /**
  5150. * Event raised when audio has been unlocked on the browser.
  5151. */
  5152. onAudioUnlockedObservable: Observable<AudioEngine>;
  5153. /**
  5154. * Event raised when audio has been locked on the browser.
  5155. */
  5156. onAudioLockedObservable: Observable<AudioEngine>;
  5157. /**
  5158. * Flags the audio engine in Locked state.
  5159. * This happens due to new browser policies preventing audio to autoplay.
  5160. */
  5161. lock(): void;
  5162. /**
  5163. * Unlocks the audio engine once a user action has been done on the dom.
  5164. * This is helpful to resume play once browser policies have been satisfied.
  5165. */
  5166. unlock(): void;
  5167. }
  5168. /**
  5169. * This represents the default audio engine used in babylon.
  5170. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5172. */
  5173. class AudioEngine implements IAudioEngine {
  5174. private _audioContext;
  5175. private _audioContextInitialized;
  5176. private _muteButton;
  5177. private _hostElement;
  5178. /**
  5179. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5180. */
  5181. canUseWebAudio: boolean;
  5182. /**
  5183. * The master gain node defines the global audio volume of your audio engine.
  5184. */
  5185. masterGain: GainNode;
  5186. /**
  5187. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5188. * @ignoreNaming
  5189. */
  5190. WarnedWebAudioUnsupported: boolean;
  5191. /**
  5192. * Gets whether or not mp3 are supported by your browser.
  5193. */
  5194. isMP3supported: boolean;
  5195. /**
  5196. * Gets whether or not ogg are supported by your browser.
  5197. */
  5198. isOGGsupported: boolean;
  5199. /**
  5200. * Gets whether audio has been unlocked on the device.
  5201. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5202. * a user interaction has happened.
  5203. */
  5204. unlocked: boolean;
  5205. /**
  5206. * Defines if the audio engine relies on a custom unlocked button.
  5207. * In this case, the embedded button will not be displayed.
  5208. */
  5209. useCustomUnlockedButton: boolean;
  5210. /**
  5211. * Event raised when audio has been unlocked on the browser.
  5212. */
  5213. onAudioUnlockedObservable: Observable<AudioEngine>;
  5214. /**
  5215. * Event raised when audio has been locked on the browser.
  5216. */
  5217. onAudioLockedObservable: Observable<AudioEngine>;
  5218. /**
  5219. * Gets the current AudioContext if available.
  5220. */
  5221. readonly audioContext: Nullable<AudioContext>;
  5222. private _connectedAnalyser;
  5223. /**
  5224. * Instantiates a new audio engine.
  5225. *
  5226. * There should be only one per page as some browsers restrict the number
  5227. * of audio contexts you can create.
  5228. * @param hostElement defines the host element where to display the mute icon if necessary
  5229. */
  5230. constructor(hostElement?: Nullable<HTMLElement>);
  5231. /**
  5232. * Flags the audio engine in Locked state.
  5233. * This happens due to new browser policies preventing audio to autoplay.
  5234. */
  5235. lock(): void;
  5236. /**
  5237. * Unlocks the audio engine once a user action has been done on the dom.
  5238. * This is helpful to resume play once browser policies have been satisfied.
  5239. */
  5240. unlock(): void;
  5241. private _resumeAudioContext;
  5242. private _initializeAudioContext;
  5243. private _tryToRun;
  5244. private _triggerRunningState;
  5245. private _triggerSuspendedState;
  5246. private _displayMuteButton;
  5247. private _moveButtonToTopLeft;
  5248. private _onResize;
  5249. private _hideMuteButton;
  5250. /**
  5251. * Destroy and release the resources associated with the audio ccontext.
  5252. */
  5253. dispose(): void;
  5254. /**
  5255. * Gets the global volume sets on the master gain.
  5256. * @returns the global volume if set or -1 otherwise
  5257. */
  5258. getGlobalVolume(): number;
  5259. /**
  5260. * Sets the global volume of your experience (sets on the master gain).
  5261. * @param newVolume Defines the new global volume of the application
  5262. */
  5263. setGlobalVolume(newVolume: number): void;
  5264. /**
  5265. * Connect the audio engine to an audio analyser allowing some amazing
  5266. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5268. * @param analyser The analyser to connect to the engine
  5269. */
  5270. connectToAnalyser(analyser: Analyser): void;
  5271. }
  5272. }
  5273. declare module BABYLON {
  5274. interface AbstractScene {
  5275. /**
  5276. * The list of sounds used in the scene.
  5277. */
  5278. sounds: Nullable<Array<Sound>>;
  5279. }
  5280. interface Scene {
  5281. /**
  5282. * @hidden
  5283. * Backing field
  5284. */
  5285. _mainSoundTrack: SoundTrack;
  5286. /**
  5287. * The main sound track played by the scene.
  5288. * It cotains your primary collection of sounds.
  5289. */
  5290. mainSoundTrack: SoundTrack;
  5291. /**
  5292. * The list of sound tracks added to the scene
  5293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5294. */
  5295. soundTracks: Nullable<Array<SoundTrack>>;
  5296. /**
  5297. * Gets a sound using a given name
  5298. * @param name defines the name to search for
  5299. * @return the found sound or null if not found at all.
  5300. */
  5301. getSoundByName(name: string): Nullable<Sound>;
  5302. /**
  5303. * Gets or sets if audio support is enabled
  5304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5305. */
  5306. audioEnabled: boolean;
  5307. /**
  5308. * Gets or sets if audio will be output to headphones
  5309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5310. */
  5311. headphone: boolean;
  5312. }
  5313. /**
  5314. * Defines the sound scene component responsible to manage any sounds
  5315. * in a given scene.
  5316. */
  5317. class AudioSceneComponent implements ISceneSerializableComponent {
  5318. /**
  5319. * The component name helpfull to identify the component in the list of scene components.
  5320. */
  5321. readonly name: string;
  5322. /**
  5323. * The scene the component belongs to.
  5324. */
  5325. scene: Scene;
  5326. private _audioEnabled;
  5327. /**
  5328. * Gets whether audio is enabled or not.
  5329. * Please use related enable/disable method to switch state.
  5330. */
  5331. readonly audioEnabled: boolean;
  5332. private _headphone;
  5333. /**
  5334. * Gets whether audio is outputing to headphone or not.
  5335. * Please use the according Switch methods to change output.
  5336. */
  5337. readonly headphone: boolean;
  5338. /**
  5339. * Creates a new instance of the component for the given scene
  5340. * @param scene Defines the scene to register the component in
  5341. */
  5342. constructor(scene: Scene);
  5343. /**
  5344. * Registers the component in a given scene
  5345. */
  5346. register(): void;
  5347. /**
  5348. * Rebuilds the elements related to this component in case of
  5349. * context lost for instance.
  5350. */
  5351. rebuild(): void;
  5352. /**
  5353. * Serializes the component data to the specified json object
  5354. * @param serializationObject The object to serialize to
  5355. */
  5356. serialize(serializationObject: any): void;
  5357. /**
  5358. * Adds all the element from the container to the scene
  5359. * @param container the container holding the elements
  5360. */
  5361. addFromContainer(container: AbstractScene): void;
  5362. /**
  5363. * Removes all the elements in the container from the scene
  5364. * @param container contains the elements to remove
  5365. */
  5366. removeFromContainer(container: AbstractScene): void;
  5367. /**
  5368. * Disposes the component and the associated ressources.
  5369. */
  5370. dispose(): void;
  5371. /**
  5372. * Disables audio in the associated scene.
  5373. */
  5374. disableAudio(): void;
  5375. /**
  5376. * Enables audio in the associated scene.
  5377. */
  5378. enableAudio(): void;
  5379. /**
  5380. * Switch audio to headphone output.
  5381. */
  5382. switchAudioModeForHeadphones(): void;
  5383. /**
  5384. * Switch audio to normal speakers.
  5385. */
  5386. switchAudioModeForNormalSpeakers(): void;
  5387. private _afterRender;
  5388. }
  5389. }
  5390. declare module BABYLON {
  5391. /**
  5392. * Defines a sound that can be played in the application.
  5393. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5395. */
  5396. class Sound {
  5397. /**
  5398. * The name of the sound in the scene.
  5399. */
  5400. name: string;
  5401. /**
  5402. * Does the sound autoplay once loaded.
  5403. */
  5404. autoplay: boolean;
  5405. /**
  5406. * Does the sound loop after it finishes playing once.
  5407. */
  5408. loop: boolean;
  5409. /**
  5410. * Does the sound use a custom attenuation curve to simulate the falloff
  5411. * happening when the source gets further away from the camera.
  5412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5413. */
  5414. useCustomAttenuation: boolean;
  5415. /**
  5416. * The sound track id this sound belongs to.
  5417. */
  5418. soundTrackId: number;
  5419. /**
  5420. * Is this sound currently played.
  5421. */
  5422. isPlaying: boolean;
  5423. /**
  5424. * Is this sound currently paused.
  5425. */
  5426. isPaused: boolean;
  5427. /**
  5428. * Does this sound enables spatial sound.
  5429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5430. */
  5431. spatialSound: boolean;
  5432. /**
  5433. * Define the reference distance the sound should be heard perfectly.
  5434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5435. */
  5436. refDistance: number;
  5437. /**
  5438. * Define the roll off factor of spatial sounds.
  5439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5440. */
  5441. rolloffFactor: number;
  5442. /**
  5443. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5445. */
  5446. maxDistance: number;
  5447. /**
  5448. * Define the distance attenuation model the sound will follow.
  5449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5450. */
  5451. distanceModel: string;
  5452. /**
  5453. * @hidden
  5454. * Back Compat
  5455. **/
  5456. onended: () => any;
  5457. /**
  5458. * Observable event when the current playing sound finishes.
  5459. */
  5460. onEndedObservable: Observable<Sound>;
  5461. private _panningModel;
  5462. private _playbackRate;
  5463. private _streaming;
  5464. private _startTime;
  5465. private _startOffset;
  5466. private _position;
  5467. /** @hidden */
  5468. _positionInEmitterSpace: boolean;
  5469. private _localDirection;
  5470. private _volume;
  5471. private _isReadyToPlay;
  5472. private _isDirectional;
  5473. private _readyToPlayCallback;
  5474. private _audioBuffer;
  5475. private _soundSource;
  5476. private _streamingSource;
  5477. private _soundPanner;
  5478. private _soundGain;
  5479. private _inputAudioNode;
  5480. private _outputAudioNode;
  5481. private _coneInnerAngle;
  5482. private _coneOuterAngle;
  5483. private _coneOuterGain;
  5484. private _scene;
  5485. private _connectedMesh;
  5486. private _customAttenuationFunction;
  5487. private _registerFunc;
  5488. private _isOutputConnected;
  5489. private _htmlAudioElement;
  5490. private _urlType;
  5491. /**
  5492. * Create a sound and attach it to a scene
  5493. * @param name Name of your sound
  5494. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5495. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5496. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5497. */
  5498. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5499. /**
  5500. * Release the sound and its associated resources
  5501. */
  5502. dispose(): void;
  5503. /**
  5504. * Gets if the sounds is ready to be played or not.
  5505. * @returns true if ready, otherwise false
  5506. */
  5507. isReady(): boolean;
  5508. private _soundLoaded;
  5509. /**
  5510. * Sets the data of the sound from an audiobuffer
  5511. * @param audioBuffer The audioBuffer containing the data
  5512. */
  5513. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5514. /**
  5515. * Updates the current sounds options such as maxdistance, loop...
  5516. * @param options A JSON object containing values named as the object properties
  5517. */
  5518. updateOptions(options: any): void;
  5519. private _createSpatialParameters;
  5520. private _updateSpatialParameters;
  5521. /**
  5522. * Switch the panning model to HRTF:
  5523. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5525. */
  5526. switchPanningModelToHRTF(): void;
  5527. /**
  5528. * Switch the panning model to Equal Power:
  5529. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5531. */
  5532. switchPanningModelToEqualPower(): void;
  5533. private _switchPanningModel;
  5534. /**
  5535. * Connect this sound to a sound track audio node like gain...
  5536. * @param soundTrackAudioNode the sound track audio node to connect to
  5537. */
  5538. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5539. /**
  5540. * Transform this sound into a directional source
  5541. * @param coneInnerAngle Size of the inner cone in degree
  5542. * @param coneOuterAngle Size of the outer cone in degree
  5543. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5544. */
  5545. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5546. /**
  5547. * Gets or sets the inner angle for the directional cone.
  5548. */
  5549. /**
  5550. * Gets or sets the inner angle for the directional cone.
  5551. */
  5552. directionalConeInnerAngle: number;
  5553. /**
  5554. * Gets or sets the outer angle for the directional cone.
  5555. */
  5556. /**
  5557. * Gets or sets the outer angle for the directional cone.
  5558. */
  5559. directionalConeOuterAngle: number;
  5560. /**
  5561. * Sets the position of the emitter if spatial sound is enabled
  5562. * @param newPosition Defines the new posisiton
  5563. */
  5564. setPosition(newPosition: Vector3): void;
  5565. /**
  5566. * Sets the local direction of the emitter if spatial sound is enabled
  5567. * @param newLocalDirection Defines the new local direction
  5568. */
  5569. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5570. private _updateDirection;
  5571. /** @hidden */
  5572. updateDistanceFromListener(): void;
  5573. /**
  5574. * Sets a new custom attenuation function for the sound.
  5575. * @param callback Defines the function used for the attenuation
  5576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5577. */
  5578. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5579. /**
  5580. * Play the sound
  5581. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5582. * @param offset (optional) Start the sound setting it at a specific time
  5583. */
  5584. play(time?: number, offset?: number): void;
  5585. private _onended;
  5586. /**
  5587. * Stop the sound
  5588. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5589. */
  5590. stop(time?: number): void;
  5591. /**
  5592. * Put the sound in pause
  5593. */
  5594. pause(): void;
  5595. /**
  5596. * Sets a dedicated volume for this sounds
  5597. * @param newVolume Define the new volume of the sound
  5598. * @param time Define in how long the sound should be at this value
  5599. */
  5600. setVolume(newVolume: number, time?: number): void;
  5601. /**
  5602. * Set the sound play back rate
  5603. * @param newPlaybackRate Define the playback rate the sound should be played at
  5604. */
  5605. setPlaybackRate(newPlaybackRate: number): void;
  5606. /**
  5607. * Gets the volume of the sound.
  5608. * @returns the volume of the sound
  5609. */
  5610. getVolume(): number;
  5611. /**
  5612. * Attach the sound to a dedicated mesh
  5613. * @param meshToConnectTo The mesh to connect the sound with
  5614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5615. */
  5616. attachToMesh(meshToConnectTo: AbstractMesh): void;
  5617. /**
  5618. * Detach the sound from the previously attached mesh
  5619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5620. */
  5621. detachFromMesh(): void;
  5622. private _onRegisterAfterWorldMatrixUpdate;
  5623. /**
  5624. * Clone the current sound in the scene.
  5625. * @returns the new sound clone
  5626. */
  5627. clone(): Nullable<Sound>;
  5628. /**
  5629. * Gets the current underlying audio buffer containing the data
  5630. * @returns the audio buffer
  5631. */
  5632. getAudioBuffer(): Nullable<AudioBuffer>;
  5633. /**
  5634. * Serializes the Sound in a JSON representation
  5635. * @returns the JSON representation of the sound
  5636. */
  5637. serialize(): any;
  5638. /**
  5639. * Parse a JSON representation of a sound to innstantiate in a given scene
  5640. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5641. * @param scene Define the scene the new parsed sound should be created in
  5642. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5643. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5644. * @returns the newly parsed sound
  5645. */
  5646. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5647. }
  5648. }
  5649. declare module BABYLON {
  5650. /**
  5651. * Options allowed during the creation of a sound track.
  5652. */
  5653. interface ISoundTrackOptions {
  5654. /**
  5655. * The volume the sound track should take during creation
  5656. */
  5657. volume?: number;
  5658. /**
  5659. * Define if the sound track is the main sound track of the scene
  5660. */
  5661. mainTrack?: boolean;
  5662. }
  5663. /**
  5664. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5665. * It will be also used in a future release to apply effects on a specific track.
  5666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5667. */
  5668. class SoundTrack {
  5669. /**
  5670. * The unique identifier of the sound track in the scene.
  5671. */
  5672. id: number;
  5673. /**
  5674. * The list of sounds included in the sound track.
  5675. */
  5676. soundCollection: Array<Sound>;
  5677. private _outputAudioNode;
  5678. private _scene;
  5679. private _isMainTrack;
  5680. private _connectedAnalyser;
  5681. private _options;
  5682. private _isInitialized;
  5683. /**
  5684. * Creates a new sound track.
  5685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5686. * @param scene Define the scene the sound track belongs to
  5687. * @param options
  5688. */
  5689. constructor(scene: Scene, options?: ISoundTrackOptions);
  5690. private _initializeSoundTrackAudioGraph;
  5691. /**
  5692. * Release the sound track and its associated resources
  5693. */
  5694. dispose(): void;
  5695. /**
  5696. * Adds a sound to this sound track
  5697. * @param sound define the cound to add
  5698. * @ignoreNaming
  5699. */
  5700. AddSound(sound: Sound): void;
  5701. /**
  5702. * Removes a sound to this sound track
  5703. * @param sound define the cound to remove
  5704. * @ignoreNaming
  5705. */
  5706. RemoveSound(sound: Sound): void;
  5707. /**
  5708. * Set a global volume for the full sound track.
  5709. * @param newVolume Define the new volume of the sound track
  5710. */
  5711. setVolume(newVolume: number): void;
  5712. /**
  5713. * Switch the panning model to HRTF:
  5714. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5716. */
  5717. switchPanningModelToHRTF(): void;
  5718. /**
  5719. * Switch the panning model to Equal Power:
  5720. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5722. */
  5723. switchPanningModelToEqualPower(): void;
  5724. /**
  5725. * Connect the sound track to an audio analyser allowing some amazing
  5726. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5728. * @param analyser The analyser to connect to the engine
  5729. */
  5730. connectToAnalyser(analyser: Analyser): void;
  5731. }
  5732. }
  5733. declare module BABYLON {
  5734. /**
  5735. * Wraps one or more Sound objects and selects one with random weight for playback.
  5736. */
  5737. class WeightedSound {
  5738. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5739. loop: boolean;
  5740. private _coneInnerAngle;
  5741. private _coneOuterAngle;
  5742. private _volume;
  5743. /** A Sound is currently playing. */
  5744. isPlaying: boolean;
  5745. /** A Sound is currently paused. */
  5746. isPaused: boolean;
  5747. private _sounds;
  5748. private _weights;
  5749. private _currentIndex?;
  5750. /**
  5751. * Creates a new WeightedSound from the list of sounds given.
  5752. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5753. * @param sounds Array of Sounds that will be selected from.
  5754. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5755. */
  5756. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5757. /**
  5758. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5759. */
  5760. /**
  5761. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5762. */
  5763. directionalConeInnerAngle: number;
  5764. /**
  5765. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5766. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5767. */
  5768. /**
  5769. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5770. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5771. */
  5772. directionalConeOuterAngle: number;
  5773. /**
  5774. * Playback volume.
  5775. */
  5776. /**
  5777. * Playback volume.
  5778. */
  5779. volume: number;
  5780. private _onended;
  5781. /**
  5782. * Suspend playback
  5783. */
  5784. pause(): void;
  5785. /**
  5786. * Stop playback
  5787. */
  5788. stop(): void;
  5789. /**
  5790. * Start playback.
  5791. * @param startOffset Position the clip head at a specific time in seconds.
  5792. */
  5793. play(startOffset?: number): void;
  5794. }
  5795. }
  5796. declare module BABYLON {
  5797. /**
  5798. * Interface used to define a behavior
  5799. */
  5800. interface Behavior<T> {
  5801. /** gets or sets behavior's name */
  5802. name: string;
  5803. /**
  5804. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5805. */
  5806. init(): void;
  5807. /**
  5808. * Called when the behavior is attached to a target
  5809. * @param target defines the target where the behavior is attached to
  5810. */
  5811. attach(target: T): void;
  5812. /**
  5813. * Called when the behavior is detached from its target
  5814. */
  5815. detach(): void;
  5816. }
  5817. /**
  5818. * Interface implemented by classes supporting behaviors
  5819. */
  5820. interface IBehaviorAware<T> {
  5821. /**
  5822. * Attach a behavior
  5823. * @param behavior defines the behavior to attach
  5824. * @returns the current host
  5825. */
  5826. addBehavior(behavior: Behavior<T>): T;
  5827. /**
  5828. * Remove a behavior from the current object
  5829. * @param behavior defines the behavior to detach
  5830. * @returns the current host
  5831. */
  5832. removeBehavior(behavior: Behavior<T>): T;
  5833. /**
  5834. * Gets a behavior using its name to search
  5835. * @param name defines the name to search
  5836. * @returns the behavior or null if not found
  5837. */
  5838. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5839. }
  5840. }
  5841. declare module BABYLON {
  5842. /**
  5843. * Class used to store bone information
  5844. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5845. */
  5846. class Bone extends Node {
  5847. /**
  5848. * defines the bone name
  5849. */
  5850. name: string;
  5851. private static _tmpVecs;
  5852. private static _tmpQuat;
  5853. private static _tmpMats;
  5854. /**
  5855. * Gets the list of child bones
  5856. */
  5857. children: Bone[];
  5858. /** Gets the animations associated with this bone */
  5859. animations: Animation[];
  5860. /**
  5861. * Gets or sets bone length
  5862. */
  5863. length: number;
  5864. /**
  5865. * @hidden Internal only
  5866. * Set this value to map this bone to a different index in the transform matrices
  5867. * Set this value to -1 to exclude the bone from the transform matrices
  5868. */
  5869. _index: Nullable<number>;
  5870. private _skeleton;
  5871. private _localMatrix;
  5872. private _restPose;
  5873. private _baseMatrix;
  5874. private _absoluteTransform;
  5875. private _invertedAbsoluteTransform;
  5876. private _parent;
  5877. private _scalingDeterminant;
  5878. private _worldTransform;
  5879. private _localScaling;
  5880. private _localRotation;
  5881. private _localPosition;
  5882. private _needToDecompose;
  5883. private _needToCompose;
  5884. /** @hidden */
  5885. /** @hidden */
  5886. _matrix: Matrix;
  5887. /**
  5888. * Create a new bone
  5889. * @param name defines the bone name
  5890. * @param skeleton defines the parent skeleton
  5891. * @param parentBone defines the parent (can be null if the bone is the root)
  5892. * @param localMatrix defines the local matrix
  5893. * @param restPose defines the rest pose matrix
  5894. * @param baseMatrix defines the base matrix
  5895. * @param index defines index of the bone in the hiearchy
  5896. */
  5897. constructor(
  5898. /**
  5899. * defines the bone name
  5900. */
  5901. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5902. /**
  5903. * Gets the parent skeleton
  5904. * @returns a skeleton
  5905. */
  5906. getSkeleton(): Skeleton;
  5907. /**
  5908. * Gets parent bone
  5909. * @returns a bone or null if the bone is the root of the bone hierarchy
  5910. */
  5911. getParent(): Nullable<Bone>;
  5912. /**
  5913. * Sets the parent bone
  5914. * @param parent defines the parent (can be null if the bone is the root)
  5915. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5916. */
  5917. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5918. /**
  5919. * Gets the local matrix
  5920. * @returns a matrix
  5921. */
  5922. getLocalMatrix(): Matrix;
  5923. /**
  5924. * Gets the base matrix (initial matrix which remains unchanged)
  5925. * @returns a matrix
  5926. */
  5927. getBaseMatrix(): Matrix;
  5928. /**
  5929. * Gets the rest pose matrix
  5930. * @returns a matrix
  5931. */
  5932. getRestPose(): Matrix;
  5933. /**
  5934. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5935. */
  5936. getWorldMatrix(): Matrix;
  5937. /**
  5938. * Sets the local matrix to rest pose matrix
  5939. */
  5940. returnToRest(): void;
  5941. /**
  5942. * Gets the inverse of the absolute transform matrix.
  5943. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5944. * @returns a matrix
  5945. */
  5946. getInvertedAbsoluteTransform(): Matrix;
  5947. /**
  5948. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5949. * @returns a matrix
  5950. */
  5951. getAbsoluteTransform(): Matrix;
  5952. /** Gets or sets current position (in local space) */
  5953. position: Vector3;
  5954. /** Gets or sets current rotation (in local space) */
  5955. rotation: Vector3;
  5956. /** Gets or sets current rotation quaternion (in local space) */
  5957. rotationQuaternion: Quaternion;
  5958. /** Gets or sets current scaling (in local space) */
  5959. scaling: Vector3;
  5960. /**
  5961. * Gets the animation properties override
  5962. */
  5963. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5964. private _decompose;
  5965. private _compose;
  5966. /**
  5967. * Update the base and local matrices
  5968. * @param matrix defines the new base or local matrix
  5969. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5970. * @param updateLocalMatrix defines if the local matrix should be updated
  5971. */
  5972. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5973. /** @hidden */
  5974. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5975. /**
  5976. * Flag the bone as dirty (Forcing it to update everything)
  5977. */
  5978. markAsDirty(): void;
  5979. private _markAsDirtyAndCompose;
  5980. private _markAsDirtyAndDecompose;
  5981. /**
  5982. * Copy an animation range from another bone
  5983. * @param source defines the source bone
  5984. * @param rangeName defines the range name to copy
  5985. * @param frameOffset defines the frame offset
  5986. * @param rescaleAsRequired defines if rescaling must be applied if required
  5987. * @param skelDimensionsRatio defines the scaling ratio
  5988. * @returns true if operation was successful
  5989. */
  5990. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5991. /**
  5992. * Translate the bone in local or world space
  5993. * @param vec The amount to translate the bone
  5994. * @param space The space that the translation is in
  5995. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5996. */
  5997. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5998. /**
  5999. * Set the postion of the bone in local or world space
  6000. * @param position The position to set the bone
  6001. * @param space The space that the position is in
  6002. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6003. */
  6004. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6005. /**
  6006. * Set the absolute position of the bone (world space)
  6007. * @param position The position to set the bone
  6008. * @param mesh The mesh that this bone is attached to
  6009. */
  6010. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6011. /**
  6012. * Scale the bone on the x, y and z axes (in local space)
  6013. * @param x The amount to scale the bone on the x axis
  6014. * @param y The amount to scale the bone on the y axis
  6015. * @param z The amount to scale the bone on the z axis
  6016. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6017. */
  6018. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6019. /**
  6020. * Set the bone scaling in local space
  6021. * @param scale defines the scaling vector
  6022. */
  6023. setScale(scale: Vector3): void;
  6024. /**
  6025. * Gets the current scaling in local space
  6026. * @returns the current scaling vector
  6027. */
  6028. getScale(): Vector3;
  6029. /**
  6030. * Gets the current scaling in local space and stores it in a target vector
  6031. * @param result defines the target vector
  6032. */
  6033. getScaleToRef(result: Vector3): void;
  6034. /**
  6035. * Set the yaw, pitch, and roll of the bone in local or world space
  6036. * @param yaw The rotation of the bone on the y axis
  6037. * @param pitch The rotation of the bone on the x axis
  6038. * @param roll The rotation of the bone on the z axis
  6039. * @param space The space that the axes of rotation are in
  6040. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6041. */
  6042. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6043. /**
  6044. * Add a rotation to the bone on an axis in local or world space
  6045. * @param axis The axis to rotate the bone on
  6046. * @param amount The amount to rotate the bone
  6047. * @param space The space that the axis is in
  6048. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6049. */
  6050. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6051. /**
  6052. * Set the rotation of the bone to a particular axis angle in local or world space
  6053. * @param axis The axis to rotate the bone on
  6054. * @param angle The angle that the bone should be rotated to
  6055. * @param space The space that the axis is in
  6056. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6057. */
  6058. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6059. /**
  6060. * Set the euler rotation of the bone in local of world space
  6061. * @param rotation The euler rotation that the bone should be set to
  6062. * @param space The space that the rotation is in
  6063. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6064. */
  6065. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6066. /**
  6067. * Set the quaternion rotation of the bone in local of world space
  6068. * @param quat The quaternion rotation that the bone should be set to
  6069. * @param space The space that the rotation is in
  6070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6071. */
  6072. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6073. /**
  6074. * Set the rotation matrix of the bone in local of world space
  6075. * @param rotMat The rotation matrix that the bone should be set to
  6076. * @param space The space that the rotation is in
  6077. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6078. */
  6079. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6080. private _rotateWithMatrix;
  6081. private _getNegativeRotationToRef;
  6082. /**
  6083. * Get the position of the bone in local or world space
  6084. * @param space The space that the returned position is in
  6085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6086. * @returns The position of the bone
  6087. */
  6088. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6089. /**
  6090. * Copy the position of the bone to a vector3 in local or world space
  6091. * @param space The space that the returned position is in
  6092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6093. * @param result The vector3 to copy the position to
  6094. */
  6095. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6096. /**
  6097. * Get the absolute position of the bone (world space)
  6098. * @param mesh The mesh that this bone is attached to
  6099. * @returns The absolute position of the bone
  6100. */
  6101. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6102. /**
  6103. * Copy the absolute position of the bone (world space) to the result param
  6104. * @param mesh The mesh that this bone is attached to
  6105. * @param result The vector3 to copy the absolute position to
  6106. */
  6107. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6108. /**
  6109. * Compute the absolute transforms of this bone and its children
  6110. */
  6111. computeAbsoluteTransforms(): void;
  6112. /**
  6113. * Get the world direction from an axis that is in the local space of the bone
  6114. * @param localAxis The local direction that is used to compute the world direction
  6115. * @param mesh The mesh that this bone is attached to
  6116. * @returns The world direction
  6117. */
  6118. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6119. /**
  6120. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6121. * @param localAxis The local direction that is used to compute the world direction
  6122. * @param mesh The mesh that this bone is attached to
  6123. * @param result The vector3 that the world direction will be copied to
  6124. */
  6125. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6126. /**
  6127. * Get the euler rotation of the bone in local or world space
  6128. * @param space The space that the rotation should be in
  6129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6130. * @returns The euler rotation
  6131. */
  6132. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6133. /**
  6134. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6135. * @param space The space that the rotation should be in
  6136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6137. * @param result The vector3 that the rotation should be copied to
  6138. */
  6139. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6140. /**
  6141. * Get the quaternion rotation of the bone in either local or world space
  6142. * @param space The space that the rotation should be in
  6143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6144. * @returns The quaternion rotation
  6145. */
  6146. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6147. /**
  6148. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6149. * @param space The space that the rotation should be in
  6150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6151. * @param result The quaternion that the rotation should be copied to
  6152. */
  6153. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6154. /**
  6155. * Get the rotation matrix of the bone in local or world space
  6156. * @param space The space that the rotation should be in
  6157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6158. * @returns The rotation matrix
  6159. */
  6160. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6161. /**
  6162. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6163. * @param space The space that the rotation should be in
  6164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6165. * @param result The quaternion that the rotation should be copied to
  6166. */
  6167. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6168. /**
  6169. * Get the world position of a point that is in the local space of the bone
  6170. * @param position The local position
  6171. * @param mesh The mesh that this bone is attached to
  6172. * @returns The world position
  6173. */
  6174. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6175. /**
  6176. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6177. * @param position The local position
  6178. * @param mesh The mesh that this bone is attached to
  6179. * @param result The vector3 that the world position should be copied to
  6180. */
  6181. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6182. /**
  6183. * Get the local position of a point that is in world space
  6184. * @param position The world position
  6185. * @param mesh The mesh that this bone is attached to
  6186. * @returns The local position
  6187. */
  6188. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6189. /**
  6190. * Get the local position of a point that is in world space and copy it to the result param
  6191. * @param position The world position
  6192. * @param mesh The mesh that this bone is attached to
  6193. * @param result The vector3 that the local position should be copied to
  6194. */
  6195. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6196. }
  6197. }
  6198. declare module BABYLON {
  6199. /**
  6200. * Class used to apply inverse kinematics to bones
  6201. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6202. */
  6203. class BoneIKController {
  6204. private static _tmpVecs;
  6205. private static _tmpQuat;
  6206. private static _tmpMats;
  6207. /**
  6208. * Gets or sets the target mesh
  6209. */
  6210. targetMesh: AbstractMesh;
  6211. /** Gets or sets the mesh used as pole */
  6212. poleTargetMesh: AbstractMesh;
  6213. /**
  6214. * Gets or sets the bone used as pole
  6215. */
  6216. poleTargetBone: Nullable<Bone>;
  6217. /**
  6218. * Gets or sets the target position
  6219. */
  6220. targetPosition: Vector3;
  6221. /**
  6222. * Gets or sets the pole target position
  6223. */
  6224. poleTargetPosition: Vector3;
  6225. /**
  6226. * Gets or sets the pole target local offset
  6227. */
  6228. poleTargetLocalOffset: Vector3;
  6229. /**
  6230. * Gets or sets the pole angle
  6231. */
  6232. poleAngle: number;
  6233. /**
  6234. * Gets or sets the mesh associated with the controller
  6235. */
  6236. mesh: AbstractMesh;
  6237. /**
  6238. * 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)
  6239. */
  6240. slerpAmount: number;
  6241. private _bone1Quat;
  6242. private _bone1Mat;
  6243. private _bone2Ang;
  6244. private _bone1;
  6245. private _bone2;
  6246. private _bone1Length;
  6247. private _bone2Length;
  6248. private _maxAngle;
  6249. private _maxReach;
  6250. private _rightHandedSystem;
  6251. private _bendAxis;
  6252. private _slerping;
  6253. private _adjustRoll;
  6254. /**
  6255. * Gets or sets maximum allowed angle
  6256. */
  6257. maxAngle: number;
  6258. /**
  6259. * Creates a new BoneIKController
  6260. * @param mesh defines the mesh to control
  6261. * @param bone defines the bone to control
  6262. * @param options defines options to set up the controller
  6263. */
  6264. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6265. targetMesh?: AbstractMesh;
  6266. poleTargetMesh?: AbstractMesh;
  6267. poleTargetBone?: Bone;
  6268. poleTargetLocalOffset?: Vector3;
  6269. poleAngle?: number;
  6270. bendAxis?: Vector3;
  6271. maxAngle?: number;
  6272. slerpAmount?: number;
  6273. });
  6274. private _setMaxAngle;
  6275. /**
  6276. * Force the controller to update the bones
  6277. */
  6278. update(): void;
  6279. }
  6280. }
  6281. declare module BABYLON {
  6282. /**
  6283. * Class used to make a bone look toward a point in space
  6284. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6285. */
  6286. class BoneLookController {
  6287. private static _tmpVecs;
  6288. private static _tmpQuat;
  6289. private static _tmpMats;
  6290. /**
  6291. * The target Vector3 that the bone will look at
  6292. */
  6293. target: Vector3;
  6294. /**
  6295. * The mesh that the bone is attached to
  6296. */
  6297. mesh: AbstractMesh;
  6298. /**
  6299. * The bone that will be looking to the target
  6300. */
  6301. bone: Bone;
  6302. /**
  6303. * The up axis of the coordinate system that is used when the bone is rotated
  6304. */
  6305. upAxis: Vector3;
  6306. /**
  6307. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6308. */
  6309. upAxisSpace: Space;
  6310. /**
  6311. * Used to make an adjustment to the yaw of the bone
  6312. */
  6313. adjustYaw: number;
  6314. /**
  6315. * Used to make an adjustment to the pitch of the bone
  6316. */
  6317. adjustPitch: number;
  6318. /**
  6319. * Used to make an adjustment to the roll of the bone
  6320. */
  6321. adjustRoll: number;
  6322. /**
  6323. * 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)
  6324. */
  6325. slerpAmount: number;
  6326. private _minYaw;
  6327. private _maxYaw;
  6328. private _minPitch;
  6329. private _maxPitch;
  6330. private _minYawSin;
  6331. private _minYawCos;
  6332. private _maxYawSin;
  6333. private _maxYawCos;
  6334. private _midYawConstraint;
  6335. private _minPitchTan;
  6336. private _maxPitchTan;
  6337. private _boneQuat;
  6338. private _slerping;
  6339. private _transformYawPitch;
  6340. private _transformYawPitchInv;
  6341. private _firstFrameSkipped;
  6342. private _yawRange;
  6343. private _fowardAxis;
  6344. /**
  6345. * Gets or sets the minimum yaw angle that the bone can look to
  6346. */
  6347. minYaw: number;
  6348. /**
  6349. * Gets or sets the maximum yaw angle that the bone can look to
  6350. */
  6351. maxYaw: number;
  6352. /**
  6353. * Gets or sets the minimum pitch angle that the bone can look to
  6354. */
  6355. minPitch: number;
  6356. /**
  6357. * Gets or sets the maximum pitch angle that the bone can look to
  6358. */
  6359. maxPitch: number;
  6360. /**
  6361. * Create a BoneLookController
  6362. * @param mesh the mesh that the bone belongs to
  6363. * @param bone the bone that will be looking to the target
  6364. * @param target the target Vector3 to look at
  6365. * @param settings optional settings:
  6366. * * maxYaw: the maximum angle the bone will yaw to
  6367. * * minYaw: the minimum angle the bone will yaw to
  6368. * * maxPitch: the maximum angle the bone will pitch to
  6369. * * minPitch: the minimum angle the bone will yaw to
  6370. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6371. * * upAxis: the up axis of the coordinate system
  6372. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6373. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6374. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6375. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6376. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6377. * * adjustRoll: used to make an adjustment to the roll of the bone
  6378. **/
  6379. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6380. maxYaw?: number;
  6381. minYaw?: number;
  6382. maxPitch?: number;
  6383. minPitch?: number;
  6384. slerpAmount?: number;
  6385. upAxis?: Vector3;
  6386. upAxisSpace?: Space;
  6387. yawAxis?: Vector3;
  6388. pitchAxis?: Vector3;
  6389. adjustYaw?: number;
  6390. adjustPitch?: number;
  6391. adjustRoll?: number;
  6392. });
  6393. /**
  6394. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6395. */
  6396. update(): void;
  6397. private _getAngleDiff;
  6398. private _getAngleBetween;
  6399. private _isAngleBetween;
  6400. }
  6401. }
  6402. declare module BABYLON {
  6403. /**
  6404. * Class used to handle skinning animations
  6405. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6406. */
  6407. class Skeleton implements IAnimatable {
  6408. /** defines the skeleton name */
  6409. name: string;
  6410. /** defines the skeleton Id */
  6411. id: string;
  6412. /**
  6413. * Gets the list of child bones
  6414. */
  6415. bones: Bone[];
  6416. /**
  6417. * Gets an estimate of the dimension of the skeleton at rest
  6418. */
  6419. dimensionsAtRest: Vector3;
  6420. /**
  6421. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6422. */
  6423. needInitialSkinMatrix: boolean;
  6424. /**
  6425. * Gets the list of animations attached to this skeleton
  6426. */
  6427. animations: Array<Animation>;
  6428. private _scene;
  6429. private _isDirty;
  6430. private _transformMatrices;
  6431. private _meshesWithPoseMatrix;
  6432. private _animatables;
  6433. private _identity;
  6434. private _synchronizedWithMesh;
  6435. private _ranges;
  6436. private _lastAbsoluteTransformsUpdateId;
  6437. /**
  6438. * Specifies if the skeleton should be serialized
  6439. */
  6440. doNotSerialize: boolean;
  6441. private _animationPropertiesOverride;
  6442. /**
  6443. * Gets or sets the animation properties override
  6444. */
  6445. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6446. /**
  6447. * An observable triggered before computing the skeleton's matrices
  6448. */
  6449. onBeforeComputeObservable: Observable<Skeleton>;
  6450. /**
  6451. * Creates a new skeleton
  6452. * @param name defines the skeleton name
  6453. * @param id defines the skeleton Id
  6454. * @param scene defines the hosting scene
  6455. */
  6456. constructor(
  6457. /** defines the skeleton name */
  6458. name: string,
  6459. /** defines the skeleton Id */
  6460. id: string, scene: Scene);
  6461. /**
  6462. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6463. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6464. * @returns a Float32Array containing matrices data
  6465. */
  6466. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6467. /**
  6468. * Gets the current hosting scene
  6469. * @returns a scene object
  6470. */
  6471. getScene(): Scene;
  6472. /**
  6473. * Gets a string representing the current skeleton data
  6474. * @param fullDetails defines a boolean indicating if we want a verbose version
  6475. * @returns a string representing the current skeleton data
  6476. */
  6477. toString(fullDetails?: boolean): string;
  6478. /**
  6479. * Get bone's index searching by name
  6480. * @param name defines bone's name to search for
  6481. * @return the indice of the bone. Returns -1 if not found
  6482. */
  6483. getBoneIndexByName(name: string): number;
  6484. /**
  6485. * Creater a new animation range
  6486. * @param name defines the name of the range
  6487. * @param from defines the start key
  6488. * @param to defines the end key
  6489. */
  6490. createAnimationRange(name: string, from: number, to: number): void;
  6491. /**
  6492. * Delete a specific animation range
  6493. * @param name defines the name of the range
  6494. * @param deleteFrames defines if frames must be removed as well
  6495. */
  6496. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6497. /**
  6498. * Gets a specific animation range
  6499. * @param name defines the name of the range to look for
  6500. * @returns the requested animation range or null if not found
  6501. */
  6502. getAnimationRange(name: string): Nullable<AnimationRange>;
  6503. /**
  6504. * Gets the list of all animation ranges defined on this skeleton
  6505. * @returns an array
  6506. */
  6507. getAnimationRanges(): Nullable<AnimationRange>[];
  6508. /**
  6509. * Copy animation range from a source skeleton.
  6510. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6511. * @param source defines the source skeleton
  6512. * @param name defines the name of the range to copy
  6513. * @param rescaleAsRequired defines if rescaling must be applied if required
  6514. * @returns true if operation was successful
  6515. */
  6516. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6517. /**
  6518. * Forces the skeleton to go to rest pose
  6519. */
  6520. returnToRest(): void;
  6521. private _getHighestAnimationFrame;
  6522. /**
  6523. * Begin a specific animation range
  6524. * @param name defines the name of the range to start
  6525. * @param loop defines if looping must be turned on (false by default)
  6526. * @param speedRatio defines the speed ratio to apply (1 by default)
  6527. * @param onAnimationEnd defines a callback which will be called when animation will end
  6528. * @returns a new animatable
  6529. */
  6530. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6531. /** @hidden */
  6532. _markAsDirty(): void;
  6533. /** @hidden */
  6534. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6535. /** @hidden */
  6536. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6537. /** @hidden */
  6538. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  6539. /**
  6540. * Build all resources required to render a skeleton
  6541. */
  6542. prepare(): void;
  6543. /**
  6544. * Gets the list of animatables currently running for this skeleton
  6545. * @returns an array of animatables
  6546. */
  6547. getAnimatables(): IAnimatable[];
  6548. /**
  6549. * Clone the current skeleton
  6550. * @param name defines the name of the new skeleton
  6551. * @param id defines the id of the enw skeleton
  6552. * @returns the new skeleton
  6553. */
  6554. clone(name: string, id: string): Skeleton;
  6555. /**
  6556. * Enable animation blending for this skeleton
  6557. * @param blendingSpeed defines the blending speed to apply
  6558. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6559. */
  6560. enableBlending(blendingSpeed?: number): void;
  6561. /**
  6562. * Releases all resources associated with the current skeleton
  6563. */
  6564. dispose(): void;
  6565. /**
  6566. * Serialize the skeleton in a JSON object
  6567. * @returns a JSON object
  6568. */
  6569. serialize(): any;
  6570. /**
  6571. * Creates a new skeleton from serialized data
  6572. * @param parsedSkeleton defines the serialized data
  6573. * @param scene defines the hosting scene
  6574. * @returns a new skeleton
  6575. */
  6576. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6577. /**
  6578. * Compute all node absolute transforms
  6579. * @param forceUpdate defines if computation must be done even if cache is up to date
  6580. */
  6581. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6582. /**
  6583. * Gets the root pose matrix
  6584. * @returns a matrix
  6585. */
  6586. getPoseMatrix(): Nullable<Matrix>;
  6587. /**
  6588. * Sorts bones per internal index
  6589. */
  6590. sortBones(): void;
  6591. private _sortBones;
  6592. }
  6593. }
  6594. declare module BABYLON {
  6595. /** @hidden */
  6596. class Collider {
  6597. /** Define if a collision was found */
  6598. collisionFound: boolean;
  6599. /**
  6600. * Define last intersection point in local space
  6601. */
  6602. intersectionPoint: Vector3;
  6603. /**
  6604. * Define last collided mesh
  6605. */
  6606. collidedMesh: Nullable<AbstractMesh>;
  6607. private _collisionPoint;
  6608. private _planeIntersectionPoint;
  6609. private _tempVector;
  6610. private _tempVector2;
  6611. private _tempVector3;
  6612. private _tempVector4;
  6613. private _edge;
  6614. private _baseToVertex;
  6615. private _destinationPoint;
  6616. private _slidePlaneNormal;
  6617. private _displacementVector;
  6618. /** @hidden */
  6619. _radius: Vector3;
  6620. /** @hidden */
  6621. _retry: number;
  6622. private _velocity;
  6623. private _basePoint;
  6624. private _epsilon;
  6625. /** @hidden */
  6626. _velocityWorldLength: number;
  6627. /** @hidden */
  6628. _basePointWorld: Vector3;
  6629. private _velocityWorld;
  6630. private _normalizedVelocity;
  6631. /** @hidden */
  6632. _initialVelocity: Vector3;
  6633. /** @hidden */
  6634. _initialPosition: Vector3;
  6635. private _nearestDistance;
  6636. private _collisionMask;
  6637. collisionMask: number;
  6638. /**
  6639. * Gets the plane normal used to compute the sliding response (in local space)
  6640. */
  6641. readonly slidePlaneNormal: Vector3;
  6642. /** @hidden */
  6643. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6644. /** @hidden */
  6645. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6646. /** @hidden */
  6647. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6648. /** @hidden */
  6649. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6650. /** @hidden */
  6651. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6652. /** @hidden */
  6653. _getResponse(pos: Vector3, vel: Vector3): void;
  6654. }
  6655. }
  6656. declare module BABYLON {
  6657. /** @hidden */
  6658. var CollisionWorker: string;
  6659. /** @hidden */
  6660. interface ICollisionCoordinator {
  6661. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6662. init(scene: Scene): void;
  6663. destroy(): void;
  6664. onMeshAdded(mesh: AbstractMesh): void;
  6665. onMeshUpdated(mesh: AbstractMesh): void;
  6666. onMeshRemoved(mesh: AbstractMesh): void;
  6667. onGeometryAdded(geometry: Geometry): void;
  6668. onGeometryUpdated(geometry: Geometry): void;
  6669. onGeometryDeleted(geometry: Geometry): void;
  6670. }
  6671. /** @hidden */
  6672. interface SerializedMesh {
  6673. id: string;
  6674. name: string;
  6675. uniqueId: number;
  6676. geometryId: Nullable<string>;
  6677. sphereCenter: Array<number>;
  6678. sphereRadius: number;
  6679. boxMinimum: Array<number>;
  6680. boxMaximum: Array<number>;
  6681. worldMatrixFromCache: any;
  6682. subMeshes: Array<SerializedSubMesh>;
  6683. checkCollisions: boolean;
  6684. }
  6685. /** @hidden */
  6686. interface SerializedSubMesh {
  6687. position: number;
  6688. verticesStart: number;
  6689. verticesCount: number;
  6690. indexStart: number;
  6691. indexCount: number;
  6692. hasMaterial: boolean;
  6693. sphereCenter: Array<number>;
  6694. sphereRadius: number;
  6695. boxMinimum: Array<number>;
  6696. boxMaximum: Array<number>;
  6697. }
  6698. /**
  6699. * Interface describing the value associated with a geometry.
  6700. * @hidden
  6701. */
  6702. interface SerializedGeometry {
  6703. /**
  6704. * Defines the unique ID of the geometry
  6705. */
  6706. id: string;
  6707. /**
  6708. * Defines the array containing the positions
  6709. */
  6710. positions: Float32Array;
  6711. /**
  6712. * Defines the array containing the indices
  6713. */
  6714. indices: Uint32Array;
  6715. /**
  6716. * Defines the array containing the normals
  6717. */
  6718. normals: Float32Array;
  6719. }
  6720. /** @hidden */
  6721. interface BabylonMessage {
  6722. taskType: WorkerTaskType;
  6723. payload: InitPayload | CollidePayload | UpdatePayload;
  6724. }
  6725. /** @hidden */
  6726. interface SerializedColliderToWorker {
  6727. position: Array<number>;
  6728. velocity: Array<number>;
  6729. radius: Array<number>;
  6730. }
  6731. /** Defines supported task for worker process */
  6732. enum WorkerTaskType {
  6733. /** Initialization */
  6734. INIT = 0,
  6735. /** Update of geometry */
  6736. UPDATE = 1,
  6737. /** Evaluate collision */
  6738. COLLIDE = 2
  6739. }
  6740. /** @hidden */
  6741. interface WorkerReply {
  6742. error: WorkerReplyType;
  6743. taskType: WorkerTaskType;
  6744. payload?: any;
  6745. }
  6746. /** @hidden */
  6747. interface CollisionReplyPayload {
  6748. newPosition: Array<number>;
  6749. collisionId: number;
  6750. collidedMeshUniqueId: number;
  6751. }
  6752. /** @hidden */
  6753. interface InitPayload {
  6754. }
  6755. /** @hidden */
  6756. interface CollidePayload {
  6757. collisionId: number;
  6758. collider: SerializedColliderToWorker;
  6759. maximumRetry: number;
  6760. excludedMeshUniqueId: Nullable<number>;
  6761. }
  6762. /** @hidden */
  6763. interface UpdatePayload {
  6764. updatedMeshes: {
  6765. [n: number]: SerializedMesh;
  6766. };
  6767. updatedGeometries: {
  6768. [s: string]: SerializedGeometry;
  6769. };
  6770. removedMeshes: Array<number>;
  6771. removedGeometries: Array<string>;
  6772. }
  6773. /** Defines kind of replies returned by worker */
  6774. enum WorkerReplyType {
  6775. /** Success */
  6776. SUCCESS = 0,
  6777. /** Unkown error */
  6778. UNKNOWN_ERROR = 1
  6779. }
  6780. /** @hidden */
  6781. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6782. private _scene;
  6783. private _scaledPosition;
  6784. private _scaledVelocity;
  6785. private _collisionsCallbackArray;
  6786. private _init;
  6787. private _runningUpdated;
  6788. private _worker;
  6789. private _addUpdateMeshesList;
  6790. private _addUpdateGeometriesList;
  6791. private _toRemoveMeshesArray;
  6792. private _toRemoveGeometryArray;
  6793. constructor();
  6794. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6795. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6796. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6797. init(scene: Scene): void;
  6798. destroy(): void;
  6799. onMeshAdded(mesh: AbstractMesh): void;
  6800. onMeshUpdated: (transformNode: TransformNode) => void;
  6801. onMeshRemoved(mesh: AbstractMesh): void;
  6802. onGeometryAdded(geometry: Geometry): void;
  6803. onGeometryUpdated: (geometry: Geometry) => void;
  6804. onGeometryDeleted(geometry: Geometry): void;
  6805. private _afterRender;
  6806. private _onMessageFromWorker;
  6807. }
  6808. /** @hidden */
  6809. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6810. private _scene;
  6811. private _scaledPosition;
  6812. private _scaledVelocity;
  6813. private _finalPosition;
  6814. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6815. init(scene: Scene): void;
  6816. destroy(): void;
  6817. onMeshAdded(mesh: AbstractMesh): void;
  6818. onMeshUpdated(mesh: AbstractMesh): void;
  6819. onMeshRemoved(mesh: AbstractMesh): void;
  6820. onGeometryAdded(geometry: Geometry): void;
  6821. onGeometryUpdated(geometry: Geometry): void;
  6822. onGeometryDeleted(geometry: Geometry): void;
  6823. private _collideWithWorld;
  6824. }
  6825. }
  6826. declare function importScripts(...urls: string[]): void;
  6827. declare const safePostMessage: any;
  6828. declare module BABYLON {
  6829. /** @hidden */
  6830. var WorkerIncluded: boolean;
  6831. /** @hidden */
  6832. class CollisionCache {
  6833. private _meshes;
  6834. private _geometries;
  6835. getMeshes(): {
  6836. [n: number]: SerializedMesh;
  6837. };
  6838. getGeometries(): {
  6839. [s: number]: SerializedGeometry;
  6840. };
  6841. getMesh(id: any): SerializedMesh;
  6842. addMesh(mesh: SerializedMesh): void;
  6843. removeMesh(uniqueId: number): void;
  6844. getGeometry(id: string): SerializedGeometry;
  6845. addGeometry(geometry: SerializedGeometry): void;
  6846. removeGeometry(id: string): void;
  6847. }
  6848. /** @hidden */
  6849. class CollideWorker {
  6850. collider: Collider;
  6851. private _collisionCache;
  6852. private finalPosition;
  6853. private collisionsScalingMatrix;
  6854. private collisionTranformationMatrix;
  6855. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6856. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6857. private checkCollision;
  6858. private processCollisionsForSubMeshes;
  6859. private collideForSubMesh;
  6860. private checkSubmeshCollision;
  6861. }
  6862. /** @hidden */
  6863. interface ICollisionDetector {
  6864. onInit(payload: InitPayload): void;
  6865. onUpdate(payload: UpdatePayload): void;
  6866. onCollision(payload: CollidePayload): void;
  6867. }
  6868. /** @hidden */
  6869. class CollisionDetectorTransferable implements ICollisionDetector {
  6870. private _collisionCache;
  6871. onInit(payload: InitPayload): void;
  6872. onUpdate(payload: UpdatePayload): void;
  6873. onCollision(payload: CollidePayload): void;
  6874. }
  6875. }
  6876. declare module BABYLON {
  6877. /**
  6878. * @hidden
  6879. */
  6880. class IntersectionInfo {
  6881. bu: Nullable<number>;
  6882. bv: Nullable<number>;
  6883. distance: number;
  6884. faceId: number;
  6885. subMeshId: number;
  6886. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6887. }
  6888. /**
  6889. * Information about the result of picking within a scene
  6890. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  6891. */
  6892. class PickingInfo {
  6893. /**
  6894. * If the pick collided with an object
  6895. */
  6896. hit: boolean;
  6897. /**
  6898. * Distance away where the pick collided
  6899. */
  6900. distance: number;
  6901. /**
  6902. * The location of pick collision
  6903. */
  6904. pickedPoint: Nullable<Vector3>;
  6905. /**
  6906. * The mesh corresponding the the pick collision
  6907. */
  6908. pickedMesh: Nullable<AbstractMesh>;
  6909. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6910. bu: number;
  6911. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6912. bv: number;
  6913. /** The id of the face on the mesh that was picked */
  6914. faceId: number;
  6915. /** Id of the the submesh that was picked */
  6916. subMeshId: number;
  6917. /** If a sprite was picked, this will be the sprite the pick collided with */
  6918. pickedSprite: Nullable<Sprite>;
  6919. /**
  6920. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6921. */
  6922. originMesh: Nullable<AbstractMesh>;
  6923. /**
  6924. * The ray that was used to perform the picking.
  6925. */
  6926. ray: Nullable<Ray>;
  6927. /**
  6928. * Gets the normal correspodning to the face the pick collided with
  6929. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6930. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6931. * @returns The normal correspodning to the face the pick collided with
  6932. */
  6933. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6934. /**
  6935. * Gets the texture coordinates of where the pick occured
  6936. * @returns the vector containing the coordnates of the texture
  6937. */
  6938. getTextureCoordinates(): Nullable<Vector2>;
  6939. }
  6940. }
  6941. declare module BABYLON {
  6942. /**
  6943. * Class used to store bounding box information
  6944. */
  6945. class BoundingBox implements ICullable {
  6946. /**
  6947. * Gets the 8 vectors representing the bounding box in local space
  6948. */
  6949. vectors: Vector3[];
  6950. /**
  6951. * Gets the center of the bounding box in local space
  6952. */
  6953. center: Vector3;
  6954. /**
  6955. * Gets the center of the bounding box in world space
  6956. */
  6957. centerWorld: Vector3;
  6958. /**
  6959. * Gets the extend size in local space
  6960. */
  6961. extendSize: Vector3;
  6962. /**
  6963. * Gets the extend size in world space
  6964. */
  6965. extendSizeWorld: Vector3;
  6966. /**
  6967. * Gets the OBB (object bounding box) directions
  6968. */
  6969. directions: Vector3[];
  6970. /**
  6971. * Gets the 8 vectors representing the bounding box in world space
  6972. */
  6973. vectorsWorld: Vector3[];
  6974. /**
  6975. * Gets the minimum vector in world space
  6976. */
  6977. minimumWorld: Vector3;
  6978. /**
  6979. * Gets the maximum vector in world space
  6980. */
  6981. maximumWorld: Vector3;
  6982. /**
  6983. * Gets the minimum vector in local space
  6984. */
  6985. minimum: Vector3;
  6986. /**
  6987. * Gets the maximum vector in local space
  6988. */
  6989. maximum: Vector3;
  6990. private _worldMatrix;
  6991. /**
  6992. * @hidden
  6993. */
  6994. _tag: number;
  6995. /**
  6996. * Creates a new bounding box
  6997. * @param min defines the minimum vector (in local space)
  6998. * @param max defines the maximum vector (in local space)
  6999. */
  7000. constructor(min: Vector3, max: Vector3);
  7001. /**
  7002. * Recreates the entire bounding box from scratch
  7003. * @param min defines the new minimum vector (in local space)
  7004. * @param max defines the new maximum vector (in local space)
  7005. */
  7006. reConstruct(min: Vector3, max: Vector3): void;
  7007. /**
  7008. * Scale the current bounding box by applying a scale factor
  7009. * @param factor defines the scale factor to apply
  7010. * @returns the current bounding box
  7011. */
  7012. scale(factor: number): BoundingBox;
  7013. /**
  7014. * Gets the world matrix of the bounding box
  7015. * @returns a matrix
  7016. */
  7017. getWorldMatrix(): Matrix;
  7018. /**
  7019. * Sets the world matrix stored in the bounding box
  7020. * @param matrix defines the matrix to store
  7021. * @returns current bounding box
  7022. */
  7023. setWorldMatrix(matrix: Matrix): BoundingBox;
  7024. /** @hidden */
  7025. _update(world: Matrix): void;
  7026. /**
  7027. * Tests if the bounding box is intersecting the frustum planes
  7028. * @param frustumPlanes defines the frustum planes to test
  7029. * @returns true if there is an intersection
  7030. */
  7031. isInFrustum(frustumPlanes: Plane[]): boolean;
  7032. /**
  7033. * Tests if the bounding box is entirely inside the frustum planes
  7034. * @param frustumPlanes defines the frustum planes to test
  7035. * @returns true if there is an inclusion
  7036. */
  7037. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7038. /**
  7039. * Tests if a point is inside the bounding box
  7040. * @param point defines the point to test
  7041. * @returns true if the point is inside the bounding box
  7042. */
  7043. intersectsPoint(point: Vector3): boolean;
  7044. /**
  7045. * Tests if the bounding box intersects with a bounding sphere
  7046. * @param sphere defines the sphere to test
  7047. * @returns true if there is an intersection
  7048. */
  7049. intersectsSphere(sphere: BoundingSphere): boolean;
  7050. /**
  7051. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7052. * @param min defines the min vector to use
  7053. * @param max defines the max vector to use
  7054. * @returns true if there is an intersection
  7055. */
  7056. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  7057. /**
  7058. * Tests if two bounding boxes are intersections
  7059. * @param box0 defines the first box to test
  7060. * @param box1 defines the second box to test
  7061. * @returns true if there is an intersection
  7062. */
  7063. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  7064. /**
  7065. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7066. * @param minPoint defines the minimum vector of the bounding box
  7067. * @param maxPoint defines the maximum vector of the bounding box
  7068. * @param sphereCenter defines the sphere center
  7069. * @param sphereRadius defines the sphere radius
  7070. * @returns true if there is an intersection
  7071. */
  7072. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  7073. /**
  7074. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7075. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7076. * @param frustumPlanes defines the frustum planes to test
  7077. * @return true if there is an inclusion
  7078. */
  7079. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  7080. /**
  7081. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7082. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7083. * @param frustumPlanes defines the frustum planes to test
  7084. * @return true if there is an intersection
  7085. */
  7086. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  7087. }
  7088. }
  7089. declare module BABYLON {
  7090. /**
  7091. * Interface for cullable objects
  7092. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7093. */
  7094. interface ICullable {
  7095. /**
  7096. * Checks if the object or part of the object is in the frustum
  7097. * @param frustumPlanes Camera near/planes
  7098. * @returns true if the object is in frustum otherwise false
  7099. */
  7100. isInFrustum(frustumPlanes: Plane[]): boolean;
  7101. /**
  7102. * Checks if a cullable object (mesh...) is in the camera frustum
  7103. * Unlike isInFrustum this cheks the full bounding box
  7104. * @param frustumPlanes Camera near/planes
  7105. * @returns true if the object is in frustum otherwise false
  7106. */
  7107. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7108. }
  7109. /**
  7110. * Info for a bounding data of a mesh
  7111. */
  7112. class BoundingInfo implements ICullable {
  7113. /**
  7114. * Bounding box for the mesh
  7115. */
  7116. boundingBox: BoundingBox;
  7117. /**
  7118. * Bounding sphere for the mesh
  7119. */
  7120. boundingSphere: BoundingSphere;
  7121. private _isLocked;
  7122. /**
  7123. * Constructs bounding info
  7124. * @param minimum min vector of the bounding box/sphere
  7125. * @param maximum max vector of the bounding box/sphere
  7126. */
  7127. constructor(minimum: Vector3, maximum: Vector3);
  7128. /**
  7129. * min vector of the bounding box/sphere
  7130. */
  7131. readonly minimum: Vector3;
  7132. /**
  7133. * max vector of the bounding box/sphere
  7134. */
  7135. readonly maximum: Vector3;
  7136. /**
  7137. * If the info is locked and won't be updated to avoid perf overhead
  7138. */
  7139. isLocked: boolean;
  7140. /**
  7141. * Updates the boudning sphere and box
  7142. * @param world world matrix to be used to update
  7143. */
  7144. update(world: Matrix): void;
  7145. /**
  7146. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7147. * @param center New center of the bounding info
  7148. * @param extend New extend of the bounding info
  7149. * @returns the current bounding info
  7150. */
  7151. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  7152. /**
  7153. * Scale the current bounding info by applying a scale factor
  7154. * @param factor defines the scale factor to apply
  7155. * @returns the current bounding info
  7156. */
  7157. scale(factor: number): BoundingInfo;
  7158. /**
  7159. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7160. * @param frustumPlanes defines the frustum to test
  7161. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  7162. * @returns true if the bounding info is in the frustum planes
  7163. */
  7164. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  7165. /**
  7166. * Gets the world distance between the min and max points of the bounding box
  7167. */
  7168. readonly diagonalLength: number;
  7169. /**
  7170. * Checks if a cullable object (mesh...) is in the camera frustum
  7171. * Unlike isInFrustum this cheks the full bounding box
  7172. * @param frustumPlanes Camera near/planes
  7173. * @returns true if the object is in frustum otherwise false
  7174. */
  7175. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7176. /** @hidden */
  7177. _checkCollision(collider: Collider): boolean;
  7178. /**
  7179. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7180. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7181. * @param point the point to check intersection with
  7182. * @returns if the point intersects
  7183. */
  7184. intersectsPoint(point: Vector3): boolean;
  7185. /**
  7186. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7187. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7188. * @param boundingInfo the bounding info to check intersection with
  7189. * @param precise if the intersection should be done using OBB
  7190. * @returns if the bounding info intersects
  7191. */
  7192. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  7193. }
  7194. }
  7195. declare module BABYLON {
  7196. /**
  7197. * Class used to store bounding sphere information
  7198. */
  7199. class BoundingSphere {
  7200. /**
  7201. * Gets the center of the bounding sphere in local space
  7202. */
  7203. center: Vector3;
  7204. /**
  7205. * Radius of the bounding sphere in local space
  7206. */
  7207. radius: number;
  7208. /**
  7209. * Gets the center of the bounding sphere in world space
  7210. */
  7211. centerWorld: Vector3;
  7212. /**
  7213. * Radius of the bounding sphere in world space
  7214. */
  7215. radiusWorld: number;
  7216. /**
  7217. * Gets the minimum vector in local space
  7218. */
  7219. minimum: Vector3;
  7220. /**
  7221. * Gets the maximum vector in local space
  7222. */
  7223. maximum: Vector3;
  7224. /**
  7225. * Creates a new bounding sphere
  7226. * @param min defines the minimum vector (in local space)
  7227. * @param max defines the maximum vector (in local space)
  7228. */
  7229. constructor(min: Vector3, max: Vector3);
  7230. /**
  7231. * Recreates the entire bounding sphere from scratch
  7232. * @param min defines the new minimum vector (in local space)
  7233. * @param max defines the new maximum vector (in local space)
  7234. */
  7235. reConstruct(min: Vector3, max: Vector3): void;
  7236. /**
  7237. * Scale the current bounding sphere by applying a scale factor
  7238. * @param factor defines the scale factor to apply
  7239. * @returns the current bounding box
  7240. */
  7241. scale(factor: number): BoundingSphere;
  7242. /** @hidden */
  7243. _update(world: Matrix): void;
  7244. /**
  7245. * Tests if the bounding sphere is intersecting the frustum planes
  7246. * @param frustumPlanes defines the frustum planes to test
  7247. * @returns true if there is an intersection
  7248. */
  7249. isInFrustum(frustumPlanes: Plane[]): boolean;
  7250. /**
  7251. * Tests if a point is inside the bounding sphere
  7252. * @param point defines the point to test
  7253. * @returns true if the point is inside the bounding sphere
  7254. */
  7255. intersectsPoint(point: Vector3): boolean;
  7256. /**
  7257. * Checks if two sphere intersct
  7258. * @param sphere0 sphere 0
  7259. * @param sphere1 sphere 1
  7260. * @returns true if the speres intersect
  7261. */
  7262. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  7263. }
  7264. }
  7265. declare module BABYLON {
  7266. /**
  7267. * Class representing a ray with position and direction
  7268. */
  7269. class Ray {
  7270. /** origin point */
  7271. origin: Vector3;
  7272. /** direction */
  7273. direction: Vector3;
  7274. /** length of the ray */
  7275. length: number;
  7276. private _edge1;
  7277. private _edge2;
  7278. private _pvec;
  7279. private _tvec;
  7280. private _qvec;
  7281. private _tmpRay;
  7282. /**
  7283. * Creates a new ray
  7284. * @param origin origin point
  7285. * @param direction direction
  7286. * @param length length of the ray
  7287. */
  7288. constructor(
  7289. /** origin point */
  7290. origin: Vector3,
  7291. /** direction */
  7292. direction: Vector3,
  7293. /** length of the ray */
  7294. length?: number);
  7295. /**
  7296. * Checks if the ray intersects a box
  7297. * @param minimum bound of the box
  7298. * @param maximum bound of the box
  7299. * @returns if the box was hit
  7300. */
  7301. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  7302. /**
  7303. * Checks if the ray intersects a box
  7304. * @param box the bounding box to check
  7305. * @returns if the box was hit
  7306. */
  7307. intersectsBox(box: BoundingBox): boolean;
  7308. /**
  7309. * If the ray hits a sphere
  7310. * @param sphere the bounding sphere to check
  7311. * @returns true if it hits the sphere
  7312. */
  7313. intersectsSphere(sphere: BoundingSphere): boolean;
  7314. /**
  7315. * If the ray hits a triange
  7316. * @param vertex0 triangle vertex
  7317. * @param vertex1 triangle vertex
  7318. * @param vertex2 triangle vertex
  7319. * @returns intersection information if hit
  7320. */
  7321. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  7322. /**
  7323. * Checks if ray intersects a plane
  7324. * @param plane the plane to check
  7325. * @returns the distance away it was hit
  7326. */
  7327. intersectsPlane(plane: Plane): Nullable<number>;
  7328. /**
  7329. * Checks if ray intersects a mesh
  7330. * @param mesh the mesh to check
  7331. * @param fastCheck if only the bounding box should checked
  7332. * @returns picking info of the intersecton
  7333. */
  7334. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  7335. /**
  7336. * Checks if ray intersects a mesh
  7337. * @param meshes the meshes to check
  7338. * @param fastCheck if only the bounding box should checked
  7339. * @param results array to store result in
  7340. * @returns Array of picking infos
  7341. */
  7342. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7343. private _comparePickingInfo;
  7344. private static smallnum;
  7345. private static rayl;
  7346. /**
  7347. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7348. * @param sega the first point of the segment to test the intersection against
  7349. * @param segb the second point of the segment to test the intersection against
  7350. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7351. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7352. */
  7353. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  7354. /**
  7355. * Update the ray from viewport position
  7356. * @param x position
  7357. * @param y y position
  7358. * @param viewportWidth viewport width
  7359. * @param viewportHeight viewport height
  7360. * @param world world matrix
  7361. * @param view view matrix
  7362. * @param projection projection matrix
  7363. * @returns this ray updated
  7364. */
  7365. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  7366. /**
  7367. * Creates a ray with origin and direction of 0,0,0
  7368. * @returns the new ray
  7369. */
  7370. static Zero(): Ray;
  7371. /**
  7372. * Creates a new ray from screen space and viewport
  7373. * @param x position
  7374. * @param y y position
  7375. * @param viewportWidth viewport width
  7376. * @param viewportHeight viewport height
  7377. * @param world world matrix
  7378. * @param view view matrix
  7379. * @param projection projection matrix
  7380. * @returns new ray
  7381. */
  7382. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  7383. /**
  7384. * 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
  7385. * transformed to the given world matrix.
  7386. * @param origin The origin point
  7387. * @param end The end point
  7388. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7389. * @returns the new ray
  7390. */
  7391. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  7392. /**
  7393. * Transforms a ray by a matrix
  7394. * @param ray ray to transform
  7395. * @param matrix matrix to apply
  7396. * @returns the resulting new ray
  7397. */
  7398. static Transform(ray: Ray, matrix: Matrix): Ray;
  7399. /**
  7400. * Transforms a ray by a matrix
  7401. * @param ray ray to transform
  7402. * @param matrix matrix to apply
  7403. * @param result ray to store result in
  7404. */
  7405. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  7406. }
  7407. }
  7408. declare module BABYLON {
  7409. /**
  7410. * This represents an orbital type of camera.
  7411. *
  7412. * 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.
  7413. * 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.
  7414. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7415. */
  7416. class ArcRotateCamera extends TargetCamera {
  7417. /**
  7418. * Defines the rotation angle of the camera along the longitudinal axis.
  7419. */
  7420. alpha: number;
  7421. /**
  7422. * Defines the rotation angle of the camera along the latitudinal axis.
  7423. */
  7424. beta: number;
  7425. /**
  7426. * Defines the radius of the camera from it s target point.
  7427. */
  7428. radius: number;
  7429. protected _target: Vector3;
  7430. protected _targetHost: Nullable<AbstractMesh>;
  7431. /**
  7432. * Defines the target point of the camera.
  7433. * The camera looks towards it form the radius distance.
  7434. */
  7435. target: Vector3;
  7436. /**
  7437. * Current inertia value on the longitudinal axis.
  7438. * The bigger this number the longer it will take for the camera to stop.
  7439. */
  7440. inertialAlphaOffset: number;
  7441. /**
  7442. * Current inertia value on the latitudinal axis.
  7443. * The bigger this number the longer it will take for the camera to stop.
  7444. */
  7445. inertialBetaOffset: number;
  7446. /**
  7447. * Current inertia value on the radius axis.
  7448. * The bigger this number the longer it will take for the camera to stop.
  7449. */
  7450. inertialRadiusOffset: number;
  7451. /**
  7452. * Minimum allowed angle on the longitudinal axis.
  7453. * This can help limiting how the Camera is able to move in the scene.
  7454. */
  7455. lowerAlphaLimit: Nullable<number>;
  7456. /**
  7457. * Maximum allowed angle on the longitudinal axis.
  7458. * This can help limiting how the Camera is able to move in the scene.
  7459. */
  7460. upperAlphaLimit: Nullable<number>;
  7461. /**
  7462. * Minimum allowed angle on the latitudinal axis.
  7463. * This can help limiting how the Camera is able to move in the scene.
  7464. */
  7465. lowerBetaLimit: number;
  7466. /**
  7467. * Maximum allowed angle on the latitudinal axis.
  7468. * This can help limiting how the Camera is able to move in the scene.
  7469. */
  7470. upperBetaLimit: number;
  7471. /**
  7472. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7473. * This can help limiting how the Camera is able to move in the scene.
  7474. */
  7475. lowerRadiusLimit: Nullable<number>;
  7476. /**
  7477. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7478. * This can help limiting how the Camera is able to move in the scene.
  7479. */
  7480. upperRadiusLimit: Nullable<number>;
  7481. /**
  7482. * Defines the current inertia value used during panning of the camera along the X axis.
  7483. */
  7484. inertialPanningX: number;
  7485. /**
  7486. * Defines the current inertia value used during panning of the camera along the Y axis.
  7487. */
  7488. inertialPanningY: number;
  7489. /**
  7490. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7491. * Basically if your fingers moves away from more than this distance you will be considered
  7492. * in pinch mode.
  7493. */
  7494. pinchToPanMaxDistance: number;
  7495. /**
  7496. * Defines the maximum distance the camera can pan.
  7497. * This could help keeping the cammera always in your scene.
  7498. */
  7499. panningDistanceLimit: Nullable<number>;
  7500. /**
  7501. * Defines the target of the camera before paning.
  7502. */
  7503. panningOriginTarget: Vector3;
  7504. /**
  7505. * Defines the value of the inertia used during panning.
  7506. * 0 would mean stop inertia and one would mean no decelleration at all.
  7507. */
  7508. panningInertia: number;
  7509. /**
  7510. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7511. */
  7512. angularSensibilityX: number;
  7513. /**
  7514. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7515. */
  7516. angularSensibilityY: number;
  7517. /**
  7518. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7519. */
  7520. pinchPrecision: number;
  7521. /**
  7522. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7523. * It will be used instead of pinchDeltaPrecision if different from 0.
  7524. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7525. */
  7526. pinchDeltaPercentage: number;
  7527. /**
  7528. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7529. */
  7530. panningSensibility: number;
  7531. /**
  7532. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7533. */
  7534. keysUp: number[];
  7535. /**
  7536. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7537. */
  7538. keysDown: number[];
  7539. /**
  7540. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7541. */
  7542. keysLeft: number[];
  7543. /**
  7544. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7545. */
  7546. keysRight: number[];
  7547. /**
  7548. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7549. */
  7550. wheelPrecision: number;
  7551. /**
  7552. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7553. * It will be used instead of pinchDeltaPrecision if different from 0.
  7554. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7555. */
  7556. wheelDeltaPercentage: number;
  7557. /**
  7558. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7559. */
  7560. zoomOnFactor: number;
  7561. /**
  7562. * Defines a screen offset for the camera position.
  7563. */
  7564. targetScreenOffset: Vector2;
  7565. /**
  7566. * Allows the camera to be completely reversed.
  7567. * If false the camera can not arrive upside down.
  7568. */
  7569. allowUpsideDown: boolean;
  7570. /**
  7571. * Define if double tap/click is used to restore the previously saved state of the camera.
  7572. */
  7573. useInputToRestoreState: boolean;
  7574. /** @hidden */
  7575. _viewMatrix: Matrix;
  7576. /** @hidden */
  7577. _useCtrlForPanning: boolean;
  7578. /** @hidden */
  7579. _panningMouseButton: number;
  7580. /**
  7581. * Defines the inpute associated to the camera.
  7582. */
  7583. inputs: ArcRotateCameraInputsManager;
  7584. /** @hidden */
  7585. _reset: () => void;
  7586. /**
  7587. * Defines the allowed panning axis.
  7588. */
  7589. panningAxis: Vector3;
  7590. protected _localDirection: Vector3;
  7591. protected _transformedDirection: Vector3;
  7592. private _bouncingBehavior;
  7593. /**
  7594. * Gets the bouncing behavior of the camera if it has been enabled.
  7595. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7596. */
  7597. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7598. /**
  7599. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7600. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7601. */
  7602. useBouncingBehavior: boolean;
  7603. private _framingBehavior;
  7604. /**
  7605. * Gets the framing behavior of the camera if it has been enabled.
  7606. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7607. */
  7608. readonly framingBehavior: Nullable<FramingBehavior>;
  7609. /**
  7610. * Defines if the framing behavior of the camera is enabled on the camera.
  7611. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7612. */
  7613. useFramingBehavior: boolean;
  7614. private _autoRotationBehavior;
  7615. /**
  7616. * Gets the auto rotation behavior of the camera if it has been enabled.
  7617. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7618. */
  7619. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7620. /**
  7621. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7622. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7623. */
  7624. useAutoRotationBehavior: boolean;
  7625. /**
  7626. * Observable triggered when the mesh target has been changed on the camera.
  7627. */
  7628. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7629. /**
  7630. * Event raised when the camera is colliding with a mesh.
  7631. */
  7632. onCollide: (collidedMesh: AbstractMesh) => void;
  7633. /**
  7634. * Defines whether the camera should check collision with the objects oh the scene.
  7635. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7636. */
  7637. checkCollisions: boolean;
  7638. /**
  7639. * Defines the collision radius of the camera.
  7640. * This simulates a sphere around the camera.
  7641. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7642. */
  7643. collisionRadius: Vector3;
  7644. protected _collider: Collider;
  7645. protected _previousPosition: Vector3;
  7646. protected _collisionVelocity: Vector3;
  7647. protected _newPosition: Vector3;
  7648. protected _previousAlpha: number;
  7649. protected _previousBeta: number;
  7650. protected _previousRadius: number;
  7651. protected _collisionTriggered: boolean;
  7652. protected _targetBoundingCenter: Nullable<Vector3>;
  7653. private _computationVector;
  7654. /**
  7655. * Instantiates a new ArcRotateCamera in a given scene
  7656. * @param name Defines the name of the camera
  7657. * @param alpha Defines the camera rotation along the logitudinal axis
  7658. * @param beta Defines the camera rotation along the latitudinal axis
  7659. * @param radius Defines the camera distance from its target
  7660. * @param target Defines the camera target
  7661. * @param scene Defines the scene the camera belongs to
  7662. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7663. */
  7664. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7665. /** @hidden */
  7666. _initCache(): void;
  7667. /** @hidden */
  7668. _updateCache(ignoreParentClass?: boolean): void;
  7669. protected _getTargetPosition(): Vector3;
  7670. private _storedAlpha;
  7671. private _storedBeta;
  7672. private _storedRadius;
  7673. private _storedTarget;
  7674. /**
  7675. * Stores the current state of the camera (alpha, beta, radius and target)
  7676. * @returns the camera itself
  7677. */
  7678. storeState(): Camera;
  7679. /**
  7680. * @hidden
  7681. * Restored camera state. You must call storeState() first
  7682. */
  7683. _restoreStateValues(): boolean;
  7684. /** @hidden */
  7685. _isSynchronizedViewMatrix(): boolean;
  7686. /**
  7687. * Attached controls to the current camera.
  7688. * @param element Defines the element the controls should be listened from
  7689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7690. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7691. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7692. */
  7693. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7694. /**
  7695. * Detach the current controls from the camera.
  7696. * The camera will stop reacting to inputs.
  7697. * @param element Defines the element to stop listening the inputs from
  7698. */
  7699. detachControl(element: HTMLElement): void;
  7700. /** @hidden */
  7701. _checkInputs(): void;
  7702. protected _checkLimits(): void;
  7703. /**
  7704. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7705. */
  7706. rebuildAnglesAndRadius(): void;
  7707. /**
  7708. * Use a position to define the current camera related information like aplha, beta and radius
  7709. * @param position Defines the position to set the camera at
  7710. */
  7711. setPosition(position: Vector3): void;
  7712. /**
  7713. * Defines the target the camera should look at.
  7714. * This will automatically adapt alpha beta and radius to fit within the new target.
  7715. * @param target Defines the new target as a Vector or a mesh
  7716. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7717. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7718. */
  7719. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7720. /** @hidden */
  7721. _getViewMatrix(): Matrix;
  7722. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7723. /**
  7724. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7725. * @param meshes Defines the mesh to zoom on
  7726. * @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)
  7727. */
  7728. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7729. /**
  7730. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7731. * The target will be changed but the radius
  7732. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7733. * @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)
  7734. */
  7735. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7736. min: Vector3;
  7737. max: Vector3;
  7738. distance: number;
  7739. }, doNotUpdateMaxZ?: boolean): void;
  7740. /**
  7741. * @override
  7742. * Override Camera.createRigCamera
  7743. */
  7744. createRigCamera(name: string, cameraIndex: number): Camera;
  7745. /**
  7746. * @hidden
  7747. * @override
  7748. * Override Camera._updateRigCameras
  7749. */
  7750. _updateRigCameras(): void;
  7751. /**
  7752. * Destroy the camera and release the current resources hold by it.
  7753. */
  7754. dispose(): void;
  7755. /**
  7756. * Gets the current object class name.
  7757. * @return the class name
  7758. */
  7759. getClassName(): string;
  7760. }
  7761. }
  7762. declare module BABYLON {
  7763. /**
  7764. * Default Inputs manager for the ArcRotateCamera.
  7765. * It groups all the default supported inputs for ease of use.
  7766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7767. */
  7768. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7769. /**
  7770. * Instantiates a new ArcRotateCameraInputsManager.
  7771. * @param camera Defines the camera the inputs belong to
  7772. */
  7773. constructor(camera: ArcRotateCamera);
  7774. /**
  7775. * Add mouse wheel input support to the input manager.
  7776. * @returns the current input manager
  7777. */
  7778. addMouseWheel(): ArcRotateCameraInputsManager;
  7779. /**
  7780. * Add pointers input support to the input manager.
  7781. * @returns the current input manager
  7782. */
  7783. addPointers(): ArcRotateCameraInputsManager;
  7784. /**
  7785. * Add keyboard input support to the input manager.
  7786. * @returns the current input manager
  7787. */
  7788. addKeyboard(): ArcRotateCameraInputsManager;
  7789. /**
  7790. * Add orientation input support to the input manager.
  7791. * @returns the current input manager
  7792. */
  7793. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7794. }
  7795. }
  7796. declare module BABYLON {
  7797. /**
  7798. * This is the base class of all the camera used in the application.
  7799. * @see http://doc.babylonjs.com/features/cameras
  7800. */
  7801. class Camera extends Node {
  7802. /**
  7803. * This is the default projection mode used by the cameras.
  7804. * It helps recreating a feeling of perspective and better appreciate depth.
  7805. * This is the best way to simulate real life cameras.
  7806. */
  7807. static readonly PERSPECTIVE_CAMERA: number;
  7808. /**
  7809. * This helps creating camera with an orthographic mode.
  7810. * 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.
  7811. */
  7812. static readonly ORTHOGRAPHIC_CAMERA: number;
  7813. /**
  7814. * This is the default FOV mode for perspective cameras.
  7815. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7816. */
  7817. static readonly FOVMODE_VERTICAL_FIXED: number;
  7818. /**
  7819. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7820. */
  7821. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7822. /**
  7823. * This specifies ther is no need for a camera rig.
  7824. * Basically only one eye is rendered corresponding to the camera.
  7825. */
  7826. static readonly RIG_MODE_NONE: number;
  7827. /**
  7828. * Simulates a camera Rig with one blue eye and one red eye.
  7829. * This can be use with 3d blue and red glasses.
  7830. */
  7831. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7832. /**
  7833. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7834. */
  7835. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7836. /**
  7837. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7838. */
  7839. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7840. /**
  7841. * Defines that both eyes of the camera will be rendered over under each other.
  7842. */
  7843. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7844. /**
  7845. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7846. */
  7847. static readonly RIG_MODE_VR: number;
  7848. /**
  7849. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7850. */
  7851. static readonly RIG_MODE_WEBVR: number;
  7852. /**
  7853. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7854. */
  7855. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7856. /**
  7857. * @hidden
  7858. * Might be removed once multiview will be a thing
  7859. */
  7860. static UseAlternateWebVRRendering: boolean;
  7861. /**
  7862. * Define the input manager associated with the camera.
  7863. */
  7864. inputs: CameraInputsManager<Camera>;
  7865. /**
  7866. * Define the current local position of the camera in the scene
  7867. */
  7868. position: Vector3;
  7869. /**
  7870. * The vector the camera should consider as up.
  7871. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7872. */
  7873. upVector: Vector3;
  7874. /**
  7875. * Define the current limit on the left side for an orthographic camera
  7876. * In scene unit
  7877. */
  7878. orthoLeft: Nullable<number>;
  7879. /**
  7880. * Define the current limit on the right side for an orthographic camera
  7881. * In scene unit
  7882. */
  7883. orthoRight: Nullable<number>;
  7884. /**
  7885. * Define the current limit on the bottom side for an orthographic camera
  7886. * In scene unit
  7887. */
  7888. orthoBottom: Nullable<number>;
  7889. /**
  7890. * Define the current limit on the top side for an orthographic camera
  7891. * In scene unit
  7892. */
  7893. orthoTop: Nullable<number>;
  7894. /**
  7895. * Field Of View is set in Radians. (default is 0.8)
  7896. */
  7897. fov: number;
  7898. /**
  7899. * Define the minimum distance the camera can see from.
  7900. * This is important to note that the depth buffer are not infinite and the closer it starts
  7901. * the more your scene might encounter depth fighting issue.
  7902. */
  7903. minZ: number;
  7904. /**
  7905. * Define the maximum distance the camera can see to.
  7906. * This is important to note that the depth buffer are not infinite and the further it end
  7907. * the more your scene might encounter depth fighting issue.
  7908. */
  7909. maxZ: number;
  7910. /**
  7911. * Define the default inertia of the camera.
  7912. * This helps giving a smooth feeling to the camera movement.
  7913. */
  7914. inertia: number;
  7915. /**
  7916. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7917. */
  7918. mode: number;
  7919. /**
  7920. * Define wether the camera is intermediate.
  7921. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7922. */
  7923. isIntermediate: boolean;
  7924. /**
  7925. * Define the viewport of the camera.
  7926. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7927. */
  7928. viewport: Viewport;
  7929. /**
  7930. * Restricts the camera to viewing objects with the same layerMask.
  7931. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7932. */
  7933. layerMask: number;
  7934. /**
  7935. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7936. */
  7937. fovMode: number;
  7938. /**
  7939. * Rig mode of the camera.
  7940. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7941. * This is normally controlled byt the camera themselves as internal use.
  7942. */
  7943. cameraRigMode: number;
  7944. /**
  7945. * Defines the distance between both "eyes" in case of a RIG
  7946. */
  7947. interaxialDistance: number;
  7948. /**
  7949. * Defines if stereoscopic rendering is done side by side or over under.
  7950. */
  7951. isStereoscopicSideBySide: boolean;
  7952. /**
  7953. * Defines the list of custom render target the camera should render to.
  7954. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7955. * else in the scene.
  7956. */
  7957. customRenderTargets: RenderTargetTexture[];
  7958. /**
  7959. * Observable triggered when the camera view matrix has changed.
  7960. */
  7961. onViewMatrixChangedObservable: Observable<Camera>;
  7962. /**
  7963. * Observable triggered when the camera Projection matrix has changed.
  7964. */
  7965. onProjectionMatrixChangedObservable: Observable<Camera>;
  7966. /**
  7967. * Observable triggered when the inputs have been processed.
  7968. */
  7969. onAfterCheckInputsObservable: Observable<Camera>;
  7970. /**
  7971. * Observable triggered when reset has been called and applied to the camera.
  7972. */
  7973. onRestoreStateObservable: Observable<Camera>;
  7974. /** @hidden */
  7975. _cameraRigParams: any;
  7976. /** @hidden */
  7977. _rigCameras: Camera[];
  7978. /** @hidden */
  7979. _rigPostProcess: Nullable<PostProcess>;
  7980. protected _webvrViewMatrix: Matrix;
  7981. /** @hidden */
  7982. _skipRendering: boolean;
  7983. /** @hidden */
  7984. _alternateCamera: Camera;
  7985. /** @hidden */
  7986. _projectionMatrix: Matrix;
  7987. /** @hidden */
  7988. _postProcesses: Nullable<PostProcess>[];
  7989. /** @hidden */
  7990. _activeMeshes: SmartArray<AbstractMesh>;
  7991. protected _globalPosition: Vector3;
  7992. private _computedViewMatrix;
  7993. private _doNotComputeProjectionMatrix;
  7994. private _transformMatrix;
  7995. private _frustumPlanes;
  7996. private _refreshFrustumPlanes;
  7997. private _storedFov;
  7998. private _stateStored;
  7999. /**
  8000. * Instantiates a new camera object.
  8001. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  8002. * @see http://doc.babylonjs.com/features/cameras
  8003. * @param name Defines the name of the camera in the scene
  8004. * @param position Defines the position of the camera
  8005. * @param scene Defines the scene the camera belongs too
  8006. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  8007. */
  8008. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8009. /**
  8010. * Store current camera state (fov, position, etc..)
  8011. * @returns the camera
  8012. */
  8013. storeState(): Camera;
  8014. /**
  8015. * Restores the camera state values if it has been stored. You must call storeState() first
  8016. */
  8017. protected _restoreStateValues(): boolean;
  8018. /**
  8019. * Restored camera state. You must call storeState() first.
  8020. * @returns true if restored and false otherwise
  8021. */
  8022. restoreState(): boolean;
  8023. /**
  8024. * Gets the class name of the camera.
  8025. * @returns the class name
  8026. */
  8027. getClassName(): string;
  8028. /**
  8029. * Gets a string representation of the camera usefull for debug purpose.
  8030. * @param fullDetails Defines that a more verboe level of logging is required
  8031. * @returns the string representation
  8032. */
  8033. toString(fullDetails?: boolean): string;
  8034. /**
  8035. * Gets the current world space position of the camera.
  8036. */
  8037. readonly globalPosition: Vector3;
  8038. /**
  8039. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  8040. * @returns the active meshe list
  8041. */
  8042. getActiveMeshes(): SmartArray<AbstractMesh>;
  8043. /**
  8044. * Check wether a mesh is part of the current active mesh list of the camera
  8045. * @param mesh Defines the mesh to check
  8046. * @returns true if active, false otherwise
  8047. */
  8048. isActiveMesh(mesh: Mesh): boolean;
  8049. /**
  8050. * Is this camera ready to be used/rendered
  8051. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8052. * @return true if the camera is ready
  8053. */
  8054. isReady(completeCheck?: boolean): boolean;
  8055. /** @hidden */
  8056. _initCache(): void;
  8057. /** @hidden */
  8058. _updateCache(ignoreParentClass?: boolean): void;
  8059. /** @hidden */
  8060. _isSynchronized(): boolean;
  8061. /** @hidden */
  8062. _isSynchronizedViewMatrix(): boolean;
  8063. /** @hidden */
  8064. _isSynchronizedProjectionMatrix(): boolean;
  8065. /**
  8066. * Attach the input controls to a specific dom element to get the input from.
  8067. * @param element Defines the element the controls should be listened from
  8068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8069. */
  8070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8071. /**
  8072. * Detach the current controls from the specified dom element.
  8073. * @param element Defines the element to stop listening the inputs from
  8074. */
  8075. detachControl(element: HTMLElement): void;
  8076. /**
  8077. * Update the camera state according to the different inputs gathered during the frame.
  8078. */
  8079. update(): void;
  8080. /** @hidden */
  8081. _checkInputs(): void;
  8082. /** @hidden */
  8083. readonly rigCameras: Camera[];
  8084. /**
  8085. * Gets the post process used by the rig cameras
  8086. */
  8087. readonly rigPostProcess: Nullable<PostProcess>;
  8088. /**
  8089. * Internal, gets the first post proces.
  8090. * @returns the first post process to be run on this camera.
  8091. */
  8092. _getFirstPostProcess(): Nullable<PostProcess>;
  8093. private _cascadePostProcessesToRigCams;
  8094. /**
  8095. * Attach a post process to the camera.
  8096. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8097. * @param postProcess The post process to attach to the camera
  8098. * @param insertAt The position of the post process in case several of them are in use in the scene
  8099. * @returns the position the post process has been inserted at
  8100. */
  8101. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8102. /**
  8103. * Detach a post process to the camera.
  8104. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8105. * @param postProcess The post process to detach from the camera
  8106. */
  8107. detachPostProcess(postProcess: PostProcess): void;
  8108. /**
  8109. * Gets the current world matrix of the camera
  8110. */
  8111. getWorldMatrix(): Matrix;
  8112. /** @hidden */
  8113. protected _getViewMatrix(): Matrix;
  8114. /**
  8115. * Gets the current view matrix of the camera.
  8116. * @param force forces the camera to recompute the matrix without looking at the cached state
  8117. * @returns the view matrix
  8118. */
  8119. getViewMatrix(force?: boolean): Matrix;
  8120. /**
  8121. * Freeze the projection matrix.
  8122. * It will prevent the cache check of the camera projection compute and can speed up perf
  8123. * if no parameter of the camera are meant to change
  8124. * @param projection Defines manually a projection if necessary
  8125. */
  8126. freezeProjectionMatrix(projection?: Matrix): void;
  8127. /**
  8128. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8129. */
  8130. unfreezeProjectionMatrix(): void;
  8131. /**
  8132. * Gets the current projection matrix of the camera.
  8133. * @param force forces the camera to recompute the matrix without looking at the cached state
  8134. * @returns the projection matrix
  8135. */
  8136. getProjectionMatrix(force?: boolean): Matrix;
  8137. /**
  8138. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8139. * @returns a Matrix
  8140. */
  8141. getTransformationMatrix(): Matrix;
  8142. private _updateFrustumPlanes;
  8143. /**
  8144. * Checks if a cullable object (mesh...) is in the camera frustum
  8145. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8146. * @param target The object to check
  8147. * @returns true if the object is in frustum otherwise false
  8148. */
  8149. isInFrustum(target: ICullable): boolean;
  8150. /**
  8151. * Checks if a cullable object (mesh...) is in the camera frustum
  8152. * Unlike isInFrustum this cheks the full bounding box
  8153. * @param target The object to check
  8154. * @returns true if the object is in frustum otherwise false
  8155. */
  8156. isCompletelyInFrustum(target: ICullable): boolean;
  8157. /**
  8158. * Gets a ray in the forward direction from the camera.
  8159. * @param length Defines the length of the ray to create
  8160. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8161. * @param origin Defines the start point of the ray which defaults to the camera position
  8162. * @returns the forward ray
  8163. */
  8164. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8165. /**
  8166. * Releases resources associated with this node.
  8167. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8168. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8169. */
  8170. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8171. /**
  8172. * Gets the left camera of a rig setup in case of Rigged Camera
  8173. */
  8174. readonly leftCamera: Nullable<FreeCamera>;
  8175. /**
  8176. * Gets the right camera of a rig setup in case of Rigged Camera
  8177. */
  8178. readonly rightCamera: Nullable<FreeCamera>;
  8179. /**
  8180. * Gets the left camera target of a rig setup in case of Rigged Camera
  8181. * @returns the target position
  8182. */
  8183. getLeftTarget(): Nullable<Vector3>;
  8184. /**
  8185. * Gets the right camera target of a rig setup in case of Rigged Camera
  8186. * @returns the target position
  8187. */
  8188. getRightTarget(): Nullable<Vector3>;
  8189. /**
  8190. * @hidden
  8191. */
  8192. setCameraRigMode(mode: number, rigParams: any): void;
  8193. private _getVRProjectionMatrix;
  8194. protected _updateCameraRotationMatrix(): void;
  8195. protected _updateWebVRCameraRotationMatrix(): void;
  8196. /**
  8197. * This function MUST be overwritten by the different WebVR cameras available.
  8198. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8199. */
  8200. protected _getWebVRProjectionMatrix(): Matrix;
  8201. /**
  8202. * This function MUST be overwritten by the different WebVR cameras available.
  8203. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8204. */
  8205. protected _getWebVRViewMatrix(): Matrix;
  8206. /** @hidden */
  8207. setCameraRigParameter(name: string, value: any): void;
  8208. /**
  8209. * needs to be overridden by children so sub has required properties to be copied
  8210. * @hidden
  8211. */
  8212. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8213. /**
  8214. * May need to be overridden by children
  8215. * @hidden
  8216. */
  8217. _updateRigCameras(): void;
  8218. /** @hidden */
  8219. _setupInputs(): void;
  8220. /**
  8221. * Serialiaze the camera setup to a json represention
  8222. * @returns the JSON representation
  8223. */
  8224. serialize(): any;
  8225. /**
  8226. * Clones the current camera.
  8227. * @param name The cloned camera name
  8228. * @returns the cloned camera
  8229. */
  8230. clone(name: string): Camera;
  8231. /**
  8232. * Gets the direction of the camera relative to a given local axis.
  8233. * @param localAxis Defines the reference axis to provide a relative direction.
  8234. * @return the direction
  8235. */
  8236. getDirection(localAxis: Vector3): Vector3;
  8237. /**
  8238. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8239. * @param localAxis Defines the reference axis to provide a relative direction.
  8240. * @param result Defines the vector to store the result in
  8241. */
  8242. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8243. /**
  8244. * Gets a camera constructor for a given camera type
  8245. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8246. * @param name The name of the camera the result will be able to instantiate
  8247. * @param scene The scene the result will construct the camera in
  8248. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8249. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8250. * @returns a factory method to construc the camera
  8251. */
  8252. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8253. /**
  8254. * Compute the world matrix of the camera.
  8255. * @returns the camera workd matrix
  8256. */
  8257. computeWorldMatrix(): Matrix;
  8258. /**
  8259. * Parse a JSON and creates the camera from the parsed information
  8260. * @param parsedCamera The JSON to parse
  8261. * @param scene The scene to instantiate the camera in
  8262. * @returns the newly constructed camera
  8263. */
  8264. static Parse(parsedCamera: any, scene: Scene): Camera;
  8265. }
  8266. }
  8267. declare module BABYLON {
  8268. /**
  8269. * @ignore
  8270. * This is a list of all the different input types that are available in the application.
  8271. * Fo instance: ArcRotateCameraGamepadInput...
  8272. */
  8273. var CameraInputTypes: {};
  8274. /**
  8275. * This is the contract to implement in order to create a new input class.
  8276. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8277. */
  8278. interface ICameraInput<TCamera extends Camera> {
  8279. /**
  8280. * Defines the camera the input is attached to.
  8281. */
  8282. camera: Nullable<TCamera>;
  8283. /**
  8284. * Gets the class name of the current intput.
  8285. * @returns the class name
  8286. */
  8287. getClassName(): string;
  8288. /**
  8289. * Get the friendly name associated with the input class.
  8290. * @returns the input friendly name
  8291. */
  8292. getSimpleName(): string;
  8293. /**
  8294. * Attach the input controls to a specific dom element to get the input from.
  8295. * @param element Defines the element the controls should be listened from
  8296. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8297. */
  8298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8299. /**
  8300. * Detach the current controls from the specified dom element.
  8301. * @param element Defines the element to stop listening the inputs from
  8302. */
  8303. detachControl(element: Nullable<HTMLElement>): void;
  8304. /**
  8305. * Update the current camera state depending on the inputs that have been used this frame.
  8306. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8307. */
  8308. checkInputs?: () => void;
  8309. }
  8310. /**
  8311. * Represents a map of input types to input instance or input index to input instance.
  8312. */
  8313. interface CameraInputsMap<TCamera extends Camera> {
  8314. /**
  8315. * Accessor to the input by input type.
  8316. */
  8317. [name: string]: ICameraInput<TCamera>;
  8318. /**
  8319. * Accessor to the input by input index.
  8320. */
  8321. [idx: number]: ICameraInput<TCamera>;
  8322. }
  8323. /**
  8324. * This represents the input manager used within a camera.
  8325. * It helps dealing with all the different kind of input attached to a camera.
  8326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8327. */
  8328. class CameraInputsManager<TCamera extends Camera> {
  8329. /**
  8330. * Defines the list of inputs attahed to the camera.
  8331. */
  8332. attached: CameraInputsMap<TCamera>;
  8333. /**
  8334. * Defines the dom element the camera is collecting inputs from.
  8335. * This is null if the controls have not been attached.
  8336. */
  8337. attachedElement: Nullable<HTMLElement>;
  8338. /**
  8339. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8340. */
  8341. noPreventDefault: boolean;
  8342. /**
  8343. * Defined the camera the input manager belongs to.
  8344. */
  8345. camera: TCamera;
  8346. /**
  8347. * Update the current camera state depending on the inputs that have been used this frame.
  8348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8349. */
  8350. checkInputs: () => void;
  8351. /**
  8352. * Instantiate a new Camera Input Manager.
  8353. * @param camera Defines the camera the input manager blongs to
  8354. */
  8355. constructor(camera: TCamera);
  8356. /**
  8357. * Add an input method to a camera
  8358. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8359. * @param input camera input method
  8360. */
  8361. add(input: ICameraInput<TCamera>): void;
  8362. /**
  8363. * Remove a specific input method from a camera
  8364. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8365. * @param inputToRemove camera input method
  8366. */
  8367. remove(inputToRemove: ICameraInput<TCamera>): void;
  8368. /**
  8369. * Remove a specific input type from a camera
  8370. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8371. * @param inputType the type of the input to remove
  8372. */
  8373. removeByType(inputType: string): void;
  8374. private _addCheckInputs;
  8375. /**
  8376. * Attach the input controls to the currently attached dom element to listen the events from.
  8377. * @param input Defines the input to attach
  8378. */
  8379. attachInput(input: ICameraInput<TCamera>): void;
  8380. /**
  8381. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8382. * @param element Defines the dom element to collect the events from
  8383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8384. */
  8385. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8386. /**
  8387. * Detach the current manager inputs controls from a specific dom element.
  8388. * @param element Defines the dom element to collect the events from
  8389. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8390. */
  8391. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8392. /**
  8393. * Rebuild the dynamic inputCheck function from the current list of
  8394. * defined inputs in the manager.
  8395. */
  8396. rebuildInputCheck(): void;
  8397. /**
  8398. * Remove all attached input methods from a camera
  8399. */
  8400. clear(): void;
  8401. /**
  8402. * Serialize the current input manager attached to a camera.
  8403. * This ensures than once parsed,
  8404. * the input associated to the camera will be identical to the current ones
  8405. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8406. */
  8407. serialize(serializedCamera: any): void;
  8408. /**
  8409. * Parses an input manager serialized JSON to restore the previous list of inputs
  8410. * and states associated to a camera.
  8411. * @param parsedCamera Defines the JSON to parse
  8412. */
  8413. parse(parsedCamera: any): void;
  8414. }
  8415. }
  8416. declare module BABYLON {
  8417. /**
  8418. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8419. * being tilted forward or back and left or right.
  8420. */
  8421. class DeviceOrientationCamera extends FreeCamera {
  8422. private _initialQuaternion;
  8423. private _quaternionCache;
  8424. /**
  8425. * Creates a new device orientation camera
  8426. * @param name The name of the camera
  8427. * @param position The start position camera
  8428. * @param scene The scene the camera belongs to
  8429. */
  8430. constructor(name: string, position: Vector3, scene: Scene);
  8431. /**
  8432. * Gets the current instance class name ("DeviceOrientationCamera").
  8433. * This helps avoiding instanceof at run time.
  8434. * @returns the class name
  8435. */
  8436. getClassName(): string;
  8437. /**
  8438. * @hidden
  8439. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8440. */
  8441. _checkInputs(): void;
  8442. /**
  8443. * Reset the camera to its default orientation on the specified axis only.
  8444. * @param axis The axis to reset
  8445. */
  8446. resetToCurrentRotation(axis?: Axis): void;
  8447. }
  8448. }
  8449. declare module BABYLON {
  8450. /**
  8451. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8452. * an arc rotate version arcFollowCamera are available.
  8453. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8454. */
  8455. class FollowCamera extends TargetCamera {
  8456. /**
  8457. * Distance the follow camera should follow an object at
  8458. */
  8459. radius: number;
  8460. /**
  8461. * Define a rotation offset between the camera and the object it follows
  8462. */
  8463. rotationOffset: number;
  8464. /**
  8465. * Define a height offset between the camera and the object it follows.
  8466. * It can help following an object from the top (like a car chaing a plane)
  8467. */
  8468. heightOffset: number;
  8469. /**
  8470. * Define how fast the camera can accelerate to follow it s target.
  8471. */
  8472. cameraAcceleration: number;
  8473. /**
  8474. * Define the speed limit of the camera following an object.
  8475. */
  8476. maxCameraSpeed: number;
  8477. /**
  8478. * Define the target of the camera.
  8479. */
  8480. lockedTarget: Nullable<AbstractMesh>;
  8481. /**
  8482. * Instantiates the follow camera.
  8483. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8484. * @param name Define the name of the camera in the scene
  8485. * @param position Define the position of the camera
  8486. * @param scene Define the scene the camera belong to
  8487. * @param lockedTarget Define the target of the camera
  8488. */
  8489. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8490. private _follow;
  8491. /** @hidden */
  8492. _checkInputs(): void;
  8493. /**
  8494. * Gets the camera class name.
  8495. * @returns the class name
  8496. */
  8497. getClassName(): string;
  8498. }
  8499. /**
  8500. * Arc Rotate version of the follow camera.
  8501. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8502. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8503. */
  8504. class ArcFollowCamera extends TargetCamera {
  8505. /** The longitudinal angle of the camera */
  8506. alpha: number;
  8507. /** The latitudinal angle of the camera */
  8508. beta: number;
  8509. /** The radius of the camera from its target */
  8510. radius: number;
  8511. /** Define the camera target (the messh it should follow) */
  8512. target: Nullable<AbstractMesh>;
  8513. private _cartesianCoordinates;
  8514. /**
  8515. * Instantiates a new ArcFollowCamera
  8516. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8517. * @param name Define the name of the camera
  8518. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8519. * @param beta Define the rotation angle of the camera around the elevation axis
  8520. * @param radius Define the radius of the camera from its target point
  8521. * @param target Define the target of the camera
  8522. * @param scene Define the scene the camera belongs to
  8523. */
  8524. constructor(name: string,
  8525. /** The longitudinal angle of the camera */
  8526. alpha: number,
  8527. /** The latitudinal angle of the camera */
  8528. beta: number,
  8529. /** The radius of the camera from its target */
  8530. radius: number,
  8531. /** Define the camera target (the messh it should follow) */
  8532. target: Nullable<AbstractMesh>, scene: Scene);
  8533. private _follow;
  8534. /** @hidden */
  8535. _checkInputs(): void;
  8536. /**
  8537. * Returns the class name of the object.
  8538. * It is mostly used internally for serialization purposes.
  8539. */
  8540. getClassName(): string;
  8541. }
  8542. }
  8543. declare module BABYLON {
  8544. /**
  8545. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8546. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8547. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8548. */
  8549. class FreeCamera extends TargetCamera {
  8550. /**
  8551. * Define the collision ellipsoid of the camera.
  8552. * This is helpful to simulate a camera body like the player body around the camera
  8553. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8554. */
  8555. ellipsoid: Vector3;
  8556. /**
  8557. * Define an offset for the position of the ellipsoid around the camera.
  8558. * This can be helpful to determine the center of the body near the gravity center of the body
  8559. * instead of its head.
  8560. */
  8561. ellipsoidOffset: Vector3;
  8562. /**
  8563. * Enable or disable collisions of the camera with the rest of the scene objects.
  8564. */
  8565. checkCollisions: boolean;
  8566. /**
  8567. * Enable or disable gravity on the camera.
  8568. */
  8569. applyGravity: boolean;
  8570. /**
  8571. * Define the input manager associated to the camera.
  8572. */
  8573. inputs: FreeCameraInputsManager;
  8574. /**
  8575. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8576. * Higher values reduce sensitivity.
  8577. */
  8578. /**
  8579. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8580. * Higher values reduce sensitivity.
  8581. */
  8582. angularSensibility: number;
  8583. /**
  8584. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8585. */
  8586. keysUp: number[];
  8587. /**
  8588. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8589. */
  8590. keysDown: number[];
  8591. /**
  8592. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8593. */
  8594. keysLeft: number[];
  8595. /**
  8596. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8597. */
  8598. keysRight: number[];
  8599. /**
  8600. * Event raised when the camera collide with a mesh in the scene.
  8601. */
  8602. onCollide: (collidedMesh: AbstractMesh) => void;
  8603. private _collider;
  8604. private _needMoveForGravity;
  8605. private _oldPosition;
  8606. private _diffPosition;
  8607. private _newPosition;
  8608. /** @hidden */
  8609. _localDirection: Vector3;
  8610. /** @hidden */
  8611. _transformedDirection: Vector3;
  8612. /**
  8613. * Instantiates a Free Camera.
  8614. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8615. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8616. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8617. * @param name Define the name of the camera in the scene
  8618. * @param position Define the start position of the camera in the scene
  8619. * @param scene Define the scene the camera belongs to
  8620. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8621. */
  8622. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8623. /**
  8624. * Attached controls to the current camera.
  8625. * @param element Defines the element the controls should be listened from
  8626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8627. */
  8628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8629. /**
  8630. * Detach the current controls from the camera.
  8631. * The camera will stop reacting to inputs.
  8632. * @param element Defines the element to stop listening the inputs from
  8633. */
  8634. detachControl(element: HTMLElement): void;
  8635. private _collisionMask;
  8636. /**
  8637. * Define a collision mask to limit the list of object the camera can collide with
  8638. */
  8639. collisionMask: number;
  8640. /** @hidden */
  8641. _collideWithWorld(displacement: Vector3): void;
  8642. private _onCollisionPositionChange;
  8643. /** @hidden */
  8644. _checkInputs(): void;
  8645. /** @hidden */
  8646. _decideIfNeedsToMove(): boolean;
  8647. /** @hidden */
  8648. _updatePosition(): void;
  8649. /**
  8650. * Destroy the camera and release the current resources hold by it.
  8651. */
  8652. dispose(): void;
  8653. /**
  8654. * Gets the current object class name.
  8655. * @return the class name
  8656. */
  8657. getClassName(): string;
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Default Inputs manager for the FreeCamera.
  8663. * It groups all the default supported inputs for ease of use.
  8664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8665. */
  8666. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8667. /**
  8668. * Instantiates a new FreeCameraInputsManager.
  8669. * @param camera Defines the camera the inputs belong to
  8670. */
  8671. constructor(camera: FreeCamera);
  8672. /**
  8673. * Add keyboard input support to the input manager.
  8674. * @returns the current input manager
  8675. */
  8676. addKeyboard(): FreeCameraInputsManager;
  8677. /**
  8678. * Add mouse input support to the input manager.
  8679. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8680. * @returns the current input manager
  8681. */
  8682. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8683. /**
  8684. * Add orientation input support to the input manager.
  8685. * @returns the current input manager
  8686. */
  8687. addDeviceOrientation(): FreeCameraInputsManager;
  8688. /**
  8689. * Add touch input support to the input manager.
  8690. * @returns the current input manager
  8691. */
  8692. addTouch(): FreeCameraInputsManager;
  8693. /**
  8694. * Add virtual joystick input support to the input manager.
  8695. * @returns the current input manager
  8696. */
  8697. addVirtualJoystick(): FreeCameraInputsManager;
  8698. }
  8699. }
  8700. declare module BABYLON {
  8701. /**
  8702. * This represents a FPS type of camera. This is only here for back compat purpose.
  8703. * Please use the UniversalCamera instead as both are identical.
  8704. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8705. */
  8706. class GamepadCamera extends UniversalCamera {
  8707. /**
  8708. * Instantiates a new Gamepad Camera
  8709. * This represents a FPS type of camera. This is only here for back compat purpose.
  8710. * Please use the UniversalCamera instead as both are identical.
  8711. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8712. * @param name Define the name of the camera in the scene
  8713. * @param position Define the start position of the camera in the scene
  8714. * @param scene Define the scene the camera belongs to
  8715. */
  8716. constructor(name: string, position: Vector3, scene: Scene);
  8717. /**
  8718. * Gets the current object class name.
  8719. * @return the class name
  8720. */
  8721. getClassName(): string;
  8722. }
  8723. }
  8724. declare module BABYLON {
  8725. /**
  8726. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8727. * This is the base of the follow, arc rotate cameras and Free camera
  8728. * @see http://doc.babylonjs.com/features/cameras
  8729. */
  8730. class TargetCamera extends Camera {
  8731. /**
  8732. * Define the current direction the camera is moving to
  8733. */
  8734. cameraDirection: Vector3;
  8735. /**
  8736. * Define the current rotation the camera is rotating to
  8737. */
  8738. cameraRotation: Vector2;
  8739. /**
  8740. * Define the current rotation of the camera
  8741. */
  8742. rotation: Vector3;
  8743. /**
  8744. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8745. */
  8746. rotationQuaternion: Quaternion;
  8747. /**
  8748. * Define the current speed of the camera
  8749. */
  8750. speed: number;
  8751. /**
  8752. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8753. * around all axis.
  8754. */
  8755. noRotationConstraint: boolean;
  8756. /**
  8757. * Define the current target of the camera as an object or a position.
  8758. */
  8759. lockedTarget: any;
  8760. /** @hidden */
  8761. _currentTarget: Vector3;
  8762. /** @hidden */
  8763. _viewMatrix: Matrix;
  8764. /** @hidden */
  8765. _camMatrix: Matrix;
  8766. /** @hidden */
  8767. _cameraTransformMatrix: Matrix;
  8768. /** @hidden */
  8769. _cameraRotationMatrix: Matrix;
  8770. private _rigCamTransformMatrix;
  8771. /** @hidden */
  8772. _referencePoint: Vector3;
  8773. /** @hidden */
  8774. _transformedReferencePoint: Vector3;
  8775. protected _globalCurrentTarget: Vector3;
  8776. protected _globalCurrentUpVector: Vector3;
  8777. /** @hidden */
  8778. _reset: () => void;
  8779. private _defaultUp;
  8780. /**
  8781. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8782. * This is the base of the follow, arc rotate cameras and Free camera
  8783. * @see http://doc.babylonjs.com/features/cameras
  8784. * @param name Defines the name of the camera in the scene
  8785. * @param position Defines the start position of the camera in the scene
  8786. * @param scene Defines the scene the camera belongs to
  8787. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8788. */
  8789. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8790. /**
  8791. * Gets the position in front of the camera at a given distance.
  8792. * @param distance The distance from the camera we want the position to be
  8793. * @returns the position
  8794. */
  8795. getFrontPosition(distance: number): Vector3;
  8796. /** @hidden */
  8797. _getLockedTargetPosition(): Nullable<Vector3>;
  8798. private _storedPosition;
  8799. private _storedRotation;
  8800. private _storedRotationQuaternion;
  8801. /**
  8802. * Store current camera state of the camera (fov, position, rotation, etc..)
  8803. * @returns the camera
  8804. */
  8805. storeState(): Camera;
  8806. /**
  8807. * Restored camera state. You must call storeState() first
  8808. * @returns whether it was successful or not
  8809. * @hidden
  8810. */
  8811. _restoreStateValues(): boolean;
  8812. /** @hidden */
  8813. _initCache(): void;
  8814. /** @hidden */
  8815. _updateCache(ignoreParentClass?: boolean): void;
  8816. /** @hidden */
  8817. _isSynchronizedViewMatrix(): boolean;
  8818. /** @hidden */
  8819. _computeLocalCameraSpeed(): number;
  8820. /** @hidden */
  8821. setTarget(target: Vector3): void;
  8822. /**
  8823. * Return the current target position of the camera. This value is expressed in local space.
  8824. * @returns the target position
  8825. */
  8826. getTarget(): Vector3;
  8827. /** @hidden */
  8828. _decideIfNeedsToMove(): boolean;
  8829. /** @hidden */
  8830. _updatePosition(): void;
  8831. /** @hidden */
  8832. _checkInputs(): void;
  8833. protected _updateCameraRotationMatrix(): void;
  8834. /**
  8835. * 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)
  8836. * @returns the current camera
  8837. */
  8838. private _rotateUpVectorWithCameraRotationMatrix;
  8839. private _cachedRotationZ;
  8840. private _cachedQuaternionRotationZ;
  8841. /** @hidden */
  8842. _getViewMatrix(): Matrix;
  8843. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8844. /**
  8845. * @hidden
  8846. */
  8847. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8848. /**
  8849. * @hidden
  8850. */
  8851. _updateRigCameras(): void;
  8852. private _getRigCamPosition;
  8853. /**
  8854. * Gets the current object class name.
  8855. * @return the class name
  8856. */
  8857. getClassName(): string;
  8858. }
  8859. }
  8860. declare module BABYLON {
  8861. /**
  8862. * This represents a FPS type of camera controlled by touch.
  8863. * This is like a universal camera minus the Gamepad controls.
  8864. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8865. */
  8866. class TouchCamera extends FreeCamera {
  8867. /**
  8868. * Defines the touch sensibility for rotation.
  8869. * The higher the faster.
  8870. */
  8871. touchAngularSensibility: number;
  8872. /**
  8873. * Defines the touch sensibility for move.
  8874. * The higher the faster.
  8875. */
  8876. touchMoveSensibility: number;
  8877. /**
  8878. * Instantiates a new touch camera.
  8879. * This represents a FPS type of camera controlled by touch.
  8880. * This is like a universal camera minus the Gamepad controls.
  8881. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8882. * @param name Define the name of the camera in the scene
  8883. * @param position Define the start position of the camera in the scene
  8884. * @param scene Define the scene the camera belongs to
  8885. */
  8886. constructor(name: string, position: Vector3, scene: Scene);
  8887. /**
  8888. * Gets the current object class name.
  8889. * @return the class name
  8890. */
  8891. getClassName(): string;
  8892. /** @hidden */
  8893. _setupInputs(): void;
  8894. }
  8895. }
  8896. declare module BABYLON {
  8897. /**
  8898. * 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,
  8899. * which still works and will still be found in many Playgrounds.
  8900. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8901. */
  8902. class UniversalCamera extends TouchCamera {
  8903. /**
  8904. * Defines the gamepad rotation sensiblity.
  8905. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8906. */
  8907. gamepadAngularSensibility: number;
  8908. /**
  8909. * Defines the gamepad move sensiblity.
  8910. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8911. */
  8912. gamepadMoveSensibility: number;
  8913. /**
  8914. * 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,
  8915. * which still works and will still be found in many Playgrounds.
  8916. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8917. * @param name Define the name of the camera in the scene
  8918. * @param position Define the start position of the camera in the scene
  8919. * @param scene Define the scene the camera belongs to
  8920. */
  8921. constructor(name: string, position: Vector3, scene: Scene);
  8922. /**
  8923. * Gets the current object class name.
  8924. * @return the class name
  8925. */
  8926. getClassName(): string;
  8927. }
  8928. }
  8929. declare module BABYLON {
  8930. /**
  8931. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8932. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8933. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8934. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8935. */
  8936. class VirtualJoysticksCamera extends FreeCamera {
  8937. /**
  8938. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  8939. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8940. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8941. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8942. * @param name Define the name of the camera in the scene
  8943. * @param position Define the start position of the camera in the scene
  8944. * @param scene Define the scene the camera belongs to
  8945. */
  8946. constructor(name: string, position: Vector3, scene: Scene);
  8947. /**
  8948. * Gets the current object class name.
  8949. * @return the class name
  8950. */
  8951. getClassName(): string;
  8952. }
  8953. }
  8954. interface VRDisplay extends EventTarget {
  8955. /**
  8956. * Dictionary of capabilities describing the VRDisplay.
  8957. */
  8958. readonly capabilities: VRDisplayCapabilities;
  8959. /**
  8960. * z-depth defining the far plane of the eye view frustum
  8961. * enables mapping of values in the render target depth
  8962. * attachment to scene coordinates. Initially set to 10000.0.
  8963. */
  8964. depthFar: number;
  8965. /**
  8966. * z-depth defining the near plane of the eye view frustum
  8967. * enables mapping of values in the render target depth
  8968. * attachment to scene coordinates. Initially set to 0.01.
  8969. */
  8970. depthNear: number;
  8971. /**
  8972. * An identifier for this distinct VRDisplay. Used as an
  8973. * association point in the Gamepad API.
  8974. */
  8975. readonly displayId: number;
  8976. /**
  8977. * A display name, a user-readable name identifying it.
  8978. */
  8979. readonly displayName: string;
  8980. readonly isConnected: boolean;
  8981. readonly isPresenting: boolean;
  8982. /**
  8983. * If this VRDisplay supports room-scale experiences, the optional
  8984. * stage attribute contains details on the room-scale parameters.
  8985. */
  8986. readonly stageParameters: VRStageParameters | null;
  8987. /**
  8988. * Passing the value returned by `requestAnimationFrame` to
  8989. * `cancelAnimationFrame` will unregister the callback.
  8990. * @param handle Define the hanle of the request to cancel
  8991. */
  8992. cancelAnimationFrame(handle: number): void;
  8993. /**
  8994. * Stops presenting to the VRDisplay.
  8995. * @returns a promise to know when it stopped
  8996. */
  8997. exitPresent(): Promise<void>;
  8998. /**
  8999. * Return the current VREyeParameters for the given eye.
  9000. * @param whichEye Define the eye we want the parameter for
  9001. * @returns the eye parameters
  9002. */
  9003. getEyeParameters(whichEye: string): VREyeParameters;
  9004. /**
  9005. * Populates the passed VRFrameData with the information required to render
  9006. * the current frame.
  9007. * @param frameData Define the data structure to populate
  9008. * @returns true if ok otherwise false
  9009. */
  9010. getFrameData(frameData: VRFrameData): boolean;
  9011. /**
  9012. * Get the layers currently being presented.
  9013. * @returns the list of VR layers
  9014. */
  9015. getLayers(): VRLayer[];
  9016. /**
  9017. * Return a VRPose containing the future predicted pose of the VRDisplay
  9018. * when the current frame will be presented. The value returned will not
  9019. * change until JavaScript has returned control to the browser.
  9020. *
  9021. * The VRPose will contain the position, orientation, velocity,
  9022. * and acceleration of each of these properties.
  9023. * @returns the pose object
  9024. */
  9025. getPose(): VRPose;
  9026. /**
  9027. * Return the current instantaneous pose of the VRDisplay, with no
  9028. * prediction applied.
  9029. * @returns the current instantaneous pose
  9030. */
  9031. getImmediatePose(): VRPose;
  9032. /**
  9033. * The callback passed to `requestAnimationFrame` will be called
  9034. * any time a new frame should be rendered. When the VRDisplay is
  9035. * presenting the callback will be called at the native refresh
  9036. * rate of the HMD. When not presenting this function acts
  9037. * identically to how window.requestAnimationFrame acts. Content should
  9038. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9039. * asynchronously from other displays and at differing refresh rates.
  9040. * @param callback Define the eaction to run next frame
  9041. * @returns the request handle it
  9042. */
  9043. requestAnimationFrame(callback: FrameRequestCallback): number;
  9044. /**
  9045. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9046. * Repeat calls while already presenting will update the VRLayers being displayed.
  9047. * @param layers Define the list of layer to present
  9048. * @returns a promise to know when the request has been fulfilled
  9049. */
  9050. requestPresent(layers: VRLayer[]): Promise<void>;
  9051. /**
  9052. * Reset the pose for this display, treating its current position and
  9053. * orientation as the "origin/zero" values. VRPose.position,
  9054. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9055. * updated when calling resetPose(). This should be called in only
  9056. * sitting-space experiences.
  9057. */
  9058. resetPose(): void;
  9059. /**
  9060. * The VRLayer provided to the VRDisplay will be captured and presented
  9061. * in the HMD. Calling this function has the same effect on the source
  9062. * canvas as any other operation that uses its source image, and canvases
  9063. * created without preserveDrawingBuffer set to true will be cleared.
  9064. * @param pose Define the pose to submit
  9065. */
  9066. submitFrame(pose?: VRPose): void;
  9067. }
  9068. declare var VRDisplay: {
  9069. prototype: VRDisplay;
  9070. new (): VRDisplay;
  9071. };
  9072. interface VRLayer {
  9073. leftBounds?: number[] | Float32Array | null;
  9074. rightBounds?: number[] | Float32Array | null;
  9075. source?: HTMLCanvasElement | null;
  9076. }
  9077. interface VRDisplayCapabilities {
  9078. readonly canPresent: boolean;
  9079. readonly hasExternalDisplay: boolean;
  9080. readonly hasOrientation: boolean;
  9081. readonly hasPosition: boolean;
  9082. readonly maxLayers: number;
  9083. }
  9084. interface VREyeParameters {
  9085. /** @deprecated */
  9086. readonly fieldOfView: VRFieldOfView;
  9087. readonly offset: Float32Array;
  9088. readonly renderHeight: number;
  9089. readonly renderWidth: number;
  9090. }
  9091. interface VRFieldOfView {
  9092. readonly downDegrees: number;
  9093. readonly leftDegrees: number;
  9094. readonly rightDegrees: number;
  9095. readonly upDegrees: number;
  9096. }
  9097. interface VRFrameData {
  9098. readonly leftProjectionMatrix: Float32Array;
  9099. readonly leftViewMatrix: Float32Array;
  9100. readonly pose: VRPose;
  9101. readonly rightProjectionMatrix: Float32Array;
  9102. readonly rightViewMatrix: Float32Array;
  9103. readonly timestamp: number;
  9104. }
  9105. interface VRPose {
  9106. readonly angularAcceleration: Float32Array | null;
  9107. readonly angularVelocity: Float32Array | null;
  9108. readonly linearAcceleration: Float32Array | null;
  9109. readonly linearVelocity: Float32Array | null;
  9110. readonly orientation: Float32Array | null;
  9111. readonly position: Float32Array | null;
  9112. readonly timestamp: number;
  9113. }
  9114. interface VRStageParameters {
  9115. sittingToStandingTransform?: Float32Array;
  9116. sizeX?: number;
  9117. sizeY?: number;
  9118. }
  9119. interface Navigator {
  9120. getVRDisplays(): Promise<VRDisplay[]>;
  9121. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9122. }
  9123. interface Window {
  9124. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9125. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9126. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9127. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9128. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9129. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9130. }
  9131. interface Gamepad {
  9132. readonly displayId: number;
  9133. }
  9134. /**
  9135. * Module Debug contains the (visual) components to debug a scene correctly
  9136. */
  9137. declare module BABYLON.Debug {
  9138. /**
  9139. * The Axes viewer will show 3 axes in a specific point in space
  9140. */
  9141. class AxesViewer {
  9142. private _xline;
  9143. private _yline;
  9144. private _zline;
  9145. private _xmesh;
  9146. private _ymesh;
  9147. private _zmesh;
  9148. /**
  9149. * Gets the hosting scene
  9150. */
  9151. scene: Nullable<Scene>;
  9152. /**
  9153. * Gets or sets a number used to scale line length
  9154. */
  9155. scaleLines: number;
  9156. /**
  9157. * Creates a new AxesViewer
  9158. * @param scene defines the hosting scene
  9159. * @param scaleLines defines a number used to scale line length (1 by default)
  9160. */
  9161. constructor(scene: Scene, scaleLines?: number);
  9162. /**
  9163. * Force the viewer to update
  9164. * @param position defines the position of the viewer
  9165. * @param xaxis defines the x axis of the viewer
  9166. * @param yaxis defines the y axis of the viewer
  9167. * @param zaxis defines the z axis of the viewer
  9168. */
  9169. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9170. /** Releases resources */
  9171. dispose(): void;
  9172. }
  9173. }
  9174. declare module BABYLON.Debug {
  9175. /**
  9176. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9177. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9178. */
  9179. class BoneAxesViewer extends AxesViewer {
  9180. /**
  9181. * Gets or sets the target mesh where to display the axes viewer
  9182. */
  9183. mesh: Nullable<Mesh>;
  9184. /**
  9185. * Gets or sets the target bone where to display the axes viewer
  9186. */
  9187. bone: Nullable<Bone>;
  9188. /** Gets current position */
  9189. pos: Vector3;
  9190. /** Gets direction of X axis */
  9191. xaxis: Vector3;
  9192. /** Gets direction of Y axis */
  9193. yaxis: Vector3;
  9194. /** Gets direction of Z axis */
  9195. zaxis: Vector3;
  9196. /**
  9197. * Creates a new BoneAxesViewer
  9198. * @param scene defines the hosting scene
  9199. * @param bone defines the target bone
  9200. * @param mesh defines the target mesh
  9201. * @param scaleLines defines a scaling factor for line length (1 by default)
  9202. */
  9203. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9204. /**
  9205. * Force the viewer to update
  9206. */
  9207. update(): void;
  9208. /** Releases resources */
  9209. dispose(): void;
  9210. }
  9211. }
  9212. declare module BABYLON {
  9213. interface Scene {
  9214. /**
  9215. * @hidden
  9216. * Backing field
  9217. */
  9218. _debugLayer: DebugLayer;
  9219. /**
  9220. * Gets the debug layer (aka Inspector) associated with the scene
  9221. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9222. */
  9223. debugLayer: DebugLayer;
  9224. }
  9225. /**
  9226. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9227. * what is happening in your scene
  9228. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9229. */
  9230. class DebugLayer {
  9231. /**
  9232. * Define the url to get the inspector script from.
  9233. * By default it uses the babylonjs CDN.
  9234. * @ignoreNaming
  9235. */
  9236. static InspectorURL: string;
  9237. private _scene;
  9238. private _inspector;
  9239. private BJSINSPECTOR;
  9240. /**
  9241. * Observable triggered when a property is changed through the inspector.
  9242. */
  9243. onPropertyChangedObservable: Observable<{
  9244. object: any;
  9245. property: string;
  9246. value: any;
  9247. initialValue: any;
  9248. }>;
  9249. /**
  9250. * Instantiates a new debug layer.
  9251. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9252. * what is happening in your scene
  9253. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9254. * @param scene Defines the scene to inspect
  9255. */
  9256. constructor(scene: Scene);
  9257. /** Creates the inspector window. */
  9258. private _createInspector;
  9259. /**
  9260. * Get if the inspector is visible or not.
  9261. * @returns true if visible otherwise, false
  9262. */
  9263. isVisible(): boolean;
  9264. /**
  9265. * Hide the inspector and close its window.
  9266. */
  9267. hide(): void;
  9268. /**
  9269. *
  9270. * Launch the debugLayer.
  9271. *
  9272. * initialTab:
  9273. * | Value | Tab Name |
  9274. * | --- | --- |
  9275. * | 0 | Scene |
  9276. * | 1 | Console |
  9277. * | 2 | Stats |
  9278. * | 3 | Textures |
  9279. * | 4 | Mesh |
  9280. * | 5 | Light |
  9281. * | 6 | Material |
  9282. * | 7 | GLTF |
  9283. * | 8 | GUI |
  9284. * | 9 | Physics |
  9285. * | 10 | Camera |
  9286. * | 11 | Audio |
  9287. *
  9288. * @param config Define the configuration of the inspector
  9289. */
  9290. show(config?: {
  9291. popup?: boolean;
  9292. initialTab?: number | string;
  9293. parentElement?: HTMLElement;
  9294. newColors?: {
  9295. backgroundColor?: string;
  9296. backgroundColorLighter?: string;
  9297. backgroundColorLighter2?: string;
  9298. backgroundColorLighter3?: string;
  9299. color?: string;
  9300. colorTop?: string;
  9301. colorBot?: string;
  9302. };
  9303. }): void;
  9304. /**
  9305. * Gets the active tab
  9306. * @return the index of the active tab or -1 if the inspector is hidden
  9307. */
  9308. getActiveTab(): number;
  9309. }
  9310. }
  9311. declare module BABYLON.Debug {
  9312. /**
  9313. * Used to show the physics impostor around the specific mesh
  9314. */
  9315. class PhysicsViewer {
  9316. /** @hidden */
  9317. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9318. /** @hidden */
  9319. protected _meshes: Array<Nullable<AbstractMesh>>;
  9320. /** @hidden */
  9321. protected _scene: Nullable<Scene>;
  9322. /** @hidden */
  9323. protected _numMeshes: number;
  9324. /** @hidden */
  9325. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9326. private _renderFunction;
  9327. private _debugBoxMesh;
  9328. private _debugSphereMesh;
  9329. private _debugMaterial;
  9330. /**
  9331. * Creates a new PhysicsViewer
  9332. * @param scene defines the hosting scene
  9333. */
  9334. constructor(scene: Scene);
  9335. /** @hidden */
  9336. protected _updateDebugMeshes(): void;
  9337. /**
  9338. * Renders a specified physic impostor
  9339. * @param impostor defines the impostor to render
  9340. */
  9341. showImpostor(impostor: PhysicsImpostor): void;
  9342. /**
  9343. * Hides a specified physic impostor
  9344. * @param impostor defines the impostor to hide
  9345. */
  9346. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9347. private _getDebugMaterial;
  9348. private _getDebugBoxMesh;
  9349. private _getDebugSphereMesh;
  9350. private _getDebugMesh;
  9351. /** Releases all resources */
  9352. dispose(): void;
  9353. }
  9354. }
  9355. declare module BABYLON {
  9356. /**
  9357. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9358. * in order to better appreciate the issue one might have.
  9359. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9360. */
  9361. class RayHelper {
  9362. /**
  9363. * Defines the ray we are currently tryin to visualize.
  9364. */
  9365. ray: Nullable<Ray>;
  9366. private _renderPoints;
  9367. private _renderLine;
  9368. private _renderFunction;
  9369. private _scene;
  9370. private _updateToMeshFunction;
  9371. private _attachedToMesh;
  9372. private _meshSpaceDirection;
  9373. private _meshSpaceOrigin;
  9374. /**
  9375. * Helper function to create a colored helper in a scene in one line.
  9376. * @param ray Defines the ray we are currently tryin to visualize
  9377. * @param scene Defines the scene the ray is used in
  9378. * @param color Defines the color we want to see the ray in
  9379. * @returns The newly created ray helper.
  9380. */
  9381. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9382. /**
  9383. * Instantiate a new ray helper.
  9384. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9385. * in order to better appreciate the issue one might have.
  9386. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9387. * @param ray Defines the ray we are currently tryin to visualize
  9388. */
  9389. constructor(ray: Ray);
  9390. /**
  9391. * Shows the ray we are willing to debug.
  9392. * @param scene Defines the scene the ray needs to be rendered in
  9393. * @param color Defines the color the ray needs to be rendered in
  9394. */
  9395. show(scene: Scene, color?: Color3): void;
  9396. /**
  9397. * Hides the ray we are debugging.
  9398. */
  9399. hide(): void;
  9400. private _render;
  9401. /**
  9402. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9403. * @param mesh Defines the mesh we want the helper attached to
  9404. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9405. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9406. * @param length Defines the length of the ray
  9407. */
  9408. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9409. /**
  9410. * Detach the ray helper from the mesh it has previously been attached to.
  9411. */
  9412. detachFromMesh(): void;
  9413. private _updateToMesh;
  9414. /**
  9415. * Dispose the helper and release its associated resources.
  9416. */
  9417. dispose(): void;
  9418. }
  9419. }
  9420. declare module BABYLON.Debug {
  9421. /**
  9422. * Class used to render a debug view of a given skeleton
  9423. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9424. */
  9425. class SkeletonViewer {
  9426. /** defines the skeleton to render */
  9427. skeleton: Skeleton;
  9428. /** defines the mesh attached to the skeleton */
  9429. mesh: AbstractMesh;
  9430. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9431. autoUpdateBonesMatrices: boolean;
  9432. /** defines the rendering group id to use with the viewer */
  9433. renderingGroupId: number;
  9434. /** Gets or sets the color used to render the skeleton */
  9435. color: Color3;
  9436. private _scene;
  9437. private _debugLines;
  9438. private _debugMesh;
  9439. private _isEnabled;
  9440. private _renderFunction;
  9441. /**
  9442. * Creates a new SkeletonViewer
  9443. * @param skeleton defines the skeleton to render
  9444. * @param mesh defines the mesh attached to the skeleton
  9445. * @param scene defines the hosting scene
  9446. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9447. * @param renderingGroupId defines the rendering group id to use with the viewer
  9448. */
  9449. constructor(
  9450. /** defines the skeleton to render */
  9451. skeleton: Skeleton,
  9452. /** defines the mesh attached to the skeleton */
  9453. mesh: AbstractMesh, scene: Scene,
  9454. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9455. autoUpdateBonesMatrices?: boolean,
  9456. /** defines the rendering group id to use with the viewer */
  9457. renderingGroupId?: number);
  9458. /** Gets or sets a boolean indicating if the viewer is enabled */
  9459. isEnabled: boolean;
  9460. private _getBonePosition;
  9461. private _getLinesForBonesWithLength;
  9462. private _getLinesForBonesNoLength;
  9463. /** Update the viewer to sync with current skeleton state */
  9464. update(): void;
  9465. /** Release associated resources */
  9466. dispose(): void;
  9467. }
  9468. }
  9469. declare module BABYLON {
  9470. /**
  9471. * Interface for attribute information associated with buffer instanciation
  9472. */
  9473. class InstancingAttributeInfo {
  9474. /**
  9475. * Index/offset of the attribute in the vertex shader
  9476. */
  9477. index: number;
  9478. /**
  9479. * size of the attribute, 1, 2, 3 or 4
  9480. */
  9481. attributeSize: number;
  9482. /**
  9483. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9484. * default is FLOAT
  9485. */
  9486. attribyteType: number;
  9487. /**
  9488. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9489. */
  9490. normalized: boolean;
  9491. /**
  9492. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9493. */
  9494. offset: number;
  9495. /**
  9496. * Name of the GLSL attribute, for debugging purpose only
  9497. */
  9498. attributeName: string;
  9499. }
  9500. /**
  9501. * Define options used to create a render target texture
  9502. */
  9503. class RenderTargetCreationOptions {
  9504. /**
  9505. * Specifies is mipmaps must be generated
  9506. */
  9507. generateMipMaps?: boolean;
  9508. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9509. generateDepthBuffer?: boolean;
  9510. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9511. generateStencilBuffer?: boolean;
  9512. /** Defines texture type (int by default) */
  9513. type?: number;
  9514. /** Defines sampling mode (trilinear by default) */
  9515. samplingMode?: number;
  9516. /** Defines format (RGBA by default) */
  9517. format?: number;
  9518. }
  9519. /**
  9520. * Define options used to create a depth texture
  9521. */
  9522. class DepthTextureCreationOptions {
  9523. /** Specifies whether or not a stencil should be allocated in the texture */
  9524. generateStencil?: boolean;
  9525. /** Specifies whether or not bilinear filtering is enable on the texture */
  9526. bilinearFiltering?: boolean;
  9527. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9528. comparisonFunction?: number;
  9529. /** Specifies if the created texture is a cube texture */
  9530. isCube?: boolean;
  9531. }
  9532. /**
  9533. * Class used to describe the capabilities of the engine relatively to the current browser
  9534. */
  9535. class EngineCapabilities {
  9536. /** Maximum textures units per fragment shader */
  9537. maxTexturesImageUnits: number;
  9538. /** Maximum texture units per vertex shader */
  9539. maxVertexTextureImageUnits: number;
  9540. /** Maximum textures units in the entire pipeline */
  9541. maxCombinedTexturesImageUnits: number;
  9542. /** Maximum texture size */
  9543. maxTextureSize: number;
  9544. /** Maximum cube texture size */
  9545. maxCubemapTextureSize: number;
  9546. /** Maximum render texture size */
  9547. maxRenderTextureSize: number;
  9548. /** Maximum number of vertex attributes */
  9549. maxVertexAttribs: number;
  9550. /** Maximum number of varyings */
  9551. maxVaryingVectors: number;
  9552. /** Maximum number of uniforms per vertex shader */
  9553. maxVertexUniformVectors: number;
  9554. /** Maximum number of uniforms per fragment shader */
  9555. maxFragmentUniformVectors: number;
  9556. /** Defines if standard derivates (dx/dy) are supported */
  9557. standardDerivatives: boolean;
  9558. /** Defines if s3tc texture compression is supported */
  9559. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9560. /** Defines if pvrtc texture compression is supported */
  9561. pvrtc: any;
  9562. /** Defines if etc1 texture compression is supported */
  9563. etc1: any;
  9564. /** Defines if etc2 texture compression is supported */
  9565. etc2: any;
  9566. /** Defines if astc texture compression is supported */
  9567. astc: any;
  9568. /** Defines if float textures are supported */
  9569. textureFloat: boolean;
  9570. /** Defines if vertex array objects are supported */
  9571. vertexArrayObject: boolean;
  9572. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9573. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9574. /** Gets the maximum level of anisotropy supported */
  9575. maxAnisotropy: number;
  9576. /** Defines if instancing is supported */
  9577. instancedArrays: boolean;
  9578. /** Defines if 32 bits indices are supported */
  9579. uintIndices: boolean;
  9580. /** Defines if high precision shaders are supported */
  9581. highPrecisionShaderSupported: boolean;
  9582. /** Defines if depth reading in the fragment shader is supported */
  9583. fragmentDepthSupported: boolean;
  9584. /** Defines if float texture linear filtering is supported*/
  9585. textureFloatLinearFiltering: boolean;
  9586. /** Defines if rendering to float textures is supported */
  9587. textureFloatRender: boolean;
  9588. /** Defines if half float textures are supported*/
  9589. textureHalfFloat: boolean;
  9590. /** Defines if half float texture linear filtering is supported*/
  9591. textureHalfFloatLinearFiltering: boolean;
  9592. /** Defines if rendering to half float textures is supported */
  9593. textureHalfFloatRender: boolean;
  9594. /** Defines if textureLOD shader command is supported */
  9595. textureLOD: boolean;
  9596. /** Defines if draw buffers extension is supported */
  9597. drawBuffersExtension: boolean;
  9598. /** Defines if depth textures are supported */
  9599. depthTextureExtension: boolean;
  9600. /** Defines if float color buffer are supported */
  9601. colorBufferFloat: boolean;
  9602. /** Gets disjoint timer query extension (null if not supported) */
  9603. timerQuery: EXT_disjoint_timer_query;
  9604. /** Defines if timestamp can be used with timer query */
  9605. canUseTimestampForTimerQuery: boolean;
  9606. }
  9607. /** Interface defining initialization parameters for Engine class */
  9608. interface EngineOptions extends WebGLContextAttributes {
  9609. /**
  9610. * Defines if the engine should no exceed a specified device ratio
  9611. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9612. */
  9613. limitDeviceRatio?: number;
  9614. /**
  9615. * Defines if webvr should be enabled automatically
  9616. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9617. */
  9618. autoEnableWebVR?: boolean;
  9619. /**
  9620. * Defines if webgl2 should be turned off even if supported
  9621. * @see http://doc.babylonjs.com/features/webgl2
  9622. */
  9623. disableWebGL2Support?: boolean;
  9624. /**
  9625. * Defines if webaudio should be initialized as well
  9626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9627. */
  9628. audioEngine?: boolean;
  9629. /**
  9630. * Defines if animations should run using a deterministic lock step
  9631. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9632. */
  9633. deterministicLockstep?: boolean;
  9634. /** Defines the maximum steps to use with deterministic lock step mode */
  9635. lockstepMaxSteps?: number;
  9636. /**
  9637. * Defines that engine should ignore context lost events
  9638. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9639. */
  9640. doNotHandleContextLost?: boolean;
  9641. }
  9642. /**
  9643. * Defines the interface used by display changed events
  9644. */
  9645. interface IDisplayChangedEventArgs {
  9646. /** Gets the vrDisplay object (if any) */
  9647. vrDisplay: Nullable<any>;
  9648. /** Gets a boolean indicating if webVR is supported */
  9649. vrSupported: boolean;
  9650. }
  9651. /**
  9652. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  9653. */
  9654. class Engine {
  9655. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  9656. static ExceptionList: ({
  9657. key: string;
  9658. capture: string;
  9659. captureConstraint: number;
  9660. targets: string[];
  9661. } | {
  9662. key: string;
  9663. capture: null;
  9664. captureConstraint: null;
  9665. targets: string[];
  9666. })[];
  9667. /** Gets the list of created engines */
  9668. static Instances: Engine[];
  9669. /**
  9670. * Gets the latest created engine
  9671. */
  9672. static readonly LastCreatedEngine: Nullable<Engine>;
  9673. /**
  9674. * Gets the latest created scene
  9675. */
  9676. static readonly LastCreatedScene: Nullable<Scene>;
  9677. /**
  9678. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  9679. * @param flag defines which part of the materials must be marked as dirty
  9680. * @param predicate defines a predicate used to filter which materials should be affected
  9681. */
  9682. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  9683. /**
  9684. * Hidden
  9685. */
  9686. static _TextureLoaders: IInternalTextureLoader[];
  9687. /** Defines that alpha blending is disabled */
  9688. static readonly ALPHA_DISABLE: number;
  9689. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  9690. static readonly ALPHA_ADD: number;
  9691. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  9692. static readonly ALPHA_COMBINE: number;
  9693. /** Defines that alpha blending to DEST - SRC * DEST */
  9694. static readonly ALPHA_SUBTRACT: number;
  9695. /** Defines that alpha blending to SRC * DEST */
  9696. static readonly ALPHA_MULTIPLY: number;
  9697. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  9698. static readonly ALPHA_MAXIMIZED: number;
  9699. /** Defines that alpha blending to SRC + DEST */
  9700. static readonly ALPHA_ONEONE: number;
  9701. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  9702. static readonly ALPHA_PREMULTIPLIED: number;
  9703. /**
  9704. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  9705. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  9706. */
  9707. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  9708. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  9709. static readonly ALPHA_INTERPOLATE: number;
  9710. /**
  9711. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  9712. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  9713. */
  9714. static readonly ALPHA_SCREENMODE: number;
  9715. /** Defines that the ressource is not delayed*/
  9716. static readonly DELAYLOADSTATE_NONE: number;
  9717. /** Defines that the ressource was successfully delay loaded */
  9718. static readonly DELAYLOADSTATE_LOADED: number;
  9719. /** Defines that the ressource is currently delay loading */
  9720. static readonly DELAYLOADSTATE_LOADING: number;
  9721. /** Defines that the ressource is delayed and has not started loading */
  9722. static readonly DELAYLOADSTATE_NOTLOADED: number;
  9723. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  9724. static readonly NEVER: number;
  9725. /** 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 */
  9726. static readonly ALWAYS: number;
  9727. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  9728. static readonly LESS: number;
  9729. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  9730. static readonly EQUAL: number;
  9731. /** 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 */
  9732. static readonly LEQUAL: number;
  9733. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  9734. static readonly GREATER: number;
  9735. /** 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 */
  9736. static readonly GEQUAL: number;
  9737. /** 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 */
  9738. static readonly NOTEQUAL: number;
  9739. /** Passed to stencilOperation to specify that stencil value must be kept */
  9740. static readonly KEEP: number;
  9741. /** Passed to stencilOperation to specify that stencil value must be replaced */
  9742. static readonly REPLACE: number;
  9743. /** Passed to stencilOperation to specify that stencil value must be incremented */
  9744. static readonly INCR: number;
  9745. /** Passed to stencilOperation to specify that stencil value must be decremented */
  9746. static readonly DECR: number;
  9747. /** Passed to stencilOperation to specify that stencil value must be inverted */
  9748. static readonly INVERT: number;
  9749. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  9750. static readonly INCR_WRAP: number;
  9751. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  9752. static readonly DECR_WRAP: number;
  9753. /** Texture is not repeating outside of 0..1 UVs */
  9754. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  9755. /** Texture is repeating outside of 0..1 UVs */
  9756. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  9757. /** Texture is repeating and mirrored */
  9758. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  9759. /** ALPHA */
  9760. static readonly TEXTUREFORMAT_ALPHA: number;
  9761. /** LUMINANCE */
  9762. static readonly TEXTUREFORMAT_LUMINANCE: number;
  9763. /** LUMINANCE_ALPHA */
  9764. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  9765. /** RGB */
  9766. static readonly TEXTUREFORMAT_RGB: number;
  9767. /** RGBA */
  9768. static readonly TEXTUREFORMAT_RGBA: number;
  9769. /** RED */
  9770. static readonly TEXTUREFORMAT_RED: number;
  9771. /** RED (2nd reference) */
  9772. static readonly TEXTUREFORMAT_R: number;
  9773. /** RG */
  9774. static readonly TEXTUREFORMAT_RG: number;
  9775. /** RED_INTEGER */
  9776. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  9777. /** RED_INTEGER (2nd reference) */
  9778. static readonly TEXTUREFORMAT_R_INTEGER: number;
  9779. /** RG_INTEGER */
  9780. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  9781. /** RGB_INTEGER */
  9782. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  9783. /** RGBA_INTEGER */
  9784. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  9785. /** UNSIGNED_BYTE */
  9786. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  9787. /** UNSIGNED_BYTE (2nd reference) */
  9788. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  9789. /** FLOAT */
  9790. static readonly TEXTURETYPE_FLOAT: number;
  9791. /** HALF_FLOAT */
  9792. static readonly TEXTURETYPE_HALF_FLOAT: number;
  9793. /** BYTE */
  9794. static readonly TEXTURETYPE_BYTE: number;
  9795. /** SHORT */
  9796. static readonly TEXTURETYPE_SHORT: number;
  9797. /** UNSIGNED_SHORT */
  9798. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  9799. /** INT */
  9800. static readonly TEXTURETYPE_INT: number;
  9801. /** UNSIGNED_INT */
  9802. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  9803. /** UNSIGNED_SHORT_4_4_4_4 */
  9804. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  9805. /** UNSIGNED_SHORT_5_5_5_1 */
  9806. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  9807. /** UNSIGNED_SHORT_5_6_5 */
  9808. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  9809. /** UNSIGNED_INT_2_10_10_10_REV */
  9810. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  9811. /** UNSIGNED_INT_24_8 */
  9812. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  9813. /** UNSIGNED_INT_10F_11F_11F_REV */
  9814. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  9815. /** UNSIGNED_INT_5_9_9_9_REV */
  9816. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  9817. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  9818. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9819. /** nearest is mag = nearest and min = nearest and mip = linear */
  9820. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  9821. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9822. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  9823. /** Trilinear is mag = linear and min = linear and mip = linear */
  9824. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  9825. /** nearest is mag = nearest and min = nearest and mip = linear */
  9826. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  9827. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9828. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  9829. /** Trilinear is mag = linear and min = linear and mip = linear */
  9830. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  9831. /** mag = nearest and min = nearest and mip = nearest */
  9832. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  9833. /** mag = nearest and min = linear and mip = nearest */
  9834. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  9835. /** mag = nearest and min = linear and mip = linear */
  9836. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  9837. /** mag = nearest and min = linear and mip = none */
  9838. static readonly TEXTURE_NEAREST_LINEAR: number;
  9839. /** mag = nearest and min = nearest and mip = none */
  9840. static readonly TEXTURE_NEAREST_NEAREST: number;
  9841. /** mag = linear and min = nearest and mip = nearest */
  9842. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  9843. /** mag = linear and min = nearest and mip = linear */
  9844. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  9845. /** mag = linear and min = linear and mip = none */
  9846. static readonly TEXTURE_LINEAR_LINEAR: number;
  9847. /** mag = linear and min = nearest and mip = none */
  9848. static readonly TEXTURE_LINEAR_NEAREST: number;
  9849. /** Explicit coordinates mode */
  9850. static readonly TEXTURE_EXPLICIT_MODE: number;
  9851. /** Spherical coordinates mode */
  9852. static readonly TEXTURE_SPHERICAL_MODE: number;
  9853. /** Planar coordinates mode */
  9854. static readonly TEXTURE_PLANAR_MODE: number;
  9855. /** Cubic coordinates mode */
  9856. static readonly TEXTURE_CUBIC_MODE: number;
  9857. /** Projection coordinates mode */
  9858. static readonly TEXTURE_PROJECTION_MODE: number;
  9859. /** Skybox coordinates mode */
  9860. static readonly TEXTURE_SKYBOX_MODE: number;
  9861. /** Inverse Cubic coordinates mode */
  9862. static readonly TEXTURE_INVCUBIC_MODE: number;
  9863. /** Equirectangular coordinates mode */
  9864. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  9865. /** Equirectangular Fixed coordinates mode */
  9866. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  9867. /** Equirectangular Fixed Mirrored coordinates mode */
  9868. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  9869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  9870. static readonly SCALEMODE_FLOOR: number;
  9871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  9872. static readonly SCALEMODE_NEAREST: number;
  9873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  9874. static readonly SCALEMODE_CEILING: number;
  9875. /**
  9876. * Returns the current version of the framework
  9877. */
  9878. static readonly Version: string;
  9879. /**
  9880. * Gets or sets the epsilon value used by collision engine
  9881. */
  9882. static CollisionsEpsilon: number;
  9883. /**
  9884. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  9885. */
  9886. static CodeRepository: string;
  9887. /**
  9888. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  9889. */
  9890. static ShadersRepository: string;
  9891. /**
  9892. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  9893. */
  9894. forcePOTTextures: boolean;
  9895. /**
  9896. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  9897. */
  9898. isFullscreen: boolean;
  9899. /**
  9900. * Gets a boolean indicating if the pointer is currently locked
  9901. */
  9902. isPointerLock: boolean;
  9903. /**
  9904. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  9905. */
  9906. cullBackFaces: boolean;
  9907. /**
  9908. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  9909. */
  9910. renderEvenInBackground: boolean;
  9911. /**
  9912. * Gets or sets a boolean indicating that cache can be kept between frames
  9913. */
  9914. preventCacheWipeBetweenFrames: boolean;
  9915. /**
  9916. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  9917. **/
  9918. enableOfflineSupport: boolean;
  9919. /**
  9920. * 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)
  9921. **/
  9922. disableManifestCheck: boolean;
  9923. /**
  9924. * Gets the list of created scenes
  9925. */
  9926. scenes: Scene[];
  9927. /**
  9928. * Gets the list of created postprocesses
  9929. */
  9930. postProcesses: PostProcess[];
  9931. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  9932. validateShaderPrograms: boolean;
  9933. /**
  9934. * Observable event triggered each time the rendering canvas is resized
  9935. */
  9936. onResizeObservable: Observable<Engine>;
  9937. /**
  9938. * Observable event triggered each time the canvas loses focus
  9939. */
  9940. onCanvasBlurObservable: Observable<Engine>;
  9941. /**
  9942. * Observable event triggered each time the canvas gains focus
  9943. */
  9944. onCanvasFocusObservable: Observable<Engine>;
  9945. /**
  9946. * Observable event triggered each time the canvas receives pointerout event
  9947. */
  9948. onCanvasPointerOutObservable: Observable<PointerEvent>;
  9949. /**
  9950. * Observable event triggered before each texture is initialized
  9951. */
  9952. onBeforeTextureInitObservable: Observable<Texture>;
  9953. private _vrDisplay;
  9954. private _vrSupported;
  9955. private _oldSize;
  9956. private _oldHardwareScaleFactor;
  9957. private _vrExclusivePointerMode;
  9958. private _webVRInitPromise;
  9959. /**
  9960. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  9961. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  9962. */
  9963. readonly isInVRExclusivePointerMode: boolean;
  9964. /**
  9965. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  9966. */
  9967. disableUniformBuffers: boolean;
  9968. /** @hidden */
  9969. _uniformBuffers: UniformBuffer[];
  9970. /**
  9971. * Gets a boolean indicating that the engine supports uniform buffers
  9972. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  9973. */
  9974. readonly supportsUniformBuffers: boolean;
  9975. /**
  9976. * Observable raised when the engine begins a new frame
  9977. */
  9978. onBeginFrameObservable: Observable<Engine>;
  9979. /**
  9980. * Observable raised when the engine ends the current frame
  9981. */
  9982. onEndFrameObservable: Observable<Engine>;
  9983. /**
  9984. * Observable raised when the engine is about to compile a shader
  9985. */
  9986. onBeforeShaderCompilationObservable: Observable<Engine>;
  9987. /**
  9988. * Observable raised when the engine has jsut compiled a shader
  9989. */
  9990. onAfterShaderCompilationObservable: Observable<Engine>;
  9991. /** @hidden */
  9992. _gl: WebGLRenderingContext;
  9993. private _renderingCanvas;
  9994. private _windowIsBackground;
  9995. private _webGLVersion;
  9996. /**
  9997. * Gets a boolean indicating that only power of 2 textures are supported
  9998. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  9999. */
  10000. readonly needPOTTextures: boolean;
  10001. /** @hidden */
  10002. _badOS: boolean;
  10003. /** @hidden */
  10004. _badDesktopOS: boolean;
  10005. /**
  10006. * Gets or sets a value indicating if we want to disable texture binding optmization.
  10007. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10008. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10009. */
  10010. disableTextureBindingOptimization: boolean;
  10011. /**
  10012. * Gets the audio engine
  10013. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10014. * @ignorenaming
  10015. */
  10016. static audioEngine: IAudioEngine;
  10017. /**
  10018. * Default AudioEngine Factory responsible of creating the Audio Engine.
  10019. * By default, this will create a BabylonJS Audio Engine if the workload
  10020. * has been embedded.
  10021. */
  10022. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10023. private _onFocus;
  10024. private _onBlur;
  10025. private _onCanvasPointerOut;
  10026. private _onCanvasBlur;
  10027. private _onCanvasFocus;
  10028. private _onFullscreenChange;
  10029. private _onPointerLockChange;
  10030. private _onVRDisplayPointerRestricted;
  10031. private _onVRDisplayPointerUnrestricted;
  10032. private _onVrDisplayConnect;
  10033. private _onVrDisplayDisconnect;
  10034. private _onVrDisplayPresentChange;
  10035. /**
  10036. * Observable signaled when VR display mode changes
  10037. */
  10038. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10039. /**
  10040. * Observable signaled when VR request present is complete
  10041. */
  10042. onVRRequestPresentComplete: Observable<boolean>;
  10043. /**
  10044. * Observable signaled when VR request present starts
  10045. */
  10046. onVRRequestPresentStart: Observable<Engine>;
  10047. private _hardwareScalingLevel;
  10048. /** @hidden */
  10049. protected _caps: EngineCapabilities;
  10050. private _pointerLockRequested;
  10051. private _isStencilEnable;
  10052. private _colorWrite;
  10053. private _loadingScreen;
  10054. /** @hidden */
  10055. _drawCalls: PerfCounter;
  10056. /** @hidden */
  10057. _textureCollisions: PerfCounter;
  10058. private _glVersion;
  10059. private _glRenderer;
  10060. private _glVendor;
  10061. private _videoTextureSupported;
  10062. private _renderingQueueLaunched;
  10063. private _activeRenderLoops;
  10064. private _deterministicLockstep;
  10065. private _lockstepMaxSteps;
  10066. /**
  10067. * Observable signaled when a context lost event is raised
  10068. */
  10069. onContextLostObservable: Observable<Engine>;
  10070. /**
  10071. * Observable signaled when a context restored event is raised
  10072. */
  10073. onContextRestoredObservable: Observable<Engine>;
  10074. private _onContextLost;
  10075. private _onContextRestored;
  10076. private _contextWasLost;
  10077. private _doNotHandleContextLost;
  10078. /**
  10079. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10081. */
  10082. doNotHandleContextLost: boolean;
  10083. private _performanceMonitor;
  10084. private _fps;
  10085. private _deltaTime;
  10086. /**
  10087. * Turn this value on if you want to pause FPS computation when in background
  10088. */
  10089. disablePerformanceMonitorInBackground: boolean;
  10090. /**
  10091. * Gets the performance monitor attached to this engine
  10092. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10093. */
  10094. readonly performanceMonitor: PerformanceMonitor;
  10095. /** @hidden */
  10096. protected _depthCullingState: _DepthCullingState;
  10097. /** @hidden */
  10098. protected _stencilState: _StencilState;
  10099. /** @hidden */
  10100. protected _alphaState: _AlphaState;
  10101. /** @hidden */
  10102. protected _alphaMode: number;
  10103. protected _internalTexturesCache: InternalTexture[];
  10104. /** @hidden */
  10105. protected _activeChannel: number;
  10106. private _currentTextureChannel;
  10107. /** @hidden */
  10108. protected _boundTexturesCache: {
  10109. [key: string]: Nullable<InternalTexture>;
  10110. };
  10111. /** @hidden */
  10112. protected _currentEffect: Nullable<Effect>;
  10113. /** @hidden */
  10114. protected _currentProgram: Nullable<WebGLProgram>;
  10115. private _compiledEffects;
  10116. private _vertexAttribArraysEnabled;
  10117. /** @hidden */
  10118. protected _cachedViewport: Nullable<Viewport>;
  10119. private _cachedVertexArrayObject;
  10120. /** @hidden */
  10121. protected _cachedVertexBuffers: any;
  10122. /** @hidden */
  10123. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10124. /** @hidden */
  10125. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10126. /** @hidden */
  10127. protected _currentRenderTarget: Nullable<InternalTexture>;
  10128. private _uintIndicesCurrentlySet;
  10129. private _currentBoundBuffer;
  10130. /** @hidden */
  10131. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10132. private _currentBufferPointers;
  10133. private _currentInstanceLocations;
  10134. private _currentInstanceBuffers;
  10135. private _textureUnits;
  10136. private _firstBoundInternalTextureTracker;
  10137. private _lastBoundInternalTextureTracker;
  10138. private _workingCanvas;
  10139. private _workingContext;
  10140. private _rescalePostProcess;
  10141. private _dummyFramebuffer;
  10142. private _externalData;
  10143. private _bindedRenderFunction;
  10144. private _vaoRecordInProgress;
  10145. private _mustWipeVertexAttributes;
  10146. private _emptyTexture;
  10147. private _emptyCubeTexture;
  10148. private _emptyTexture3D;
  10149. private _frameHandler;
  10150. private _nextFreeTextureSlots;
  10151. private _maxSimultaneousTextures;
  10152. private _activeRequests;
  10153. private _texturesSupported;
  10154. private _textureFormatInUse;
  10155. /**
  10156. * Gets the list of texture formats supported
  10157. */
  10158. readonly texturesSupported: Array<string>;
  10159. /**
  10160. * Gets the list of texture formats in use
  10161. */
  10162. readonly textureFormatInUse: Nullable<string>;
  10163. /**
  10164. * Gets the current viewport
  10165. */
  10166. readonly currentViewport: Nullable<Viewport>;
  10167. /**
  10168. * Gets the default empty texture
  10169. */
  10170. readonly emptyTexture: InternalTexture;
  10171. /**
  10172. * Gets the default empty 3D texture
  10173. */
  10174. readonly emptyTexture3D: InternalTexture;
  10175. /**
  10176. * Gets the default empty cube texture
  10177. */
  10178. readonly emptyCubeTexture: InternalTexture;
  10179. /**
  10180. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10181. */
  10182. readonly premultipliedAlpha: boolean;
  10183. /**
  10184. * Creates a new engine
  10185. * @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
  10186. * @param antialias defines enable antialiasing (default: false)
  10187. * @param options defines further options to be sent to the getContext() function
  10188. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10189. */
  10190. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10191. private _rebuildInternalTextures;
  10192. private _rebuildEffects;
  10193. private _rebuildBuffers;
  10194. private _initGLContext;
  10195. /**
  10196. * Gets version of the current webGL context
  10197. */
  10198. readonly webGLVersion: number;
  10199. /**
  10200. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10201. */
  10202. readonly isStencilEnable: boolean;
  10203. private _prepareWorkingCanvas;
  10204. /**
  10205. * Reset the texture cache to empty state
  10206. */
  10207. resetTextureCache(): void;
  10208. /**
  10209. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10210. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10211. * @returns true if engine is in deterministic lock step mode
  10212. */
  10213. isDeterministicLockStep(): boolean;
  10214. /**
  10215. * Gets the max steps when engine is running in deterministic lock step
  10216. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10217. * @returns the max steps
  10218. */
  10219. getLockstepMaxSteps(): number;
  10220. /**
  10221. * Gets an object containing information about the current webGL context
  10222. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10223. */
  10224. getGlInfo(): {
  10225. vendor: string;
  10226. renderer: string;
  10227. version: string;
  10228. };
  10229. /**
  10230. * Gets current aspect ratio
  10231. * @param camera defines the camera to use to get the aspect ratio
  10232. * @param useScreen defines if screen size must be used (or the current render target if any)
  10233. * @returns a number defining the aspect ratio
  10234. */
  10235. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10236. /**
  10237. * Gets current screen aspect ratio
  10238. * @returns a number defining the aspect ratio
  10239. */
  10240. getScreenAspectRatio(): number;
  10241. /**
  10242. * Gets the current render width
  10243. * @param useScreen defines if screen size must be used (or the current render target if any)
  10244. * @returns a number defining the current render width
  10245. */
  10246. getRenderWidth(useScreen?: boolean): number;
  10247. /**
  10248. * Gets the current render height
  10249. * @param useScreen defines if screen size must be used (or the current render target if any)
  10250. * @returns a number defining the current render height
  10251. */
  10252. getRenderHeight(useScreen?: boolean): number;
  10253. /**
  10254. * Gets the HTML canvas attached with the current webGL context
  10255. * @returns a HTML canvas
  10256. */
  10257. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10258. /**
  10259. * Gets the client rect of the HTML canvas attached with the current webGL context
  10260. * @returns a client rectanglee
  10261. */
  10262. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10263. /**
  10264. * Defines the hardware scaling level.
  10265. * By default the hardware scaling level is computed from the window device ratio.
  10266. * 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.
  10267. * @param level defines the level to use
  10268. */
  10269. setHardwareScalingLevel(level: number): void;
  10270. /**
  10271. * Gets the current hardware scaling level.
  10272. * By default the hardware scaling level is computed from the window device ratio.
  10273. * 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.
  10274. * @returns a number indicating the current hardware scaling level
  10275. */
  10276. getHardwareScalingLevel(): number;
  10277. /**
  10278. * Gets the list of loaded textures
  10279. * @returns an array containing all loaded textures
  10280. */
  10281. getLoadedTexturesCache(): InternalTexture[];
  10282. /**
  10283. * Gets the object containing all engine capabilities
  10284. * @returns the EngineCapabilities object
  10285. */
  10286. getCaps(): EngineCapabilities;
  10287. /** @hidden */
  10288. readonly drawCalls: number;
  10289. /** @hidden */
  10290. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  10291. /**
  10292. * Gets the current depth function
  10293. * @returns a number defining the depth function
  10294. */
  10295. getDepthFunction(): Nullable<number>;
  10296. /**
  10297. * Sets the current depth function
  10298. * @param depthFunc defines the function to use
  10299. */
  10300. setDepthFunction(depthFunc: number): void;
  10301. /**
  10302. * Sets the current depth function to GREATER
  10303. */
  10304. setDepthFunctionToGreater(): void;
  10305. /**
  10306. * Sets the current depth function to GEQUAL
  10307. */
  10308. setDepthFunctionToGreaterOrEqual(): void;
  10309. /**
  10310. * Sets the current depth function to LESS
  10311. */
  10312. setDepthFunctionToLess(): void;
  10313. /**
  10314. * Sets the current depth function to LEQUAL
  10315. */
  10316. setDepthFunctionToLessOrEqual(): void;
  10317. /**
  10318. * Gets a boolean indicating if stencil buffer is enabled
  10319. * @returns the current stencil buffer state
  10320. */
  10321. getStencilBuffer(): boolean;
  10322. /**
  10323. * Enable or disable the stencil buffer
  10324. * @param enable defines if the stencil buffer must be enabled or disabled
  10325. */
  10326. setStencilBuffer(enable: boolean): void;
  10327. /**
  10328. * Gets the current stencil mask
  10329. * @returns a number defining the new stencil mask to use
  10330. */
  10331. getStencilMask(): number;
  10332. /**
  10333. * Sets the current stencil mask
  10334. * @param mask defines the new stencil mask to use
  10335. */
  10336. setStencilMask(mask: number): void;
  10337. /**
  10338. * Gets the current stencil function
  10339. * @returns a number defining the stencil function to use
  10340. */
  10341. getStencilFunction(): number;
  10342. /**
  10343. * Gets the current stencil reference value
  10344. * @returns a number defining the stencil reference value to use
  10345. */
  10346. getStencilFunctionReference(): number;
  10347. /**
  10348. * Gets the current stencil mask
  10349. * @returns a number defining the stencil mask to use
  10350. */
  10351. getStencilFunctionMask(): number;
  10352. /**
  10353. * Sets the current stencil function
  10354. * @param stencilFunc defines the new stencil function to use
  10355. */
  10356. setStencilFunction(stencilFunc: number): void;
  10357. /**
  10358. * Sets the current stencil reference
  10359. * @param reference defines the new stencil reference to use
  10360. */
  10361. setStencilFunctionReference(reference: number): void;
  10362. /**
  10363. * Sets the current stencil mask
  10364. * @param mask defines the new stencil mask to use
  10365. */
  10366. setStencilFunctionMask(mask: number): void;
  10367. /**
  10368. * Gets the current stencil operation when stencil fails
  10369. * @returns a number defining stencil operation to use when stencil fails
  10370. */
  10371. getStencilOperationFail(): number;
  10372. /**
  10373. * Gets the current stencil operation when depth fails
  10374. * @returns a number defining stencil operation to use when depth fails
  10375. */
  10376. getStencilOperationDepthFail(): number;
  10377. /**
  10378. * Gets the current stencil operation when stencil passes
  10379. * @returns a number defining stencil operation to use when stencil passes
  10380. */
  10381. getStencilOperationPass(): number;
  10382. /**
  10383. * Sets the stencil operation to use when stencil fails
  10384. * @param operation defines the stencil operation to use when stencil fails
  10385. */
  10386. setStencilOperationFail(operation: number): void;
  10387. /**
  10388. * Sets the stencil operation to use when depth fails
  10389. * @param operation defines the stencil operation to use when depth fails
  10390. */
  10391. setStencilOperationDepthFail(operation: number): void;
  10392. /**
  10393. * Sets the stencil operation to use when stencil passes
  10394. * @param operation defines the stencil operation to use when stencil passes
  10395. */
  10396. setStencilOperationPass(operation: number): void;
  10397. /**
  10398. * Sets a boolean indicating if the dithering state is enabled or disabled
  10399. * @param value defines the dithering state
  10400. */
  10401. setDitheringState(value: boolean): void;
  10402. /**
  10403. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10404. * @param value defines the rasterizer state
  10405. */
  10406. setRasterizerState(value: boolean): void;
  10407. /**
  10408. * stop executing a render loop function and remove it from the execution array
  10409. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10410. */
  10411. stopRenderLoop(renderFunction?: () => void): void;
  10412. /** @hidden */
  10413. _renderLoop(): void;
  10414. /**
  10415. * Register and execute a render loop. The engine can have more than one render function
  10416. * @param renderFunction defines the function to continuously execute
  10417. */
  10418. runRenderLoop(renderFunction: () => void): void;
  10419. /**
  10420. * Toggle full screen mode
  10421. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10422. */
  10423. switchFullscreen(requestPointerLock: boolean): void;
  10424. /**
  10425. * Clear the current render buffer or the current render target (if any is set up)
  10426. * @param color defines the color to use
  10427. * @param backBuffer defines if the back buffer must be cleared
  10428. * @param depth defines if the depth buffer must be cleared
  10429. * @param stencil defines if the stencil buffer must be cleared
  10430. */
  10431. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10432. /**
  10433. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10434. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10435. * @param y defines the y-coordinate of the corner of the clear rectangle
  10436. * @param width defines the width of the clear rectangle
  10437. * @param height defines the height of the clear rectangle
  10438. * @param clearColor defines the clear color
  10439. */
  10440. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10441. private _viewportCached;
  10442. /** @hidden */
  10443. _viewport(x: number, y: number, width: number, height: number): void;
  10444. /**
  10445. * Set the WebGL's viewport
  10446. * @param viewport defines the viewport element to be used
  10447. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10448. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10449. */
  10450. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10451. /**
  10452. * Directly set the WebGL Viewport
  10453. * @param x defines the x coordinate of the viewport (in screen space)
  10454. * @param y defines the y coordinate of the viewport (in screen space)
  10455. * @param width defines the width of the viewport (in screen space)
  10456. * @param height defines the height of the viewport (in screen space)
  10457. * @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
  10458. */
  10459. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10460. /**
  10461. * Begin a new frame
  10462. */
  10463. beginFrame(): void;
  10464. /**
  10465. * Enf the current frame
  10466. */
  10467. endFrame(): void;
  10468. /**
  10469. * Resize the view according to the canvas' size
  10470. */
  10471. resize(): void;
  10472. /**
  10473. * Force a specific size of the canvas
  10474. * @param width defines the new canvas' width
  10475. * @param height defines the new canvas' height
  10476. */
  10477. setSize(width: number, height: number): void;
  10478. /**
  10479. * Gets a boolean indicating if a webVR device was detected
  10480. * @returns true if a webVR device was detected
  10481. */
  10482. isVRDevicePresent(): boolean;
  10483. /**
  10484. * Gets the current webVR device
  10485. * @returns the current webVR device (or null)
  10486. */
  10487. getVRDevice(): any;
  10488. /**
  10489. * Initializes a webVR display and starts listening to display change events
  10490. * The onVRDisplayChangedObservable will be notified upon these changes
  10491. * @returns The onVRDisplayChangedObservable
  10492. */
  10493. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10494. /**
  10495. * Initializes a webVR display and starts listening to display change events
  10496. * The onVRDisplayChangedObservable will be notified upon these changes
  10497. * @returns A promise containing a VRDisplay and if vr is supported
  10498. */
  10499. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10500. /**
  10501. * Call this function to switch to webVR mode
  10502. * Will do nothing if webVR is not supported or if there is no webVR device
  10503. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10504. */
  10505. enableVR(): void;
  10506. /**
  10507. * Call this function to leave webVR mode
  10508. * Will do nothing if webVR is not supported or if there is no webVR device
  10509. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10510. */
  10511. disableVR(): void;
  10512. private _onVRFullScreenTriggered;
  10513. private _getVRDisplaysAsync;
  10514. /**
  10515. * Binds the frame buffer to the specified texture.
  10516. * @param texture The texture to render to or null for the default canvas
  10517. * @param faceIndex The face of the texture to render to in case of cube texture
  10518. * @param requiredWidth The width of the target to render to
  10519. * @param requiredHeight The height of the target to render to
  10520. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10521. * @param depthStencilTexture The depth stencil texture to use to render
  10522. * @param lodLevel defines le lod level to bind to the frame buffer
  10523. */
  10524. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10525. private bindUnboundFramebuffer;
  10526. /**
  10527. * Unbind the current render target texture from the webGL context
  10528. * @param texture defines the render target texture to unbind
  10529. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10530. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10531. */
  10532. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10533. /**
  10534. * Unbind a list of render target textures from the webGL context
  10535. * This is used only when drawBuffer extension or webGL2 are active
  10536. * @param textures defines the render target textures to unbind
  10537. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10538. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10539. */
  10540. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10541. /**
  10542. * Force the mipmap generation for the given render target texture
  10543. * @param texture defines the render target texture to use
  10544. */
  10545. generateMipMapsForCubemap(texture: InternalTexture): void;
  10546. /**
  10547. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10548. */
  10549. flushFramebuffer(): void;
  10550. /**
  10551. * Unbind the current render target and bind the default framebuffer
  10552. */
  10553. restoreDefaultFramebuffer(): void;
  10554. /**
  10555. * Create an uniform buffer
  10556. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10557. * @param elements defines the content of the uniform buffer
  10558. * @returns the webGL uniform buffer
  10559. */
  10560. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10561. /**
  10562. * Create a dynamic uniform buffer
  10563. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10564. * @param elements defines the content of the uniform buffer
  10565. * @returns the webGL uniform buffer
  10566. */
  10567. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10568. /**
  10569. * Update an existing uniform buffer
  10570. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10571. * @param uniformBuffer defines the target uniform buffer
  10572. * @param elements defines the content to update
  10573. * @param offset defines the offset in the uniform buffer where update should start
  10574. * @param count defines the size of the data to update
  10575. */
  10576. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10577. private _resetVertexBufferBinding;
  10578. /**
  10579. * Creates a vertex buffer
  10580. * @param data the data for the vertex buffer
  10581. * @returns the new WebGL static buffer
  10582. */
  10583. createVertexBuffer(data: DataArray): WebGLBuffer;
  10584. /**
  10585. * Creates a dynamic vertex buffer
  10586. * @param data the data for the dynamic vertex buffer
  10587. * @returns the new WebGL dynamic buffer
  10588. */
  10589. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10590. /**
  10591. * Update a dynamic index buffer
  10592. * @param indexBuffer defines the target index buffer
  10593. * @param indices defines the data to update
  10594. * @param offset defines the offset in the target index buffer where update should start
  10595. */
  10596. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10597. /**
  10598. * Updates a dynamic vertex buffer.
  10599. * @param vertexBuffer the vertex buffer to update
  10600. * @param data the data used to update the vertex buffer
  10601. * @param byteOffset the byte offset of the data
  10602. * @param byteLength the byte length of the data
  10603. */
  10604. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10605. private _resetIndexBufferBinding;
  10606. /**
  10607. * Creates a new index buffer
  10608. * @param indices defines the content of the index buffer
  10609. * @param updatable defines if the index buffer must be updatable
  10610. * @returns a new webGL buffer
  10611. */
  10612. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10613. /**
  10614. * Bind a webGL buffer to the webGL context
  10615. * @param buffer defines the buffer to bind
  10616. */
  10617. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10618. /**
  10619. * Bind an uniform buffer to the current webGL context
  10620. * @param buffer defines the buffer to bind
  10621. */
  10622. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10623. /**
  10624. * Bind a buffer to the current webGL context at a given location
  10625. * @param buffer defines the buffer to bind
  10626. * @param location defines the index where to bind the buffer
  10627. */
  10628. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10629. /**
  10630. * Bind a specific block at a given index in a specific shader program
  10631. * @param shaderProgram defines the shader program
  10632. * @param blockName defines the block name
  10633. * @param index defines the index where to bind the block
  10634. */
  10635. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  10636. private bindIndexBuffer;
  10637. private bindBuffer;
  10638. /**
  10639. * update the bound buffer with the given data
  10640. * @param data defines the data to update
  10641. */
  10642. updateArrayBuffer(data: Float32Array): void;
  10643. private _vertexAttribPointer;
  10644. private _bindIndexBufferWithCache;
  10645. private _bindVertexBuffersAttributes;
  10646. /**
  10647. * Records a vertex array object
  10648. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10649. * @param vertexBuffers defines the list of vertex buffers to store
  10650. * @param indexBuffer defines the index buffer to store
  10651. * @param effect defines the effect to store
  10652. * @returns the new vertex array object
  10653. */
  10654. recordVertexArrayObject(vertexBuffers: {
  10655. [key: string]: VertexBuffer;
  10656. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  10657. /**
  10658. * Bind a specific vertex array object
  10659. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10660. * @param vertexArrayObject defines the vertex array object to bind
  10661. * @param indexBuffer defines the index buffer to bind
  10662. */
  10663. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  10664. /**
  10665. * Bind webGl buffers directly to the webGL context
  10666. * @param vertexBuffer defines the vertex buffer to bind
  10667. * @param indexBuffer defines the index buffer to bind
  10668. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  10669. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  10670. * @param effect defines the effect associated with the vertex buffer
  10671. */
  10672. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  10673. private _unbindVertexArrayObject;
  10674. /**
  10675. * Bind a list of vertex buffers to the webGL context
  10676. * @param vertexBuffers defines the list of vertex buffers to bind
  10677. * @param indexBuffer defines the index buffer to bind
  10678. * @param effect defines the effect associated with the vertex buffers
  10679. */
  10680. bindBuffers(vertexBuffers: {
  10681. [key: string]: Nullable<VertexBuffer>;
  10682. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  10683. /**
  10684. * Unbind all instance attributes
  10685. */
  10686. unbindInstanceAttributes(): void;
  10687. /**
  10688. * Release and free the memory of a vertex array object
  10689. * @param vao defines the vertex array object to delete
  10690. */
  10691. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  10692. /** @hidden */
  10693. _releaseBuffer(buffer: WebGLBuffer): boolean;
  10694. /**
  10695. * Creates a webGL buffer to use with instanciation
  10696. * @param capacity defines the size of the buffer
  10697. * @returns the webGL buffer
  10698. */
  10699. createInstancesBuffer(capacity: number): WebGLBuffer;
  10700. /**
  10701. * Delete a webGL buffer used with instanciation
  10702. * @param buffer defines the webGL buffer to delete
  10703. */
  10704. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  10705. /**
  10706. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  10707. * @param instancesBuffer defines the webGL buffer to update and bind
  10708. * @param data defines the data to store in the buffer
  10709. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  10710. */
  10711. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  10712. /**
  10713. * Apply all cached states (depth, culling, stencil and alpha)
  10714. */
  10715. applyStates(): void;
  10716. /**
  10717. * Send a draw order
  10718. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10719. * @param indexStart defines the starting index
  10720. * @param indexCount defines the number of index to draw
  10721. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10722. */
  10723. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  10724. /**
  10725. * Draw a list of points
  10726. * @param verticesStart defines the index of first vertex to draw
  10727. * @param verticesCount defines the count of vertices to draw
  10728. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10729. */
  10730. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10731. /**
  10732. * Draw a list of unindexed primitives
  10733. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10734. * @param verticesStart defines the index of first vertex to draw
  10735. * @param verticesCount defines the count of vertices to draw
  10736. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10737. */
  10738. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10739. /**
  10740. * Draw a list of indexed primitives
  10741. * @param fillMode defines the primitive to use
  10742. * @param indexStart defines the starting index
  10743. * @param indexCount defines the number of index to draw
  10744. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10745. */
  10746. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  10747. /**
  10748. * Draw a list of unindexed primitives
  10749. * @param fillMode defines the primitive to use
  10750. * @param verticesStart defines the index of first vertex to draw
  10751. * @param verticesCount defines the count of vertices to draw
  10752. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10753. */
  10754. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10755. private _drawMode;
  10756. /** @hidden */
  10757. _releaseEffect(effect: Effect): void;
  10758. /** @hidden */
  10759. _deleteProgram(program: WebGLProgram): void;
  10760. /**
  10761. * Create a new effect (used to store vertex/fragment shaders)
  10762. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  10763. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  10764. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  10765. * @param samplers defines an array of string used to represent textures
  10766. * @param defines defines the string containing the defines to use to compile the shaders
  10767. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  10768. * @param onCompiled defines a function to call when the effect creation is successful
  10769. * @param onError defines a function to call when the effect creation has failed
  10770. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  10771. * @returns the new Effect
  10772. */
  10773. 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;
  10774. private _compileShader;
  10775. private _compileRawShader;
  10776. /**
  10777. * Directly creates a webGL program
  10778. * @param vertexCode defines the vertex shader code to use
  10779. * @param fragmentCode defines the fragment shader code to use
  10780. * @param context defines the webGL context to use (if not set, the current one will be used)
  10781. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10782. * @returns the new webGL program
  10783. */
  10784. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10785. /**
  10786. * Creates a webGL program
  10787. * @param vertexCode defines the vertex shader code to use
  10788. * @param fragmentCode defines the fragment shader code to use
  10789. * @param defines defines the string containing the defines to use to compile the shaders
  10790. * @param context defines the webGL context to use (if not set, the current one will be used)
  10791. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10792. * @returns the new webGL program
  10793. */
  10794. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10795. private _createShaderProgram;
  10796. /**
  10797. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  10798. * @param shaderProgram defines the webGL program to use
  10799. * @param uniformsNames defines the list of uniform names
  10800. * @returns an array of webGL uniform locations
  10801. */
  10802. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  10803. /**
  10804. * Gets the lsit of active attributes for a given webGL program
  10805. * @param shaderProgram defines the webGL program to use
  10806. * @param attributesNames defines the list of attribute names to get
  10807. * @returns an array of indices indicating the offset of each attribute
  10808. */
  10809. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  10810. /**
  10811. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  10812. * @param effect defines the effect to activate
  10813. */
  10814. enableEffect(effect: Nullable<Effect>): void;
  10815. /**
  10816. * Set the value of an uniform to an array of int32
  10817. * @param uniform defines the webGL uniform location where to store the value
  10818. * @param array defines the array of int32 to store
  10819. */
  10820. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10821. /**
  10822. * Set the value of an uniform to an array of int32 (stored as vec2)
  10823. * @param uniform defines the webGL uniform location where to store the value
  10824. * @param array defines the array of int32 to store
  10825. */
  10826. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10827. /**
  10828. * Set the value of an uniform to an array of int32 (stored as vec3)
  10829. * @param uniform defines the webGL uniform location where to store the value
  10830. * @param array defines the array of int32 to store
  10831. */
  10832. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10833. /**
  10834. * Set the value of an uniform to an array of int32 (stored as vec4)
  10835. * @param uniform defines the webGL uniform location where to store the value
  10836. * @param array defines the array of int32 to store
  10837. */
  10838. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10839. /**
  10840. * Set the value of an uniform to an array of float32
  10841. * @param uniform defines the webGL uniform location where to store the value
  10842. * @param array defines the array of float32 to store
  10843. */
  10844. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10845. /**
  10846. * Set the value of an uniform to an array of float32 (stored as vec2)
  10847. * @param uniform defines the webGL uniform location where to store the value
  10848. * @param array defines the array of float32 to store
  10849. */
  10850. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10851. /**
  10852. * Set the value of an uniform to an array of float32 (stored as vec3)
  10853. * @param uniform defines the webGL uniform location where to store the value
  10854. * @param array defines the array of float32 to store
  10855. */
  10856. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10857. /**
  10858. * Set the value of an uniform to an array of float32 (stored as vec4)
  10859. * @param uniform defines the webGL uniform location where to store the value
  10860. * @param array defines the array of float32 to store
  10861. */
  10862. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10863. /**
  10864. * Set the value of an uniform to an array of number
  10865. * @param uniform defines the webGL uniform location where to store the value
  10866. * @param array defines the array of number to store
  10867. */
  10868. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10869. /**
  10870. * Set the value of an uniform to an array of number (stored as vec2)
  10871. * @param uniform defines the webGL uniform location where to store the value
  10872. * @param array defines the array of number to store
  10873. */
  10874. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10875. /**
  10876. * Set the value of an uniform to an array of number (stored as vec3)
  10877. * @param uniform defines the webGL uniform location where to store the value
  10878. * @param array defines the array of number to store
  10879. */
  10880. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10881. /**
  10882. * Set the value of an uniform to an array of number (stored as vec4)
  10883. * @param uniform defines the webGL uniform location where to store the value
  10884. * @param array defines the array of number to store
  10885. */
  10886. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10887. /**
  10888. * Set the value of an uniform to an array of float32 (stored as matrices)
  10889. * @param uniform defines the webGL uniform location where to store the value
  10890. * @param matrices defines the array of float32 to store
  10891. */
  10892. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  10893. /**
  10894. * Set the value of an uniform to a matrix
  10895. * @param uniform defines the webGL uniform location where to store the value
  10896. * @param matrix defines the matrix to store
  10897. */
  10898. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  10899. /**
  10900. * Set the value of an uniform to a matrix (3x3)
  10901. * @param uniform defines the webGL uniform location where to store the value
  10902. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  10903. */
  10904. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10905. /**
  10906. * Set the value of an uniform to a matrix (2x2)
  10907. * @param uniform defines the webGL uniform location where to store the value
  10908. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  10909. */
  10910. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10911. /**
  10912. * Set the value of an uniform to a number (int)
  10913. * @param uniform defines the webGL uniform location where to store the value
  10914. * @param value defines the int number to store
  10915. */
  10916. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10917. /**
  10918. * Set the value of an uniform to a number (float)
  10919. * @param uniform defines the webGL uniform location where to store the value
  10920. * @param value defines the float number to store
  10921. */
  10922. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10923. /**
  10924. * Set the value of an uniform to a vec2
  10925. * @param uniform defines the webGL uniform location where to store the value
  10926. * @param x defines the 1st component of the value
  10927. * @param y defines the 2nd component of the value
  10928. */
  10929. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  10930. /**
  10931. * Set the value of an uniform to a vec3
  10932. * @param uniform defines the webGL uniform location where to store the value
  10933. * @param x defines the 1st component of the value
  10934. * @param y defines the 2nd component of the value
  10935. * @param z defines the 3rd component of the value
  10936. */
  10937. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  10938. /**
  10939. * Set the value of an uniform to a boolean
  10940. * @param uniform defines the webGL uniform location where to store the value
  10941. * @param bool defines the boolean to store
  10942. */
  10943. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  10944. /**
  10945. * Set the value of an uniform to a vec4
  10946. * @param uniform defines the webGL uniform location where to store the value
  10947. * @param x defines the 1st component of the value
  10948. * @param y defines the 2nd component of the value
  10949. * @param z defines the 3rd component of the value
  10950. * @param w defines the 4th component of the value
  10951. */
  10952. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  10953. /**
  10954. * Set the value of an uniform to a Color3
  10955. * @param uniform defines the webGL uniform location where to store the value
  10956. * @param color3 defines the color to store
  10957. */
  10958. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  10959. /**
  10960. * Set the value of an uniform to a Color3 and an alpha value
  10961. * @param uniform defines the webGL uniform location where to store the value
  10962. * @param color3 defines the color to store
  10963. * @param alpha defines the alpha component to store
  10964. */
  10965. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  10966. /**
  10967. * Sets a Color4 on a uniform variable
  10968. * @param uniform defines the uniform location
  10969. * @param color4 defines the value to be set
  10970. */
  10971. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  10972. /**
  10973. * Set various states to the webGL context
  10974. * @param culling defines backface culling state
  10975. * @param zOffset defines the value to apply to zOffset (0 by default)
  10976. * @param force defines if states must be applied even if cache is up to date
  10977. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  10978. */
  10979. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  10980. /**
  10981. * Set the z offset to apply to current rendering
  10982. * @param value defines the offset to apply
  10983. */
  10984. setZOffset(value: number): void;
  10985. /**
  10986. * Gets the current value of the zOffset
  10987. * @returns the current zOffset state
  10988. */
  10989. getZOffset(): number;
  10990. /**
  10991. * Enable or disable depth buffering
  10992. * @param enable defines the state to set
  10993. */
  10994. setDepthBuffer(enable: boolean): void;
  10995. /**
  10996. * Gets a boolean indicating if depth writing is enabled
  10997. * @returns the current depth writing state
  10998. */
  10999. getDepthWrite(): boolean;
  11000. /**
  11001. * Enable or disable depth writing
  11002. * @param enable defines the state to set
  11003. */
  11004. setDepthWrite(enable: boolean): void;
  11005. /**
  11006. * Enable or disable color writing
  11007. * @param enable defines the state to set
  11008. */
  11009. setColorWrite(enable: boolean): void;
  11010. /**
  11011. * Gets a boolean indicating if color writing is enabled
  11012. * @returns the current color writing state
  11013. */
  11014. getColorWrite(): boolean;
  11015. /**
  11016. * Sets alpha constants used by some alpha blending modes
  11017. * @param r defines the red component
  11018. * @param g defines the green component
  11019. * @param b defines the blue component
  11020. * @param a defines the alpha component
  11021. */
  11022. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11023. /**
  11024. * Sets the current alpha mode
  11025. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11026. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11027. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11028. */
  11029. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11030. /**
  11031. * Gets the current alpha mode
  11032. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11033. * @returns the current alpha mode
  11034. */
  11035. getAlphaMode(): number;
  11036. /**
  11037. * Clears the list of texture accessible through engine.
  11038. * This can help preventing texture load conflict due to name collision.
  11039. */
  11040. clearInternalTexturesCache(): void;
  11041. /**
  11042. * Force the entire cache to be cleared
  11043. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11044. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11045. */
  11046. wipeCaches(bruteForce?: boolean): void;
  11047. /**
  11048. * Set the compressed texture format to use, based on the formats you have, and the formats
  11049. * supported by the hardware / browser.
  11050. *
  11051. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11052. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11053. * to API arguments needed to compressed textures. This puts the burden on the container
  11054. * generator to house the arcane code for determining these for current & future formats.
  11055. *
  11056. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11057. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11058. *
  11059. * Note: The result of this call is not taken into account when a texture is base64.
  11060. *
  11061. * @param formatsAvailable defines the list of those format families you have created
  11062. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11063. *
  11064. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11065. * @returns The extension selected.
  11066. */
  11067. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11068. private _getSamplingParameters;
  11069. private _partialLoadImg;
  11070. private _cascadeLoadImgs;
  11071. /** @hidden */
  11072. _createTexture(): WebGLTexture;
  11073. /**
  11074. * Usually called from BABYLON.Texture.ts.
  11075. * Passed information to create a WebGLTexture
  11076. * @param urlArg defines a value which contains one of the following:
  11077. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11078. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11079. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11080. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11081. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11082. * @param scene needed for loading to the correct scene
  11083. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11084. * @param onLoad optional callback to be called upon successful completion
  11085. * @param onError optional callback to be called upon failure
  11086. * @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
  11087. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11088. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11089. * @param forcedExtension defines the extension to use to pick the right loader
  11090. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11091. */
  11092. 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;
  11093. private _rescaleTexture;
  11094. /**
  11095. * Update a raw texture
  11096. * @param texture defines the texture to update
  11097. * @param data defines the data to store in the texture
  11098. * @param format defines the format of the data
  11099. * @param invertY defines if data must be stored with Y axis inverted
  11100. * @param compression defines the compression used (null by default)
  11101. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11102. */
  11103. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11104. /**
  11105. * Creates a raw texture
  11106. * @param data defines the data to store in the texture
  11107. * @param width defines the width of the texture
  11108. * @param height defines the height of the texture
  11109. * @param format defines the format of the data
  11110. * @param generateMipMaps defines if the engine should generate the mip levels
  11111. * @param invertY defines if data must be stored with Y axis inverted
  11112. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11113. * @param compression defines the compression used (null by default)
  11114. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11115. * @returns the raw texture inside an InternalTexture
  11116. */
  11117. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11118. private _unpackFlipYCached;
  11119. /**
  11120. * In case you are sharing the context with other applications, it might
  11121. * be interested to not cache the unpack flip y state to ensure a consistent
  11122. * value would be set.
  11123. */
  11124. enableUnpackFlipYCached: boolean;
  11125. /** @hidden */
  11126. _unpackFlipY(value: boolean): void;
  11127. /** @hidden */
  11128. _getUnpackAlignement(): number;
  11129. /**
  11130. * Creates a dynamic texture
  11131. * @param width defines the width of the texture
  11132. * @param height defines the height of the texture
  11133. * @param generateMipMaps defines if the engine should generate the mip levels
  11134. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11135. * @returns the dynamic texture inside an InternalTexture
  11136. */
  11137. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11138. /**
  11139. * Update the sampling mode of a given texture
  11140. * @param samplingMode defines the required sampling mode
  11141. * @param texture defines the texture to update
  11142. */
  11143. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11144. /**
  11145. * Update the content of a dynamic texture
  11146. * @param texture defines the texture to update
  11147. * @param canvas defines the canvas containing the source
  11148. * @param invertY defines if data must be stored with Y axis inverted
  11149. * @param premulAlpha defines if alpha is stored as premultiplied
  11150. * @param format defines the format of the data
  11151. */
  11152. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11153. /**
  11154. * Update a video texture
  11155. * @param texture defines the texture to update
  11156. * @param video defines the video element to use
  11157. * @param invertY defines if data must be stored with Y axis inverted
  11158. */
  11159. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11160. /**
  11161. * Updates a depth texture Comparison Mode and Function.
  11162. * If the comparison Function is equal to 0, the mode will be set to none.
  11163. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11164. * @param texture The texture to set the comparison function for
  11165. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11166. */
  11167. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11168. private _setupDepthStencilTexture;
  11169. /**
  11170. * Creates a depth stencil texture.
  11171. * This is only available in WebGL 2 or with the depth texture extension available.
  11172. * @param size The size of face edge in the texture.
  11173. * @param options The options defining the texture.
  11174. * @returns The texture
  11175. */
  11176. createDepthStencilTexture(size: number | {
  11177. width: number;
  11178. height: number;
  11179. }, options: DepthTextureCreationOptions): InternalTexture;
  11180. /**
  11181. * Creates a depth stencil texture.
  11182. * This is only available in WebGL 2 or with the depth texture extension available.
  11183. * @param size The size of face edge in the texture.
  11184. * @param options The options defining the texture.
  11185. * @returns The texture
  11186. */
  11187. private _createDepthStencilTexture;
  11188. /**
  11189. * Creates a depth stencil cube texture.
  11190. * This is only available in WebGL 2.
  11191. * @param size The size of face edge in the cube texture.
  11192. * @param options The options defining the cube texture.
  11193. * @returns The cube texture
  11194. */
  11195. private _createDepthStencilCubeTexture;
  11196. /**
  11197. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11198. * @param renderTarget The render target to set the frame buffer for
  11199. */
  11200. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11201. /**
  11202. * Creates a new render target texture
  11203. * @param size defines the size of the texture
  11204. * @param options defines the options used to create the texture
  11205. * @returns a new render target texture stored in an InternalTexture
  11206. */
  11207. createRenderTargetTexture(size: number | {
  11208. width: number;
  11209. height: number;
  11210. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11211. /**
  11212. * Create a multi render target texture
  11213. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11214. * @param size defines the size of the texture
  11215. * @param options defines the creation options
  11216. * @returns the cube texture as an InternalTexture
  11217. */
  11218. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11219. private _setupFramebufferDepthAttachments;
  11220. /**
  11221. * Updates the sample count of a render target texture
  11222. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11223. * @param texture defines the texture to update
  11224. * @param samples defines the sample count to set
  11225. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11226. */
  11227. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11228. /**
  11229. * Update the sample count for a given multiple render target texture
  11230. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11231. * @param textures defines the textures to update
  11232. * @param samples defines the sample count to set
  11233. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11234. */
  11235. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11236. /** @hidden */
  11237. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11238. /** @hidden */
  11239. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11240. /** @hidden */
  11241. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11242. /** @hidden */
  11243. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11244. /**
  11245. * Creates a new render target cube texture
  11246. * @param size defines the size of the texture
  11247. * @param options defines the options used to create the texture
  11248. * @returns a new render target cube texture stored in an InternalTexture
  11249. */
  11250. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11251. /**
  11252. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11253. * @param rootUrl defines the url where the file to load is located
  11254. * @param scene defines the current scene
  11255. * @param lodScale defines scale to apply to the mip map selection
  11256. * @param lodOffset defines offset to apply to the mip map selection
  11257. * @param onLoad defines an optional callback raised when the texture is loaded
  11258. * @param onError defines an optional callback raised if there is an issue to load the texture
  11259. * @param format defines the format of the data
  11260. * @param forcedExtension defines the extension to use to pick the right loader
  11261. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11262. * @returns the cube texture as an InternalTexture
  11263. */
  11264. 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;
  11265. /**
  11266. * Creates a cube texture
  11267. * @param rootUrl defines the url where the files to load is located
  11268. * @param scene defines the current scene
  11269. * @param files defines the list of files to load (1 per face)
  11270. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11271. * @param onLoad defines an optional callback raised when the texture is loaded
  11272. * @param onError defines an optional callback raised if there is an issue to load the texture
  11273. * @param format defines the format of the data
  11274. * @param forcedExtension defines the extension to use to pick the right loader
  11275. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11276. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11277. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11278. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11279. * @returns the cube texture as an InternalTexture
  11280. */
  11281. 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;
  11282. /**
  11283. * @hidden
  11284. */
  11285. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11286. /**
  11287. * Update a raw cube texture
  11288. * @param texture defines the texture to udpdate
  11289. * @param data defines the data to store
  11290. * @param format defines the data format
  11291. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11292. * @param invertY defines if data must be stored with Y axis inverted
  11293. * @param compression defines the compression used (null by default)
  11294. * @param level defines which level of the texture to update
  11295. */
  11296. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11297. /**
  11298. * Creates a new raw cube texture
  11299. * @param data defines the array of data to use to create each face
  11300. * @param size defines the size of the textures
  11301. * @param format defines the format of the data
  11302. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11303. * @param generateMipMaps defines if the engine should generate the mip levels
  11304. * @param invertY defines if data must be stored with Y axis inverted
  11305. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11306. * @param compression defines the compression used (null by default)
  11307. * @returns the cube texture as an InternalTexture
  11308. */
  11309. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11310. /**
  11311. * Creates a new raw cube texture from a specified url
  11312. * @param url defines the url where the data is located
  11313. * @param scene defines the current scene
  11314. * @param size defines the size of the textures
  11315. * @param format defines the format of the data
  11316. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11317. * @param noMipmap defines if the engine should avoid generating the mip levels
  11318. * @param callback defines a callback used to extract texture data from loaded data
  11319. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11320. * @param onLoad defines a callback called when texture is loaded
  11321. * @param onError defines a callback called if there is an error
  11322. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11323. * @param invertY defines if data must be stored with Y axis inverted
  11324. * @returns the cube texture as an InternalTexture
  11325. */
  11326. 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;
  11327. /**
  11328. * Update a raw 3D texture
  11329. * @param texture defines the texture to update
  11330. * @param data defines the data to store
  11331. * @param format defines the data format
  11332. * @param invertY defines if data must be stored with Y axis inverted
  11333. * @param compression defines the used compression (can be null)
  11334. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11335. */
  11336. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11337. /**
  11338. * Creates a new raw 3D texture
  11339. * @param data defines the data used to create the texture
  11340. * @param width defines the width of the texture
  11341. * @param height defines the height of the texture
  11342. * @param depth defines the depth of the texture
  11343. * @param format defines the format of the texture
  11344. * @param generateMipMaps defines if the engine must generate mip levels
  11345. * @param invertY defines if data must be stored with Y axis inverted
  11346. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11347. * @param compression defines the compressed used (can be null)
  11348. * @param textureType defines the compressed used (can be null)
  11349. * @returns a new raw 3D texture (stored in an InternalTexture)
  11350. */
  11351. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11352. private _prepareWebGLTextureContinuation;
  11353. private _prepareWebGLTexture;
  11354. private _convertRGBtoRGBATextureData;
  11355. /** @hidden */
  11356. _releaseFramebufferObjects(texture: InternalTexture): void;
  11357. /** @hidden */
  11358. _releaseTexture(texture: InternalTexture): void;
  11359. private setProgram;
  11360. private _boundUniforms;
  11361. /**
  11362. * Binds an effect to the webGL context
  11363. * @param effect defines the effect to bind
  11364. */
  11365. bindSamplers(effect: Effect): void;
  11366. private _moveBoundTextureOnTop;
  11367. private _getCorrectTextureChannel;
  11368. private _linkTrackers;
  11369. private _removeDesignatedSlot;
  11370. private _activateCurrentTexture;
  11371. /** @hidden */
  11372. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11373. /** @hidden */
  11374. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11375. /**
  11376. * Sets a texture to the webGL context from a postprocess
  11377. * @param channel defines the channel to use
  11378. * @param postProcess defines the source postprocess
  11379. */
  11380. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11381. /**
  11382. * Binds the output of the passed in post process to the texture channel specified
  11383. * @param channel The channel the texture should be bound to
  11384. * @param postProcess The post process which's output should be bound
  11385. */
  11386. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11387. /**
  11388. * Unbind all textures from the webGL context
  11389. */
  11390. unbindAllTextures(): void;
  11391. /**
  11392. * Sets a texture to the according uniform.
  11393. * @param channel The texture channel
  11394. * @param uniform The uniform to set
  11395. * @param texture The texture to apply
  11396. */
  11397. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11398. /**
  11399. * Sets a depth stencil texture from a render target to the according uniform.
  11400. * @param channel The texture channel
  11401. * @param uniform The uniform to set
  11402. * @param texture The render target texture containing the depth stencil texture to apply
  11403. */
  11404. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11405. private _bindSamplerUniformToChannel;
  11406. private _getTextureWrapMode;
  11407. private _setTexture;
  11408. /**
  11409. * Sets an array of texture to the webGL context
  11410. * @param channel defines the channel where the texture array must be set
  11411. * @param uniform defines the associated uniform location
  11412. * @param textures defines the array of textures to bind
  11413. */
  11414. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11415. /** @hidden */
  11416. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11417. private _setTextureParameterFloat;
  11418. private _setTextureParameterInteger;
  11419. /**
  11420. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11421. * @param x defines the x coordinate of the rectangle where pixels must be read
  11422. * @param y defines the y coordinate of the rectangle where pixels must be read
  11423. * @param width defines the width of the rectangle where pixels must be read
  11424. * @param height defines the height of the rectangle where pixels must be read
  11425. * @returns a Uint8Array containing RGBA colors
  11426. */
  11427. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11428. /**
  11429. * Add an externaly attached data from its key.
  11430. * This method call will fail and return false, if such key already exists.
  11431. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11432. * @param key the unique key that identifies the data
  11433. * @param data the data object to associate to the key for this Engine instance
  11434. * @return true if no such key were already present and the data was added successfully, false otherwise
  11435. */
  11436. addExternalData<T>(key: string, data: T): boolean;
  11437. /**
  11438. * Get an externaly attached data from its key
  11439. * @param key the unique key that identifies the data
  11440. * @return the associated data, if present (can be null), or undefined if not present
  11441. */
  11442. getExternalData<T>(key: string): T;
  11443. /**
  11444. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11445. * @param key the unique key that identifies the data
  11446. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11447. * @return the associated data, can be null if the factory returned null.
  11448. */
  11449. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11450. /**
  11451. * Remove an externaly attached data from the Engine instance
  11452. * @param key the unique key that identifies the data
  11453. * @return true if the data was successfully removed, false if it doesn't exist
  11454. */
  11455. removeExternalData(key: string): boolean;
  11456. /**
  11457. * Unbind all vertex attributes from the webGL context
  11458. */
  11459. unbindAllAttributes(): void;
  11460. /**
  11461. * 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
  11462. */
  11463. releaseEffects(): void;
  11464. /**
  11465. * Dispose and release all associated resources
  11466. */
  11467. dispose(): void;
  11468. /**
  11469. * Display the loading screen
  11470. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11471. */
  11472. displayLoadingUI(): void;
  11473. /**
  11474. * Hide the loading screen
  11475. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11476. */
  11477. hideLoadingUI(): void;
  11478. /**
  11479. * Gets the current loading screen object
  11480. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11481. */
  11482. /**
  11483. * Sets the current loading screen object
  11484. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11485. */
  11486. loadingScreen: ILoadingScreen;
  11487. /**
  11488. * Sets the current loading screen text
  11489. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11490. */
  11491. loadingUIText: string;
  11492. /**
  11493. * Sets the current loading screen background color
  11494. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11495. */
  11496. loadingUIBackgroundColor: string;
  11497. /**
  11498. * Attach a new callback raised when context lost event is fired
  11499. * @param callback defines the callback to call
  11500. */
  11501. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11502. /**
  11503. * Attach a new callback raised when context restored event is fired
  11504. * @param callback defines the callback to call
  11505. */
  11506. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11507. /**
  11508. * Gets the source code of the vertex shader associated with a specific webGL program
  11509. * @param program defines the program to use
  11510. * @returns a string containing the source code of the vertex shader associated with the program
  11511. */
  11512. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11513. /**
  11514. * Gets the source code of the fragment shader associated with a specific webGL program
  11515. * @param program defines the program to use
  11516. * @returns a string containing the source code of the fragment shader associated with the program
  11517. */
  11518. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11519. /**
  11520. * Get the current error code of the webGL context
  11521. * @returns the error code
  11522. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11523. */
  11524. getError(): number;
  11525. /**
  11526. * Gets the current framerate
  11527. * @returns a number representing the framerate
  11528. */
  11529. getFps(): number;
  11530. /**
  11531. * Gets the time spent between current and previous frame
  11532. * @returns a number representing the delta time in ms
  11533. */
  11534. getDeltaTime(): number;
  11535. private _measureFps;
  11536. /** @hidden */
  11537. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11538. private _canRenderToFloatFramebuffer;
  11539. private _canRenderToHalfFloatFramebuffer;
  11540. private _canRenderToFramebuffer;
  11541. /** @hidden */
  11542. _getWebGLTextureType(type: number): number;
  11543. private _getInternalFormat;
  11544. /** @hidden */
  11545. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11546. /** @hidden */
  11547. _getRGBAMultiSampleBufferFormat(type: number): number;
  11548. /** @hidden */
  11549. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  11550. /** @hidden */
  11551. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11552. private _partialLoadFile;
  11553. private _cascadeLoadFiles;
  11554. /**
  11555. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11556. * @returns true if the engine can be created
  11557. * @ignorenaming
  11558. */
  11559. static isSupported(): boolean;
  11560. }
  11561. }
  11562. declare module BABYLON {
  11563. /**
  11564. * Options to create the null engine
  11565. */
  11566. class NullEngineOptions {
  11567. /**
  11568. * Render width (Default: 512)
  11569. */
  11570. renderWidth: number;
  11571. /**
  11572. * Render height (Default: 256)
  11573. */
  11574. renderHeight: number;
  11575. /**
  11576. * Texture size (Default: 512)
  11577. */
  11578. textureSize: number;
  11579. /**
  11580. * If delta time between frames should be constant
  11581. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11582. */
  11583. deterministicLockstep: boolean;
  11584. /**
  11585. * Maximum about of steps between frames (Default: 4)
  11586. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11587. */
  11588. lockstepMaxSteps: number;
  11589. }
  11590. /**
  11591. * The null engine class provides support for headless version of babylon.js.
  11592. * This can be used in server side scenario or for testing purposes
  11593. */
  11594. class NullEngine extends Engine {
  11595. private _options;
  11596. /**
  11597. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11598. */
  11599. isDeterministicLockStep(): boolean;
  11600. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  11601. getLockstepMaxSteps(): number;
  11602. /**
  11603. * Sets hardware scaling, used to save performance if needed
  11604. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  11605. */
  11606. getHardwareScalingLevel(): number;
  11607. constructor(options?: NullEngineOptions);
  11608. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11609. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11610. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11611. getRenderWidth(useScreen?: boolean): number;
  11612. getRenderHeight(useScreen?: boolean): number;
  11613. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11614. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11615. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11616. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11617. bindSamplers(effect: Effect): void;
  11618. enableEffect(effect: Effect): void;
  11619. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11620. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11621. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11622. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11623. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11624. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11625. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11626. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11627. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  11628. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  11629. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  11630. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  11631. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  11632. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  11633. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  11634. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11635. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11636. setFloat(uniform: WebGLUniformLocation, value: number): void;
  11637. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  11638. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  11639. setBool(uniform: WebGLUniformLocation, bool: number): void;
  11640. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  11641. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  11642. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  11643. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11644. bindBuffers(vertexBuffers: {
  11645. [key: string]: VertexBuffer;
  11646. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  11647. wipeCaches(bruteForce?: boolean): void;
  11648. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11649. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11650. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11651. /** @hidden */
  11652. _createTexture(): WebGLTexture;
  11653. /** @hidden */
  11654. _releaseTexture(texture: InternalTexture): void;
  11655. 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;
  11656. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11657. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11658. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  11659. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11660. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11661. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11662. /**
  11663. * @hidden
  11664. * Get the current error code of the webGL context
  11665. * @returns the error code
  11666. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11667. */
  11668. getError(): number;
  11669. /** @hidden */
  11670. _getUnpackAlignement(): number;
  11671. /** @hidden */
  11672. _unpackFlipY(value: boolean): void;
  11673. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11674. /**
  11675. * Updates a dynamic vertex buffer.
  11676. * @param vertexBuffer the vertex buffer to update
  11677. * @param data the data used to update the vertex buffer
  11678. * @param byteOffset the byte offset of the data (optional)
  11679. * @param byteLength the byte length of the data (optional)
  11680. */
  11681. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  11682. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  11683. /** @hidden */
  11684. _bindTexture(channel: number, texture: InternalTexture): void;
  11685. /** @hidden */
  11686. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11687. releaseEffects(): void;
  11688. displayLoadingUI(): void;
  11689. hideLoadingUI(): void;
  11690. /** @hidden */
  11691. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11692. /** @hidden */
  11693. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11694. /** @hidden */
  11695. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11696. /** @hidden */
  11697. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11698. }
  11699. }
  11700. interface WebGLRenderingContext {
  11701. readonly RASTERIZER_DISCARD: number;
  11702. readonly DEPTH_COMPONENT24: number;
  11703. readonly TEXTURE_3D: number;
  11704. readonly TEXTURE_2D_ARRAY: number;
  11705. readonly TEXTURE_COMPARE_FUNC: number;
  11706. readonly TEXTURE_COMPARE_MODE: number;
  11707. readonly COMPARE_REF_TO_TEXTURE: number;
  11708. readonly TEXTURE_WRAP_R: number;
  11709. readonly HALF_FLOAT: number;
  11710. readonly RGB8: number;
  11711. readonly RED_INTEGER: number;
  11712. readonly RG_INTEGER: number;
  11713. readonly RGB_INTEGER: number;
  11714. readonly RGBA_INTEGER: number;
  11715. readonly R8_SNORM: number;
  11716. readonly RG8_SNORM: number;
  11717. readonly RGB8_SNORM: number;
  11718. readonly RGBA8_SNORM: number;
  11719. readonly R8I: number;
  11720. readonly RG8I: number;
  11721. readonly RGB8I: number;
  11722. readonly RGBA8I: number;
  11723. readonly R8UI: number;
  11724. readonly RG8UI: number;
  11725. readonly RGB8UI: number;
  11726. readonly RGBA8UI: number;
  11727. readonly R16I: number;
  11728. readonly RG16I: number;
  11729. readonly RGB16I: number;
  11730. readonly RGBA16I: number;
  11731. readonly R16UI: number;
  11732. readonly RG16UI: number;
  11733. readonly RGB16UI: number;
  11734. readonly RGBA16UI: number;
  11735. readonly R32I: number;
  11736. readonly RG32I: number;
  11737. readonly RGB32I: number;
  11738. readonly RGBA32I: number;
  11739. readonly R32UI: number;
  11740. readonly RG32UI: number;
  11741. readonly RGB32UI: number;
  11742. readonly RGBA32UI: number;
  11743. readonly RGB10_A2UI: number;
  11744. readonly R11F_G11F_B10F: number;
  11745. readonly RGB9_E5: number;
  11746. readonly RGB10_A2: number;
  11747. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  11748. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  11749. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  11750. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  11751. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  11752. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  11753. 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;
  11754. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  11755. readonly TRANSFORM_FEEDBACK: number;
  11756. readonly INTERLEAVED_ATTRIBS: number;
  11757. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  11758. createTransformFeedback(): WebGLTransformFeedback;
  11759. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  11760. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  11761. beginTransformFeedback(primitiveMode: number): void;
  11762. endTransformFeedback(): void;
  11763. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  11764. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11765. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11766. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11767. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  11768. }
  11769. interface ImageBitmap {
  11770. readonly width: number;
  11771. readonly height: number;
  11772. close(): void;
  11773. }
  11774. interface WebGLQuery extends WebGLObject {
  11775. }
  11776. declare var WebGLQuery: {
  11777. prototype: WebGLQuery;
  11778. new (): WebGLQuery;
  11779. };
  11780. interface WebGLSampler extends WebGLObject {
  11781. }
  11782. declare var WebGLSampler: {
  11783. prototype: WebGLSampler;
  11784. new (): WebGLSampler;
  11785. };
  11786. interface WebGLSync extends WebGLObject {
  11787. }
  11788. declare var WebGLSync: {
  11789. prototype: WebGLSync;
  11790. new (): WebGLSync;
  11791. };
  11792. interface WebGLTransformFeedback extends WebGLObject {
  11793. }
  11794. declare var WebGLTransformFeedback: {
  11795. prototype: WebGLTransformFeedback;
  11796. new (): WebGLTransformFeedback;
  11797. };
  11798. interface WebGLVertexArrayObject extends WebGLObject {
  11799. }
  11800. declare var WebGLVertexArrayObject: {
  11801. prototype: WebGLVertexArrayObject;
  11802. new (): WebGLVertexArrayObject;
  11803. };
  11804. declare module BABYLON {
  11805. /**
  11806. * Gather the list of keyboard event types as constants.
  11807. */
  11808. class KeyboardEventTypes {
  11809. /**
  11810. * The keydown event is fired when a key becomes active (pressed).
  11811. */
  11812. static readonly KEYDOWN: number;
  11813. /**
  11814. * The keyup event is fired when a key has been released.
  11815. */
  11816. static readonly KEYUP: number;
  11817. }
  11818. /**
  11819. * This class is used to store keyboard related info for the onKeyboardObservable event.
  11820. */
  11821. class KeyboardInfo {
  11822. /**
  11823. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11824. */
  11825. type: number;
  11826. /**
  11827. * Defines the related dom event
  11828. */
  11829. event: KeyboardEvent;
  11830. /**
  11831. * Instantiates a new keyboard info.
  11832. * This class is used to store keyboard related info for the onKeyboardObservable event.
  11833. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  11834. * @param event Defines the related dom event
  11835. */
  11836. constructor(
  11837. /**
  11838. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11839. */
  11840. type: number,
  11841. /**
  11842. * Defines the related dom event
  11843. */
  11844. event: KeyboardEvent);
  11845. }
  11846. /**
  11847. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  11848. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  11849. */
  11850. class KeyboardInfoPre extends KeyboardInfo {
  11851. /**
  11852. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11853. */
  11854. type: number;
  11855. /**
  11856. * Defines the related dom event
  11857. */
  11858. event: KeyboardEvent;
  11859. /**
  11860. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  11861. */
  11862. skipOnPointerObservable: boolean;
  11863. /**
  11864. * Instantiates a new keyboard pre info.
  11865. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  11866. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  11867. * @param event Defines the related dom event
  11868. */
  11869. constructor(
  11870. /**
  11871. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11872. */
  11873. type: number,
  11874. /**
  11875. * Defines the related dom event
  11876. */
  11877. event: KeyboardEvent);
  11878. }
  11879. }
  11880. declare module BABYLON {
  11881. /**
  11882. * Gather the list of pointer event types as constants.
  11883. */
  11884. class PointerEventTypes {
  11885. /**
  11886. * 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.
  11887. */
  11888. static readonly POINTERDOWN: number;
  11889. /**
  11890. * The pointerup event is fired when a pointer is no longer active.
  11891. */
  11892. static readonly POINTERUP: number;
  11893. /**
  11894. * The pointermove event is fired when a pointer changes coordinates.
  11895. */
  11896. static readonly POINTERMOVE: number;
  11897. /**
  11898. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11899. */
  11900. static readonly POINTERWHEEL: number;
  11901. /**
  11902. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11903. */
  11904. static readonly POINTERPICK: number;
  11905. /**
  11906. * The pointertap event is fired when a the object has been touched and released without drag.
  11907. */
  11908. static readonly POINTERTAP: number;
  11909. /**
  11910. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11911. */
  11912. static readonly POINTERDOUBLETAP: number;
  11913. }
  11914. /**
  11915. * Base class of pointer info types.
  11916. */
  11917. class PointerInfoBase {
  11918. /**
  11919. * Defines the type of event (BABYLON.PointerEventTypes)
  11920. */
  11921. type: number;
  11922. /**
  11923. * Defines the related dom event
  11924. */
  11925. event: PointerEvent | MouseWheelEvent;
  11926. /**
  11927. * Instantiates the base class of pointers info.
  11928. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11929. * @param event Defines the related dom event
  11930. */
  11931. constructor(
  11932. /**
  11933. * Defines the type of event (BABYLON.PointerEventTypes)
  11934. */
  11935. type: number,
  11936. /**
  11937. * Defines the related dom event
  11938. */
  11939. event: PointerEvent | MouseWheelEvent);
  11940. }
  11941. /**
  11942. * This class is used to store pointer related info for the onPrePointerObservable event.
  11943. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11944. */
  11945. class PointerInfoPre extends PointerInfoBase {
  11946. /**
  11947. * Ray from a pointer if availible (eg. 6dof controller)
  11948. */
  11949. ray: Nullable<Ray>;
  11950. /**
  11951. * Defines the local position of the pointer on the canvas.
  11952. */
  11953. localPosition: Vector2;
  11954. /**
  11955. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11956. */
  11957. skipOnPointerObservable: boolean;
  11958. /**
  11959. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11960. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11961. * @param event Defines the related dom event
  11962. * @param localX Defines the local x coordinates of the pointer when the event occured
  11963. * @param localY Defines the local y coordinates of the pointer when the event occured
  11964. */
  11965. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11966. }
  11967. /**
  11968. * This type contains all the data related to a pointer event in Babylon.js.
  11969. * 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.
  11970. */
  11971. class PointerInfo extends PointerInfoBase {
  11972. /**
  11973. * Defines the picking info associated to the info (if any)\
  11974. */
  11975. pickInfo: Nullable<PickingInfo>;
  11976. /**
  11977. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11978. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11979. * @param event Defines the related dom event
  11980. * @param pickInfo Defines the picking info associated to the info (if any)\
  11981. */
  11982. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11983. /**
  11984. * Defines the picking info associated to the info (if any)\
  11985. */
  11986. pickInfo: Nullable<PickingInfo>);
  11987. }
  11988. }
  11989. declare module BABYLON {
  11990. /**
  11991. * Represents a gamepad control stick position
  11992. */
  11993. class StickValues {
  11994. /**
  11995. * The x component of the control stick
  11996. */
  11997. x: number;
  11998. /**
  11999. * The y component of the control stick
  12000. */
  12001. y: number;
  12002. /**
  12003. * Initializes the gamepad x and y control stick values
  12004. * @param x The x component of the gamepad control stick value
  12005. * @param y The y component of the gamepad control stick value
  12006. */
  12007. constructor(
  12008. /**
  12009. * The x component of the control stick
  12010. */
  12011. x: number,
  12012. /**
  12013. * The y component of the control stick
  12014. */
  12015. y: number);
  12016. }
  12017. /**
  12018. * An interface which manages callbacks for gamepad button changes
  12019. */
  12020. interface GamepadButtonChanges {
  12021. /**
  12022. * Called when a gamepad has been changed
  12023. */
  12024. changed: boolean;
  12025. /**
  12026. * Called when a gamepad press event has been triggered
  12027. */
  12028. pressChanged: boolean;
  12029. /**
  12030. * Called when a touch event has been triggered
  12031. */
  12032. touchChanged: boolean;
  12033. /**
  12034. * Called when a value has changed
  12035. */
  12036. valueChanged: boolean;
  12037. }
  12038. /**
  12039. * Represents a gamepad
  12040. */
  12041. class Gamepad {
  12042. /**
  12043. * The id of the gamepad
  12044. */
  12045. id: string;
  12046. /**
  12047. * The index of the gamepad
  12048. */
  12049. index: number;
  12050. /**
  12051. * The browser gamepad
  12052. */
  12053. browserGamepad: any;
  12054. /**
  12055. * Specifies what type of gamepad this represents
  12056. */
  12057. type: number;
  12058. private _leftStick;
  12059. private _rightStick;
  12060. /** @hidden */
  12061. _isConnected: boolean;
  12062. private _leftStickAxisX;
  12063. private _leftStickAxisY;
  12064. private _rightStickAxisX;
  12065. private _rightStickAxisY;
  12066. /**
  12067. * Triggered when the left control stick has been changed
  12068. */
  12069. private _onleftstickchanged;
  12070. /**
  12071. * Triggered when the right control stick has been changed
  12072. */
  12073. private _onrightstickchanged;
  12074. /**
  12075. * Represents a gamepad controller
  12076. */
  12077. static GAMEPAD: number;
  12078. /**
  12079. * Represents a generic controller
  12080. */
  12081. static GENERIC: number;
  12082. /**
  12083. * Represents an XBox controller
  12084. */
  12085. static XBOX: number;
  12086. /**
  12087. * Represents a pose-enabled controller
  12088. */
  12089. static POSE_ENABLED: number;
  12090. /**
  12091. * Specifies whether the left control stick should be Y-inverted
  12092. */
  12093. protected _invertLeftStickY: boolean;
  12094. /**
  12095. * Specifies if the gamepad has been connected
  12096. */
  12097. readonly isConnected: boolean;
  12098. /**
  12099. * Initializes the gamepad
  12100. * @param id The id of the gamepad
  12101. * @param index The index of the gamepad
  12102. * @param browserGamepad The browser gamepad
  12103. * @param leftStickX The x component of the left joystick
  12104. * @param leftStickY The y component of the left joystick
  12105. * @param rightStickX The x component of the right joystick
  12106. * @param rightStickY The y component of the right joystick
  12107. */
  12108. constructor(
  12109. /**
  12110. * The id of the gamepad
  12111. */
  12112. id: string,
  12113. /**
  12114. * The index of the gamepad
  12115. */
  12116. index: number,
  12117. /**
  12118. * The browser gamepad
  12119. */
  12120. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12121. /**
  12122. * Callback triggered when the left joystick has changed
  12123. * @param callback
  12124. */
  12125. onleftstickchanged(callback: (values: StickValues) => void): void;
  12126. /**
  12127. * Callback triggered when the right joystick has changed
  12128. * @param callback
  12129. */
  12130. onrightstickchanged(callback: (values: StickValues) => void): void;
  12131. /**
  12132. * Gets the left joystick
  12133. */
  12134. /**
  12135. * Sets the left joystick values
  12136. */
  12137. leftStick: StickValues;
  12138. /**
  12139. * Gets the right joystick
  12140. */
  12141. /**
  12142. * Sets the right joystick value
  12143. */
  12144. rightStick: StickValues;
  12145. /**
  12146. * Updates the gamepad joystick positions
  12147. */
  12148. update(): void;
  12149. /**
  12150. * Disposes the gamepad
  12151. */
  12152. dispose(): void;
  12153. }
  12154. /**
  12155. * Represents a generic gamepad
  12156. */
  12157. class GenericPad extends Gamepad {
  12158. private _buttons;
  12159. private _onbuttondown;
  12160. private _onbuttonup;
  12161. /**
  12162. * Observable triggered when a button has been pressed
  12163. */
  12164. onButtonDownObservable: Observable<number>;
  12165. /**
  12166. * Observable triggered when a button has been released
  12167. */
  12168. onButtonUpObservable: Observable<number>;
  12169. /**
  12170. * Callback triggered when a button has been pressed
  12171. * @param callback Called when a button has been pressed
  12172. */
  12173. onbuttondown(callback: (buttonPressed: number) => void): void;
  12174. /**
  12175. * Callback triggered when a button has been released
  12176. * @param callback Called when a button has been released
  12177. */
  12178. onbuttonup(callback: (buttonReleased: number) => void): void;
  12179. /**
  12180. * Initializes the generic gamepad
  12181. * @param id The id of the generic gamepad
  12182. * @param index The index of the generic gamepad
  12183. * @param browserGamepad The browser gamepad
  12184. */
  12185. constructor(id: string, index: number, browserGamepad: any);
  12186. private _setButtonValue;
  12187. /**
  12188. * Updates the generic gamepad
  12189. */
  12190. update(): void;
  12191. /**
  12192. * Disposes the generic gamepad
  12193. */
  12194. dispose(): void;
  12195. }
  12196. }
  12197. declare module BABYLON {
  12198. /**
  12199. * Manager for handling gamepads
  12200. */
  12201. class GamepadManager {
  12202. private _scene?;
  12203. private _babylonGamepads;
  12204. private _oneGamepadConnected;
  12205. /** @hidden */
  12206. _isMonitoring: boolean;
  12207. private _gamepadEventSupported;
  12208. private _gamepadSupport;
  12209. /**
  12210. * observable to be triggered when the gamepad controller has been connected
  12211. */
  12212. onGamepadConnectedObservable: Observable<Gamepad>;
  12213. /**
  12214. * observable to be triggered when the gamepad controller has been disconnected
  12215. */
  12216. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12217. private _onGamepadConnectedEvent;
  12218. private _onGamepadDisconnectedEvent;
  12219. /**
  12220. * Initializes the gamepad manager
  12221. * @param _scene BabylonJS scene
  12222. */
  12223. constructor(_scene?: Scene | undefined);
  12224. /**
  12225. * The gamepads in the game pad manager
  12226. */
  12227. readonly gamepads: Gamepad[];
  12228. /**
  12229. * Get the gamepad controllers based on type
  12230. * @param type The type of gamepad controller
  12231. * @returns Nullable gamepad
  12232. */
  12233. getGamepadByType(type?: number): Nullable<Gamepad>;
  12234. /**
  12235. * Disposes the gamepad manager
  12236. */
  12237. dispose(): void;
  12238. private _addNewGamepad;
  12239. private _startMonitoringGamepads;
  12240. private _stopMonitoringGamepads;
  12241. /** @hidden */
  12242. _checkGamepadsStatus(): void;
  12243. private _updateGamepadObjects;
  12244. }
  12245. }
  12246. declare module BABYLON {
  12247. interface Scene {
  12248. /** @hidden */
  12249. _gamepadManager: Nullable<GamepadManager>;
  12250. /**
  12251. * Gets the gamepad manager associated with the scene
  12252. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12253. */
  12254. gamepadManager: GamepadManager;
  12255. }
  12256. /**
  12257. * Interface representing a free camera inputs manager
  12258. */
  12259. interface FreeCameraInputsManager {
  12260. /**
  12261. * Adds gamepad input support to the FreeCameraInputsManager.
  12262. * @returns the FreeCameraInputsManager
  12263. */
  12264. addGamepad(): FreeCameraInputsManager;
  12265. }
  12266. /**
  12267. * Interface representing an arc rotate camera inputs manager
  12268. */
  12269. interface ArcRotateCameraInputsManager {
  12270. /**
  12271. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12272. * @returns the camera inputs manager
  12273. */
  12274. addGamepad(): ArcRotateCameraInputsManager;
  12275. }
  12276. /**
  12277. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12278. */
  12279. class GamepadSystemSceneComponent implements ISceneComponent {
  12280. /**
  12281. * The component name helpfull to identify the component in the list of scene components.
  12282. */
  12283. readonly name: string;
  12284. /**
  12285. * The scene the component belongs to.
  12286. */
  12287. scene: Scene;
  12288. /**
  12289. * Creates a new instance of the component for the given scene
  12290. * @param scene Defines the scene to register the component in
  12291. */
  12292. constructor(scene: Scene);
  12293. /**
  12294. * Registers the component in a given scene
  12295. */
  12296. register(): void;
  12297. /**
  12298. * Rebuilds the elements related to this component in case of
  12299. * context lost for instance.
  12300. */
  12301. rebuild(): void;
  12302. /**
  12303. * Disposes the component and the associated ressources
  12304. */
  12305. dispose(): void;
  12306. private _beforeCameraUpdate;
  12307. }
  12308. }
  12309. declare module BABYLON {
  12310. /**
  12311. * Defines supported buttons for XBox360 compatible gamepads
  12312. */
  12313. enum Xbox360Button {
  12314. /** A */
  12315. A = 0,
  12316. /** B */
  12317. B = 1,
  12318. /** X */
  12319. X = 2,
  12320. /** Y */
  12321. Y = 3,
  12322. /** Start */
  12323. Start = 4,
  12324. /** Back */
  12325. Back = 5,
  12326. /** Left button */
  12327. LB = 6,
  12328. /** Right button */
  12329. RB = 7,
  12330. /** Left stick */
  12331. LeftStick = 8,
  12332. /** Right stick */
  12333. RightStick = 9
  12334. }
  12335. /** Defines values for XBox360 DPad */
  12336. enum Xbox360Dpad {
  12337. /** Up */
  12338. Up = 0,
  12339. /** Down */
  12340. Down = 1,
  12341. /** Left */
  12342. Left = 2,
  12343. /** Right */
  12344. Right = 3
  12345. }
  12346. /**
  12347. * Defines a XBox360 gamepad
  12348. */
  12349. class Xbox360Pad extends Gamepad {
  12350. private _leftTrigger;
  12351. private _rightTrigger;
  12352. private _onlefttriggerchanged;
  12353. private _onrighttriggerchanged;
  12354. private _onbuttondown;
  12355. private _onbuttonup;
  12356. private _ondpaddown;
  12357. private _ondpadup;
  12358. /** Observable raised when a button is pressed */
  12359. onButtonDownObservable: Observable<Xbox360Button>;
  12360. /** Observable raised when a button is released */
  12361. onButtonUpObservable: Observable<Xbox360Button>;
  12362. /** Observable raised when a pad is pressed */
  12363. onPadDownObservable: Observable<Xbox360Dpad>;
  12364. /** Observable raised when a pad is released */
  12365. onPadUpObservable: Observable<Xbox360Dpad>;
  12366. private _buttonA;
  12367. private _buttonB;
  12368. private _buttonX;
  12369. private _buttonY;
  12370. private _buttonBack;
  12371. private _buttonStart;
  12372. private _buttonLB;
  12373. private _buttonRB;
  12374. private _buttonLeftStick;
  12375. private _buttonRightStick;
  12376. private _dPadUp;
  12377. private _dPadDown;
  12378. private _dPadLeft;
  12379. private _dPadRight;
  12380. private _isXboxOnePad;
  12381. /**
  12382. * Creates a new XBox360 gamepad object
  12383. * @param id defines the id of this gamepad
  12384. * @param index defines its index
  12385. * @param gamepad defines the internal HTML gamepad object
  12386. * @param xboxOne defines if it is a XBox One gamepad
  12387. */
  12388. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12389. /**
  12390. * Defines the callback to call when left trigger is pressed
  12391. * @param callback defines the callback to use
  12392. */
  12393. onlefttriggerchanged(callback: (value: number) => void): void;
  12394. /**
  12395. * Defines the callback to call when right trigger is pressed
  12396. * @param callback defines the callback to use
  12397. */
  12398. onrighttriggerchanged(callback: (value: number) => void): void;
  12399. /**
  12400. * Gets the left trigger value
  12401. */
  12402. /**
  12403. * Sets the left trigger value
  12404. */
  12405. leftTrigger: number;
  12406. /**
  12407. * Gets the right trigger value
  12408. */
  12409. /**
  12410. * Sets the right trigger value
  12411. */
  12412. rightTrigger: number;
  12413. /**
  12414. * Defines the callback to call when a button is pressed
  12415. * @param callback defines the callback to use
  12416. */
  12417. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12418. /**
  12419. * Defines the callback to call when a button is released
  12420. * @param callback defines the callback to use
  12421. */
  12422. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12423. /**
  12424. * Defines the callback to call when a pad is pressed
  12425. * @param callback defines the callback to use
  12426. */
  12427. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12428. /**
  12429. * Defines the callback to call when a pad is released
  12430. * @param callback defines the callback to use
  12431. */
  12432. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12433. private _setButtonValue;
  12434. private _setDPadValue;
  12435. /**
  12436. * Gets the value of the `A` button
  12437. */
  12438. /**
  12439. * Sets the value of the `A` button
  12440. */
  12441. buttonA: number;
  12442. /**
  12443. * Gets the value of the `B` button
  12444. */
  12445. /**
  12446. * Sets the value of the `B` button
  12447. */
  12448. buttonB: number;
  12449. /**
  12450. * Gets the value of the `X` button
  12451. */
  12452. /**
  12453. * Sets the value of the `X` button
  12454. */
  12455. buttonX: number;
  12456. /**
  12457. * Gets the value of the `Y` button
  12458. */
  12459. /**
  12460. * Sets the value of the `Y` button
  12461. */
  12462. buttonY: number;
  12463. /**
  12464. * Gets the value of the `Start` button
  12465. */
  12466. /**
  12467. * Sets the value of the `Start` button
  12468. */
  12469. buttonStart: number;
  12470. /**
  12471. * Gets the value of the `Back` button
  12472. */
  12473. /**
  12474. * Sets the value of the `Back` button
  12475. */
  12476. buttonBack: number;
  12477. /**
  12478. * Gets the value of the `Left` button
  12479. */
  12480. /**
  12481. * Sets the value of the `Left` button
  12482. */
  12483. buttonLB: number;
  12484. /**
  12485. * Gets the value of the `Right` button
  12486. */
  12487. /**
  12488. * Sets the value of the `Right` button
  12489. */
  12490. buttonRB: number;
  12491. /**
  12492. * Gets the value of the Left joystick
  12493. */
  12494. /**
  12495. * Sets the value of the Left joystick
  12496. */
  12497. buttonLeftStick: number;
  12498. /**
  12499. * Gets the value of the Right joystick
  12500. */
  12501. /**
  12502. * Sets the value of the Right joystick
  12503. */
  12504. buttonRightStick: number;
  12505. /**
  12506. * Gets the value of D-pad up
  12507. */
  12508. /**
  12509. * Sets the value of D-pad up
  12510. */
  12511. dPadUp: number;
  12512. /**
  12513. * Gets the value of D-pad down
  12514. */
  12515. /**
  12516. * Sets the value of D-pad down
  12517. */
  12518. dPadDown: number;
  12519. /**
  12520. * Gets the value of D-pad left
  12521. */
  12522. /**
  12523. * Sets the value of D-pad left
  12524. */
  12525. dPadLeft: number;
  12526. /**
  12527. * Gets the value of D-pad right
  12528. */
  12529. /**
  12530. * Sets the value of D-pad right
  12531. */
  12532. dPadRight: number;
  12533. /**
  12534. * Force the gamepad to synchronize with device values
  12535. */
  12536. update(): void;
  12537. /**
  12538. * Disposes the gamepad
  12539. */
  12540. dispose(): void;
  12541. }
  12542. }
  12543. declare module BABYLON {
  12544. /**
  12545. * Single axis drag gizmo
  12546. */
  12547. class AxisDragGizmo extends Gizmo {
  12548. /**
  12549. * Drag behavior responsible for the gizmos dragging interactions
  12550. */
  12551. dragBehavior: PointerDragBehavior;
  12552. private _pointerObserver;
  12553. /**
  12554. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12555. */
  12556. snapDistance: number;
  12557. /**
  12558. * Event that fires each time the gizmo snaps to a new location.
  12559. * * snapDistance is the the change in distance
  12560. */
  12561. onSnapObservable: Observable<{
  12562. snapDistance: number;
  12563. }>;
  12564. /**
  12565. * Creates an AxisDragGizmo
  12566. * @param gizmoLayer The utility layer the gizmo will be added to
  12567. * @param dragAxis The axis which the gizmo will be able to drag on
  12568. * @param color The color of the gizmo
  12569. */
  12570. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12571. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12572. /**
  12573. * Disposes of the gizmo
  12574. */
  12575. dispose(): void;
  12576. }
  12577. }
  12578. declare module BABYLON {
  12579. /**
  12580. * Single axis scale gizmo
  12581. */
  12582. class AxisScaleGizmo extends Gizmo {
  12583. private _coloredMaterial;
  12584. /**
  12585. * Drag behavior responsible for the gizmos dragging interactions
  12586. */
  12587. dragBehavior: PointerDragBehavior;
  12588. private _pointerObserver;
  12589. /**
  12590. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12591. */
  12592. snapDistance: number;
  12593. /**
  12594. * Event that fires each time the gizmo snaps to a new location.
  12595. * * snapDistance is the the change in distance
  12596. */
  12597. onSnapObservable: Observable<{
  12598. snapDistance: number;
  12599. }>;
  12600. /**
  12601. * If the scaling operation should be done on all axis (default: false)
  12602. */
  12603. uniformScaling: boolean;
  12604. /**
  12605. * Creates an AxisScaleGizmo
  12606. * @param gizmoLayer The utility layer the gizmo will be added to
  12607. * @param dragAxis The axis which the gizmo will be able to scale on
  12608. * @param color The color of the gizmo
  12609. */
  12610. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12611. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12612. /**
  12613. * Disposes of the gizmo
  12614. */
  12615. dispose(): void;
  12616. /**
  12617. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12618. * @param mesh The mesh to replace the default mesh of the gizmo
  12619. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  12620. */
  12621. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  12622. }
  12623. }
  12624. declare module BABYLON {
  12625. /**
  12626. * Bounding box gizmo
  12627. */
  12628. class BoundingBoxGizmo extends Gizmo {
  12629. private _lineBoundingBox;
  12630. private _rotateSpheresParent;
  12631. private _scaleBoxesParent;
  12632. private _boundingDimensions;
  12633. private _renderObserver;
  12634. private _pointerObserver;
  12635. private _scaleDragSpeed;
  12636. private _tmpQuaternion;
  12637. private _tmpVector;
  12638. private _tmpRotationMatrix;
  12639. /**
  12640. * 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)
  12641. */
  12642. ignoreChildren: boolean;
  12643. /**
  12644. * 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)
  12645. */
  12646. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  12647. /**
  12648. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  12649. */
  12650. rotationSphereSize: number;
  12651. /**
  12652. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  12653. */
  12654. scaleBoxSize: number;
  12655. /**
  12656. * 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)
  12657. */
  12658. fixedDragMeshScreenSize: boolean;
  12659. /**
  12660. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  12661. */
  12662. fixedDragMeshScreenSizeDistanceFactor: number;
  12663. /**
  12664. * Fired when a rotation sphere or scale box is dragged
  12665. */
  12666. onDragStartObservable: Observable<{}>;
  12667. /**
  12668. * Fired when a scale box is dragged
  12669. */
  12670. onScaleBoxDragObservable: Observable<{}>;
  12671. /**
  12672. * Fired when a scale box drag is ended
  12673. */
  12674. onScaleBoxDragEndObservable: Observable<{}>;
  12675. /**
  12676. * Fired when a rotation sphere is dragged
  12677. */
  12678. onRotationSphereDragObservable: Observable<{}>;
  12679. /**
  12680. * Fired when a rotation sphere drag is ended
  12681. */
  12682. onRotationSphereDragEndObservable: Observable<{}>;
  12683. /**
  12684. * 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)
  12685. */
  12686. scalePivot: Nullable<Vector3>;
  12687. private _anchorMesh;
  12688. private _existingMeshScale;
  12689. private static _PivotCached;
  12690. private static _OldPivotPoint;
  12691. private static _PivotTranslation;
  12692. private static _PivotTmpVector;
  12693. /** @hidden */
  12694. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  12695. /** @hidden */
  12696. static _RestorePivotPoint(mesh: AbstractMesh): void;
  12697. /**
  12698. * Creates an BoundingBoxGizmo
  12699. * @param gizmoLayer The utility layer the gizmo will be added to
  12700. * @param color The color of the gizmo
  12701. */
  12702. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12703. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12704. private _selectNode;
  12705. /**
  12706. * Updates the bounding box information for the Gizmo
  12707. */
  12708. updateBoundingBox(): void;
  12709. /**
  12710. * Enables rotation on the specified axis and disables rotation on the others
  12711. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  12712. */
  12713. setEnabledRotationAxis(axis: string): void;
  12714. /**
  12715. * Disposes of the gizmo
  12716. */
  12717. dispose(): void;
  12718. /**
  12719. * 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)
  12720. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  12721. * @returns the bounding box mesh with the passed in mesh as a child
  12722. */
  12723. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  12724. /**
  12725. * CustomMeshes are not supported by this gizmo
  12726. * @param mesh The mesh to replace the default mesh of the gizmo
  12727. */
  12728. setCustomMesh(mesh: Mesh): void;
  12729. }
  12730. }
  12731. declare module BABYLON {
  12732. /**
  12733. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  12734. */
  12735. class Gizmo implements IDisposable {
  12736. /** The utility layer the gizmo will be added to */
  12737. gizmoLayer: UtilityLayerRenderer;
  12738. /**
  12739. * The root mesh of the gizmo
  12740. */
  12741. protected _rootMesh: Mesh;
  12742. private _attachedMesh;
  12743. /**
  12744. * Ratio for the scale of the gizmo (Default: 1)
  12745. */
  12746. scaleRatio: number;
  12747. private _tmpMatrix;
  12748. /**
  12749. * If a custom mesh has been set (Default: false)
  12750. */
  12751. protected _customMeshSet: boolean;
  12752. /**
  12753. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  12754. * * When set, interactions will be enabled
  12755. */
  12756. attachedMesh: Nullable<AbstractMesh>;
  12757. /**
  12758. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12759. * @param mesh The mesh to replace the default mesh of the gizmo
  12760. */
  12761. setCustomMesh(mesh: Mesh): void;
  12762. /**
  12763. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  12764. */
  12765. updateGizmoRotationToMatchAttachedMesh: boolean;
  12766. /**
  12767. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  12768. */
  12769. updateGizmoPositionToMatchAttachedMesh: boolean;
  12770. /**
  12771. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  12772. */
  12773. protected _updateScale: boolean;
  12774. protected _interactionsEnabled: boolean;
  12775. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12776. private _beforeRenderObserver;
  12777. /**
  12778. * Creates a gizmo
  12779. * @param gizmoLayer The utility layer the gizmo will be added to
  12780. */
  12781. constructor(
  12782. /** The utility layer the gizmo will be added to */
  12783. gizmoLayer?: UtilityLayerRenderer);
  12784. private _tempVector;
  12785. /**
  12786. * @hidden
  12787. * Updates the gizmo to match the attached mesh's position/rotation
  12788. */
  12789. protected _update(): void;
  12790. /**
  12791. * Disposes of the gizmo
  12792. */
  12793. dispose(): void;
  12794. }
  12795. }
  12796. declare module BABYLON {
  12797. /**
  12798. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  12799. */
  12800. class GizmoManager implements IDisposable {
  12801. private scene;
  12802. /**
  12803. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  12804. */
  12805. gizmos: {
  12806. positionGizmo: Nullable<PositionGizmo>;
  12807. rotationGizmo: Nullable<RotationGizmo>;
  12808. scaleGizmo: Nullable<ScaleGizmo>;
  12809. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  12810. };
  12811. private _gizmosEnabled;
  12812. private _pointerObserver;
  12813. private _attachedMesh;
  12814. private _boundingBoxColor;
  12815. /**
  12816. * When bounding box gizmo is enabled, this can be used to track drag/end events
  12817. */
  12818. boundingBoxDragBehavior: SixDofDragBehavior;
  12819. /**
  12820. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  12821. */
  12822. attachableMeshes: Nullable<Array<AbstractMesh>>;
  12823. /**
  12824. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  12825. */
  12826. usePointerToAttachGizmos: boolean;
  12827. /**
  12828. * Instatiates a gizmo manager
  12829. * @param scene the scene to overlay the gizmos on top of
  12830. */
  12831. constructor(scene: Scene);
  12832. /**
  12833. * Attaches a set of gizmos to the specified mesh
  12834. * @param mesh The mesh the gizmo's should be attached to
  12835. */
  12836. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  12837. /**
  12838. * If the position gizmo is enabled
  12839. */
  12840. positionGizmoEnabled: boolean;
  12841. /**
  12842. * If the rotation gizmo is enabled
  12843. */
  12844. rotationGizmoEnabled: boolean;
  12845. /**
  12846. * If the scale gizmo is enabled
  12847. */
  12848. scaleGizmoEnabled: boolean;
  12849. /**
  12850. * If the boundingBox gizmo is enabled
  12851. */
  12852. boundingBoxGizmoEnabled: boolean;
  12853. /**
  12854. * Disposes of the gizmo manager
  12855. */
  12856. dispose(): void;
  12857. }
  12858. }
  12859. declare module BABYLON {
  12860. /**
  12861. * Single plane rotation gizmo
  12862. */
  12863. class PlaneRotationGizmo extends Gizmo {
  12864. /**
  12865. * Drag behavior responsible for the gizmos dragging interactions
  12866. */
  12867. dragBehavior: PointerDragBehavior;
  12868. private _pointerObserver;
  12869. /**
  12870. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  12871. */
  12872. snapDistance: number;
  12873. /**
  12874. * Event that fires each time the gizmo snaps to a new location.
  12875. * * snapDistance is the the change in distance
  12876. */
  12877. onSnapObservable: Observable<{
  12878. snapDistance: number;
  12879. }>;
  12880. /**
  12881. * Creates a PlaneRotationGizmo
  12882. * @param gizmoLayer The utility layer the gizmo will be added to
  12883. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  12884. * @param color The color of the gizmo
  12885. */
  12886. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12887. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12888. /**
  12889. * Disposes of the gizmo
  12890. */
  12891. dispose(): void;
  12892. }
  12893. }
  12894. declare module BABYLON {
  12895. /**
  12896. * Gizmo that enables dragging a mesh along 3 axis
  12897. */
  12898. class PositionGizmo extends Gizmo {
  12899. /**
  12900. * Internal gizmo used for interactions on the x axis
  12901. */
  12902. xGizmo: AxisDragGizmo;
  12903. /**
  12904. * Internal gizmo used for interactions on the y axis
  12905. */
  12906. yGizmo: AxisDragGizmo;
  12907. /**
  12908. * Internal gizmo used for interactions on the z axis
  12909. */
  12910. zGizmo: AxisDragGizmo;
  12911. attachedMesh: Nullable<AbstractMesh>;
  12912. /**
  12913. * Creates a PositionGizmo
  12914. * @param gizmoLayer The utility layer the gizmo will be added to
  12915. */
  12916. constructor(gizmoLayer?: UtilityLayerRenderer);
  12917. updateGizmoRotationToMatchAttachedMesh: boolean;
  12918. /**
  12919. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12920. */
  12921. snapDistance: number;
  12922. /**
  12923. * Ratio for the scale of the gizmo (Default: 1)
  12924. */
  12925. scaleRatio: number;
  12926. /**
  12927. * Disposes of the gizmo
  12928. */
  12929. dispose(): void;
  12930. /**
  12931. * CustomMeshes are not supported by this gizmo
  12932. * @param mesh The mesh to replace the default mesh of the gizmo
  12933. */
  12934. setCustomMesh(mesh: Mesh): void;
  12935. }
  12936. }
  12937. declare module BABYLON {
  12938. /**
  12939. * Gizmo that enables rotating a mesh along 3 axis
  12940. */
  12941. class RotationGizmo extends Gizmo {
  12942. /**
  12943. * Internal gizmo used for interactions on the x axis
  12944. */
  12945. xGizmo: PlaneRotationGizmo;
  12946. /**
  12947. * Internal gizmo used for interactions on the y axis
  12948. */
  12949. yGizmo: PlaneRotationGizmo;
  12950. /**
  12951. * Internal gizmo used for interactions on the z axis
  12952. */
  12953. zGizmo: PlaneRotationGizmo;
  12954. attachedMesh: Nullable<AbstractMesh>;
  12955. /**
  12956. * Creates a RotationGizmo
  12957. * @param gizmoLayer The utility layer the gizmo will be added to
  12958. */
  12959. constructor(gizmoLayer?: UtilityLayerRenderer);
  12960. updateGizmoRotationToMatchAttachedMesh: boolean;
  12961. /**
  12962. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12963. */
  12964. snapDistance: number;
  12965. /**
  12966. * Ratio for the scale of the gizmo (Default: 1)
  12967. */
  12968. scaleRatio: number;
  12969. /**
  12970. * Disposes of the gizmo
  12971. */
  12972. dispose(): void;
  12973. /**
  12974. * CustomMeshes are not supported by this gizmo
  12975. * @param mesh The mesh to replace the default mesh of the gizmo
  12976. */
  12977. setCustomMesh(mesh: Mesh): void;
  12978. }
  12979. }
  12980. declare module BABYLON {
  12981. /**
  12982. * Gizmo that enables scaling a mesh along 3 axis
  12983. */
  12984. class ScaleGizmo extends Gizmo {
  12985. /**
  12986. * Internal gizmo used for interactions on the x axis
  12987. */
  12988. xGizmo: AxisScaleGizmo;
  12989. /**
  12990. * Internal gizmo used for interactions on the y axis
  12991. */
  12992. yGizmo: AxisScaleGizmo;
  12993. /**
  12994. * Internal gizmo used for interactions on the z axis
  12995. */
  12996. zGizmo: AxisScaleGizmo;
  12997. /**
  12998. * Internal gizmo used to scale all axis equally
  12999. */
  13000. uniformScaleGizmo: AxisScaleGizmo;
  13001. attachedMesh: Nullable<AbstractMesh>;
  13002. /**
  13003. * Creates a ScaleGizmo
  13004. * @param gizmoLayer The utility layer the gizmo will be added to
  13005. */
  13006. constructor(gizmoLayer?: UtilityLayerRenderer);
  13007. updateGizmoRotationToMatchAttachedMesh: boolean;
  13008. /**
  13009. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13010. */
  13011. snapDistance: number;
  13012. /**
  13013. * Ratio for the scale of the gizmo (Default: 1)
  13014. */
  13015. scaleRatio: number;
  13016. /**
  13017. * Disposes of the gizmo
  13018. */
  13019. dispose(): void;
  13020. }
  13021. }
  13022. declare module BABYLON {
  13023. /**
  13024. * Represents the different options available during the creation of
  13025. * a Environment helper.
  13026. *
  13027. * This can control the default ground, skybox and image processing setup of your scene.
  13028. */
  13029. interface IEnvironmentHelperOptions {
  13030. /**
  13031. * Specifies wether or not to create a ground.
  13032. * True by default.
  13033. */
  13034. createGround: boolean;
  13035. /**
  13036. * Specifies the ground size.
  13037. * 15 by default.
  13038. */
  13039. groundSize: number;
  13040. /**
  13041. * The texture used on the ground for the main color.
  13042. * Comes from the BabylonJS CDN by default.
  13043. *
  13044. * Remarks: Can be either a texture or a url.
  13045. */
  13046. groundTexture: string | BaseTexture;
  13047. /**
  13048. * The color mixed in the ground texture by default.
  13049. * BabylonJS clearColor by default.
  13050. */
  13051. groundColor: Color3;
  13052. /**
  13053. * Specifies the ground opacity.
  13054. * 1 by default.
  13055. */
  13056. groundOpacity: number;
  13057. /**
  13058. * Enables the ground to receive shadows.
  13059. * True by default.
  13060. */
  13061. enableGroundShadow: boolean;
  13062. /**
  13063. * Helps preventing the shadow to be fully black on the ground.
  13064. * 0.5 by default.
  13065. */
  13066. groundShadowLevel: number;
  13067. /**
  13068. * Creates a mirror texture attach to the ground.
  13069. * false by default.
  13070. */
  13071. enableGroundMirror: boolean;
  13072. /**
  13073. * Specifies the ground mirror size ratio.
  13074. * 0.3 by default as the default kernel is 64.
  13075. */
  13076. groundMirrorSizeRatio: number;
  13077. /**
  13078. * Specifies the ground mirror blur kernel size.
  13079. * 64 by default.
  13080. */
  13081. groundMirrorBlurKernel: number;
  13082. /**
  13083. * Specifies the ground mirror visibility amount.
  13084. * 1 by default
  13085. */
  13086. groundMirrorAmount: number;
  13087. /**
  13088. * Specifies the ground mirror reflectance weight.
  13089. * This uses the standard weight of the background material to setup the fresnel effect
  13090. * of the mirror.
  13091. * 1 by default.
  13092. */
  13093. groundMirrorFresnelWeight: number;
  13094. /**
  13095. * Specifies the ground mirror Falloff distance.
  13096. * This can helps reducing the size of the reflection.
  13097. * 0 by Default.
  13098. */
  13099. groundMirrorFallOffDistance: number;
  13100. /**
  13101. * Specifies the ground mirror texture type.
  13102. * Unsigned Int by Default.
  13103. */
  13104. groundMirrorTextureType: number;
  13105. /**
  13106. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13107. * the shown objects.
  13108. */
  13109. groundYBias: number;
  13110. /**
  13111. * Specifies wether or not to create a skybox.
  13112. * True by default.
  13113. */
  13114. createSkybox: boolean;
  13115. /**
  13116. * Specifies the skybox size.
  13117. * 20 by default.
  13118. */
  13119. skyboxSize: number;
  13120. /**
  13121. * The texture used on the skybox for the main color.
  13122. * Comes from the BabylonJS CDN by default.
  13123. *
  13124. * Remarks: Can be either a texture or a url.
  13125. */
  13126. skyboxTexture: string | BaseTexture;
  13127. /**
  13128. * The color mixed in the skybox texture by default.
  13129. * BabylonJS clearColor by default.
  13130. */
  13131. skyboxColor: Color3;
  13132. /**
  13133. * The background rotation around the Y axis of the scene.
  13134. * This helps aligning the key lights of your scene with the background.
  13135. * 0 by default.
  13136. */
  13137. backgroundYRotation: number;
  13138. /**
  13139. * Compute automatically the size of the elements to best fit with the scene.
  13140. */
  13141. sizeAuto: boolean;
  13142. /**
  13143. * Default position of the rootMesh if autoSize is not true.
  13144. */
  13145. rootPosition: Vector3;
  13146. /**
  13147. * Sets up the image processing in the scene.
  13148. * true by default.
  13149. */
  13150. setupImageProcessing: boolean;
  13151. /**
  13152. * The texture used as your environment texture in the scene.
  13153. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13154. *
  13155. * Remarks: Can be either a texture or a url.
  13156. */
  13157. environmentTexture: string | BaseTexture;
  13158. /**
  13159. * The value of the exposure to apply to the scene.
  13160. * 0.6 by default if setupImageProcessing is true.
  13161. */
  13162. cameraExposure: number;
  13163. /**
  13164. * The value of the contrast to apply to the scene.
  13165. * 1.6 by default if setupImageProcessing is true.
  13166. */
  13167. cameraContrast: number;
  13168. /**
  13169. * Specifies wether or not tonemapping should be enabled in the scene.
  13170. * true by default if setupImageProcessing is true.
  13171. */
  13172. toneMappingEnabled: boolean;
  13173. }
  13174. /**
  13175. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13176. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13177. * It also helps with the default setup of your imageProcessing configuration.
  13178. */
  13179. class EnvironmentHelper {
  13180. /**
  13181. * Default ground texture URL.
  13182. */
  13183. private static _groundTextureCDNUrl;
  13184. /**
  13185. * Default skybox texture URL.
  13186. */
  13187. private static _skyboxTextureCDNUrl;
  13188. /**
  13189. * Default environment texture URL.
  13190. */
  13191. private static _environmentTextureCDNUrl;
  13192. /**
  13193. * Creates the default options for the helper.
  13194. */
  13195. private static _getDefaultOptions;
  13196. private _rootMesh;
  13197. /**
  13198. * Gets the root mesh created by the helper.
  13199. */
  13200. readonly rootMesh: Mesh;
  13201. private _skybox;
  13202. /**
  13203. * Gets the skybox created by the helper.
  13204. */
  13205. readonly skybox: Nullable<Mesh>;
  13206. private _skyboxTexture;
  13207. /**
  13208. * Gets the skybox texture created by the helper.
  13209. */
  13210. readonly skyboxTexture: Nullable<BaseTexture>;
  13211. private _skyboxMaterial;
  13212. /**
  13213. * Gets the skybox material created by the helper.
  13214. */
  13215. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13216. private _ground;
  13217. /**
  13218. * Gets the ground mesh created by the helper.
  13219. */
  13220. readonly ground: Nullable<Mesh>;
  13221. private _groundTexture;
  13222. /**
  13223. * Gets the ground texture created by the helper.
  13224. */
  13225. readonly groundTexture: Nullable<BaseTexture>;
  13226. private _groundMirror;
  13227. /**
  13228. * Gets the ground mirror created by the helper.
  13229. */
  13230. readonly groundMirror: Nullable<MirrorTexture>;
  13231. /**
  13232. * Gets the ground mirror render list to helps pushing the meshes
  13233. * you wish in the ground reflection.
  13234. */
  13235. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13236. private _groundMaterial;
  13237. /**
  13238. * Gets the ground material created by the helper.
  13239. */
  13240. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13241. /**
  13242. * Stores the creation options.
  13243. */
  13244. private readonly _scene;
  13245. private _options;
  13246. /**
  13247. * This observable will be notified with any error during the creation of the environment,
  13248. * mainly texture creation errors.
  13249. */
  13250. onErrorObservable: Observable<{
  13251. message?: string;
  13252. exception?: any;
  13253. }>;
  13254. /**
  13255. * constructor
  13256. * @param options
  13257. * @param scene The scene to add the material to
  13258. */
  13259. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13260. /**
  13261. * Updates the background according to the new options
  13262. * @param options
  13263. */
  13264. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13265. /**
  13266. * Sets the primary color of all the available elements.
  13267. * @param color the main color to affect to the ground and the background
  13268. */
  13269. setMainColor(color: Color3): void;
  13270. /**
  13271. * Setup the image processing according to the specified options.
  13272. */
  13273. private _setupImageProcessing;
  13274. /**
  13275. * Setup the environment texture according to the specified options.
  13276. */
  13277. private _setupEnvironmentTexture;
  13278. /**
  13279. * Setup the background according to the specified options.
  13280. */
  13281. private _setupBackground;
  13282. /**
  13283. * Get the scene sizes according to the setup.
  13284. */
  13285. private _getSceneSize;
  13286. /**
  13287. * Setup the ground according to the specified options.
  13288. */
  13289. private _setupGround;
  13290. /**
  13291. * Setup the ground material according to the specified options.
  13292. */
  13293. private _setupGroundMaterial;
  13294. /**
  13295. * Setup the ground diffuse texture according to the specified options.
  13296. */
  13297. private _setupGroundDiffuseTexture;
  13298. /**
  13299. * Setup the ground mirror texture according to the specified options.
  13300. */
  13301. private _setupGroundMirrorTexture;
  13302. /**
  13303. * Setup the ground to receive the mirror texture.
  13304. */
  13305. private _setupMirrorInGroundMaterial;
  13306. /**
  13307. * Setup the skybox according to the specified options.
  13308. */
  13309. private _setupSkybox;
  13310. /**
  13311. * Setup the skybox material according to the specified options.
  13312. */
  13313. private _setupSkyboxMaterial;
  13314. /**
  13315. * Setup the skybox reflection texture according to the specified options.
  13316. */
  13317. private _setupSkyboxReflectionTexture;
  13318. private _errorHandler;
  13319. /**
  13320. * Dispose all the elements created by the Helper.
  13321. */
  13322. dispose(): void;
  13323. }
  13324. }
  13325. declare module BABYLON {
  13326. /**
  13327. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13328. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13329. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13330. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13331. */
  13332. class PhotoDome extends TransformNode {
  13333. private _useDirectMapping;
  13334. /**
  13335. * The texture being displayed on the sphere
  13336. */
  13337. protected _photoTexture: Texture;
  13338. /**
  13339. * Gets or sets the texture being displayed on the sphere
  13340. */
  13341. photoTexture: Texture;
  13342. /**
  13343. * Observable raised when an error occured while loading the 360 image
  13344. */
  13345. onLoadErrorObservable: Observable<string>;
  13346. /**
  13347. * The skybox material
  13348. */
  13349. protected _material: BackgroundMaterial;
  13350. /**
  13351. * The surface used for the skybox
  13352. */
  13353. protected _mesh: Mesh;
  13354. /**
  13355. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13356. * Also see the options.resolution property.
  13357. */
  13358. fovMultiplier: number;
  13359. /**
  13360. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13361. * @param name Element's name, child elements will append suffixes for their own names.
  13362. * @param urlsOfPhoto defines the url of the photo to display
  13363. * @param options defines an object containing optional or exposed sub element properties
  13364. * @param onError defines a callback called when an error occured while loading the texture
  13365. */
  13366. constructor(name: string, urlOfPhoto: string, options: {
  13367. resolution?: number;
  13368. size?: number;
  13369. useDirectMapping?: boolean;
  13370. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13371. /**
  13372. * Releases resources associated with this node.
  13373. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13374. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13375. */
  13376. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13377. }
  13378. }
  13379. declare module BABYLON {
  13380. interface Scene {
  13381. /**
  13382. * Creates a default light for the scene.
  13383. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13384. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13385. */
  13386. createDefaultLight(replace?: boolean): void;
  13387. /**
  13388. * Creates a default camera for the scene.
  13389. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13390. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13391. * @param replace has default false, when true replaces the active camera in the scene
  13392. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13393. */
  13394. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13395. /**
  13396. * Creates a default camera and a default light.
  13397. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13398. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13399. * @param replace has the default false, when true replaces the active camera/light in the scene
  13400. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13401. */
  13402. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13403. /**
  13404. * Creates a new sky box
  13405. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13406. * @param environmentTexture defines the texture to use as environment texture
  13407. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13408. * @param scale defines the overall scale of the skybox
  13409. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13410. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13411. * @returns a new mesh holding the sky box
  13412. */
  13413. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13414. /**
  13415. * Creates a new environment
  13416. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13417. * @param options defines the options you can use to configure the environment
  13418. * @returns the new EnvironmentHelper
  13419. */
  13420. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13421. /**
  13422. * Creates a new VREXperienceHelper
  13423. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13424. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13425. * @returns a new VREXperienceHelper
  13426. */
  13427. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13428. }
  13429. }
  13430. declare module BABYLON {
  13431. /**
  13432. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13433. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13434. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13435. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13436. */
  13437. class VideoDome extends TransformNode {
  13438. private _useDirectMapping;
  13439. /**
  13440. * The video texture being displayed on the sphere
  13441. */
  13442. protected _videoTexture: VideoTexture;
  13443. /**
  13444. * Gets the video texture being displayed on the sphere
  13445. */
  13446. readonly videoTexture: VideoTexture;
  13447. /**
  13448. * The skybox material
  13449. */
  13450. protected _material: BackgroundMaterial;
  13451. /**
  13452. * The surface used for the skybox
  13453. */
  13454. protected _mesh: Mesh;
  13455. /**
  13456. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13457. * Also see the options.resolution property.
  13458. */
  13459. fovMultiplier: number;
  13460. /**
  13461. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13462. * @param name Element's name, child elements will append suffixes for their own names.
  13463. * @param urlsOrVideo defines the url(s) or the video element to use
  13464. * @param options An object containing optional or exposed sub element properties
  13465. */
  13466. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13467. resolution?: number;
  13468. clickToPlay?: boolean;
  13469. autoPlay?: boolean;
  13470. loop?: boolean;
  13471. size?: number;
  13472. poster?: string;
  13473. useDirectMapping?: boolean;
  13474. }, scene: Scene);
  13475. /**
  13476. * Releases resources associated with this node.
  13477. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13478. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13479. */
  13480. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13481. }
  13482. }
  13483. declare module BABYLON {
  13484. /**
  13485. * This class can be used to get instrumentation data from a Babylon engine
  13486. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13487. */
  13488. class EngineInstrumentation implements IDisposable {
  13489. /**
  13490. * Define the instrumented engine.
  13491. */
  13492. engine: Engine;
  13493. private _captureGPUFrameTime;
  13494. private _gpuFrameTimeToken;
  13495. private _gpuFrameTime;
  13496. private _captureShaderCompilationTime;
  13497. private _shaderCompilationTime;
  13498. private _onBeginFrameObserver;
  13499. private _onEndFrameObserver;
  13500. private _onBeforeShaderCompilationObserver;
  13501. private _onAfterShaderCompilationObserver;
  13502. /**
  13503. * Gets the perf counter used for GPU frame time
  13504. */
  13505. readonly gpuFrameTimeCounter: PerfCounter;
  13506. /**
  13507. * Gets the GPU frame time capture status
  13508. */
  13509. /**
  13510. * Enable or disable the GPU frame time capture
  13511. */
  13512. captureGPUFrameTime: boolean;
  13513. /**
  13514. * Gets the perf counter used for shader compilation time
  13515. */
  13516. readonly shaderCompilationTimeCounter: PerfCounter;
  13517. /**
  13518. * Gets the shader compilation time capture status
  13519. */
  13520. /**
  13521. * Enable or disable the shader compilation time capture
  13522. */
  13523. captureShaderCompilationTime: boolean;
  13524. /**
  13525. * Instantiates a new engine instrumentation.
  13526. * This class can be used to get instrumentation data from a Babylon engine
  13527. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13528. * @param engine Defines the engine to instrument
  13529. */
  13530. constructor(
  13531. /**
  13532. * Define the instrumented engine.
  13533. */
  13534. engine: Engine);
  13535. /**
  13536. * Dispose and release associated resources.
  13537. */
  13538. dispose(): void;
  13539. }
  13540. }
  13541. declare module BABYLON {
  13542. /**
  13543. * This class can be used to get instrumentation data from a Babylon engine
  13544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13545. */
  13546. class SceneInstrumentation implements IDisposable {
  13547. /**
  13548. * Defines the scene to instrument
  13549. */
  13550. scene: Scene;
  13551. private _captureActiveMeshesEvaluationTime;
  13552. private _activeMeshesEvaluationTime;
  13553. private _captureRenderTargetsRenderTime;
  13554. private _renderTargetsRenderTime;
  13555. private _captureFrameTime;
  13556. private _frameTime;
  13557. private _captureRenderTime;
  13558. private _renderTime;
  13559. private _captureInterFrameTime;
  13560. private _interFrameTime;
  13561. private _captureParticlesRenderTime;
  13562. private _particlesRenderTime;
  13563. private _captureSpritesRenderTime;
  13564. private _spritesRenderTime;
  13565. private _capturePhysicsTime;
  13566. private _physicsTime;
  13567. private _captureAnimationsTime;
  13568. private _animationsTime;
  13569. private _captureCameraRenderTime;
  13570. private _cameraRenderTime;
  13571. private _onBeforeActiveMeshesEvaluationObserver;
  13572. private _onAfterActiveMeshesEvaluationObserver;
  13573. private _onBeforeRenderTargetsRenderObserver;
  13574. private _onAfterRenderTargetsRenderObserver;
  13575. private _onAfterRenderObserver;
  13576. private _onBeforeDrawPhaseObserver;
  13577. private _onAfterDrawPhaseObserver;
  13578. private _onBeforeAnimationsObserver;
  13579. private _onBeforeParticlesRenderingObserver;
  13580. private _onAfterParticlesRenderingObserver;
  13581. private _onBeforeSpritesRenderingObserver;
  13582. private _onAfterSpritesRenderingObserver;
  13583. private _onBeforePhysicsObserver;
  13584. private _onAfterPhysicsObserver;
  13585. private _onAfterAnimationsObserver;
  13586. private _onBeforeCameraRenderObserver;
  13587. private _onAfterCameraRenderObserver;
  13588. /**
  13589. * Gets the perf counter used for active meshes evaluation time
  13590. */
  13591. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13592. /**
  13593. * Gets the active meshes evaluation time capture status
  13594. */
  13595. /**
  13596. * Enable or disable the active meshes evaluation time capture
  13597. */
  13598. captureActiveMeshesEvaluationTime: boolean;
  13599. /**
  13600. * Gets the perf counter used for render targets render time
  13601. */
  13602. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13603. /**
  13604. * Gets the render targets render time capture status
  13605. */
  13606. /**
  13607. * Enable or disable the render targets render time capture
  13608. */
  13609. captureRenderTargetsRenderTime: boolean;
  13610. /**
  13611. * Gets the perf counter used for particles render time
  13612. */
  13613. readonly particlesRenderTimeCounter: PerfCounter;
  13614. /**
  13615. * Gets the particles render time capture status
  13616. */
  13617. /**
  13618. * Enable or disable the particles render time capture
  13619. */
  13620. captureParticlesRenderTime: boolean;
  13621. /**
  13622. * Gets the perf counter used for sprites render time
  13623. */
  13624. readonly spritesRenderTimeCounter: PerfCounter;
  13625. /**
  13626. * Gets the sprites render time capture status
  13627. */
  13628. /**
  13629. * Enable or disable the sprites render time capture
  13630. */
  13631. captureSpritesRenderTime: boolean;
  13632. /**
  13633. * Gets the perf counter used for physics time
  13634. */
  13635. readonly physicsTimeCounter: PerfCounter;
  13636. /**
  13637. * Gets the physics time capture status
  13638. */
  13639. /**
  13640. * Enable or disable the physics time capture
  13641. */
  13642. capturePhysicsTime: boolean;
  13643. /**
  13644. * Gets the perf counter used for animations time
  13645. */
  13646. readonly animationsTimeCounter: PerfCounter;
  13647. /**
  13648. * Gets the animations time capture status
  13649. */
  13650. /**
  13651. * Enable or disable the animations time capture
  13652. */
  13653. captureAnimationsTime: boolean;
  13654. /**
  13655. * Gets the perf counter used for frame time capture
  13656. */
  13657. readonly frameTimeCounter: PerfCounter;
  13658. /**
  13659. * Gets the frame time capture status
  13660. */
  13661. /**
  13662. * Enable or disable the frame time capture
  13663. */
  13664. captureFrameTime: boolean;
  13665. /**
  13666. * Gets the perf counter used for inter-frames time capture
  13667. */
  13668. readonly interFrameTimeCounter: PerfCounter;
  13669. /**
  13670. * Gets the inter-frames time capture status
  13671. */
  13672. /**
  13673. * Enable or disable the inter-frames time capture
  13674. */
  13675. captureInterFrameTime: boolean;
  13676. /**
  13677. * Gets the perf counter used for render time capture
  13678. */
  13679. readonly renderTimeCounter: PerfCounter;
  13680. /**
  13681. * Gets the render time capture status
  13682. */
  13683. /**
  13684. * Enable or disable the render time capture
  13685. */
  13686. captureRenderTime: boolean;
  13687. /**
  13688. * Gets the perf counter used for camera render time capture
  13689. */
  13690. readonly cameraRenderTimeCounter: PerfCounter;
  13691. /**
  13692. * Gets the camera render time capture status
  13693. */
  13694. /**
  13695. * Enable or disable the camera render time capture
  13696. */
  13697. captureCameraRenderTime: boolean;
  13698. /**
  13699. * Gets the perf counter used for draw calls
  13700. */
  13701. readonly drawCallsCounter: PerfCounter;
  13702. /**
  13703. * Gets the perf counter used for texture collisions
  13704. */
  13705. readonly textureCollisionsCounter: PerfCounter;
  13706. /**
  13707. * Instantiates a new scene instrumentation.
  13708. * This class can be used to get instrumentation data from a Babylon engine
  13709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13710. * @param scene Defines the scene to instrument
  13711. */
  13712. constructor(
  13713. /**
  13714. * Defines the scene to instrument
  13715. */
  13716. scene: Scene);
  13717. /**
  13718. * Dispose and release associated resources.
  13719. */
  13720. dispose(): void;
  13721. }
  13722. }
  13723. declare module BABYLON {
  13724. /**
  13725. * @hidden
  13726. **/
  13727. class _TimeToken {
  13728. _startTimeQuery: Nullable<WebGLQuery>;
  13729. _endTimeQuery: Nullable<WebGLQuery>;
  13730. _timeElapsedQuery: Nullable<WebGLQuery>;
  13731. _timeElapsedQueryEnded: boolean;
  13732. }
  13733. }
  13734. declare module BABYLON {
  13735. /**
  13736. * Effect layer options. This helps customizing the behaviour
  13737. * of the effect layer.
  13738. */
  13739. interface IEffectLayerOptions {
  13740. /**
  13741. * Multiplication factor apply to the canvas size to compute the render target size
  13742. * used to generated the objects (the smaller the faster).
  13743. */
  13744. mainTextureRatio: number;
  13745. /**
  13746. * Enforces a fixed size texture to ensure effect stability across devices.
  13747. */
  13748. mainTextureFixedSize?: number;
  13749. /**
  13750. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  13751. */
  13752. alphaBlendingMode: number;
  13753. /**
  13754. * The camera attached to the layer.
  13755. */
  13756. camera: Nullable<Camera>;
  13757. /**
  13758. * The rendering group to draw the layer in.
  13759. */
  13760. renderingGroupId: number;
  13761. }
  13762. /**
  13763. * The effect layer Helps adding post process effect blended with the main pass.
  13764. *
  13765. * This can be for instance use to generate glow or higlight effects on the scene.
  13766. *
  13767. * The effect layer class can not be used directly and is intented to inherited from to be
  13768. * customized per effects.
  13769. */
  13770. abstract class EffectLayer {
  13771. private _vertexBuffers;
  13772. private _indexBuffer;
  13773. private _cachedDefines;
  13774. private _effectLayerMapGenerationEffect;
  13775. private _effectLayerOptions;
  13776. private _mergeEffect;
  13777. protected _scene: Scene;
  13778. protected _engine: Engine;
  13779. protected _maxSize: number;
  13780. protected _mainTextureDesiredSize: ISize;
  13781. protected _mainTexture: RenderTargetTexture;
  13782. protected _shouldRender: boolean;
  13783. protected _postProcesses: PostProcess[];
  13784. protected _textures: BaseTexture[];
  13785. protected _emissiveTextureAndColor: {
  13786. texture: Nullable<BaseTexture>;
  13787. color: Color4;
  13788. };
  13789. /**
  13790. * The name of the layer
  13791. */
  13792. name: string;
  13793. /**
  13794. * The clear color of the texture used to generate the glow map.
  13795. */
  13796. neutralColor: Color4;
  13797. /**
  13798. * Specifies wether the highlight layer is enabled or not.
  13799. */
  13800. isEnabled: boolean;
  13801. /**
  13802. * Gets the camera attached to the layer.
  13803. */
  13804. readonly camera: Nullable<Camera>;
  13805. /**
  13806. * Gets the rendering group id the layer should render in.
  13807. */
  13808. readonly renderingGroupId: number;
  13809. /**
  13810. * An event triggered when the effect layer has been disposed.
  13811. */
  13812. onDisposeObservable: Observable<EffectLayer>;
  13813. /**
  13814. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  13815. */
  13816. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  13817. /**
  13818. * An event triggered when the generated texture is being merged in the scene.
  13819. */
  13820. onBeforeComposeObservable: Observable<EffectLayer>;
  13821. /**
  13822. * An event triggered when the generated texture has been merged in the scene.
  13823. */
  13824. onAfterComposeObservable: Observable<EffectLayer>;
  13825. /**
  13826. * An event triggered when the efffect layer changes its size.
  13827. */
  13828. onSizeChangedObservable: Observable<EffectLayer>;
  13829. /**
  13830. * Instantiates a new effect Layer and references it in the scene.
  13831. * @param name The name of the layer
  13832. * @param scene The scene to use the layer in
  13833. */
  13834. constructor(
  13835. /** The Friendly of the effect in the scene */
  13836. name: string, scene: Scene);
  13837. /**
  13838. * Get the effect name of the layer.
  13839. * @return The effect name
  13840. */
  13841. abstract getEffectName(): string;
  13842. /**
  13843. * Checks for the readiness of the element composing the layer.
  13844. * @param subMesh the mesh to check for
  13845. * @param useInstances specify wether or not to use instances to render the mesh
  13846. * @return true if ready otherwise, false
  13847. */
  13848. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  13849. /**
  13850. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  13851. * @returns true if the effect requires stencil during the main canvas render pass.
  13852. */
  13853. abstract needStencil(): boolean;
  13854. /**
  13855. * Create the merge effect. This is the shader use to blit the information back
  13856. * to the main canvas at the end of the scene rendering.
  13857. * @returns The effect containing the shader used to merge the effect on the main canvas
  13858. */
  13859. protected abstract _createMergeEffect(): Effect;
  13860. /**
  13861. * Creates the render target textures and post processes used in the effect layer.
  13862. */
  13863. protected abstract _createTextureAndPostProcesses(): void;
  13864. /**
  13865. * Implementation specific of rendering the generating effect on the main canvas.
  13866. * @param effect The effect used to render through
  13867. */
  13868. protected abstract _internalRender(effect: Effect): void;
  13869. /**
  13870. * Sets the required values for both the emissive texture and and the main color.
  13871. */
  13872. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  13873. /**
  13874. * Free any resources and references associated to a mesh.
  13875. * Internal use
  13876. * @param mesh The mesh to free.
  13877. */
  13878. abstract _disposeMesh(mesh: Mesh): void;
  13879. /**
  13880. * Serializes this layer (Glow or Highlight for example)
  13881. * @returns a serialized layer object
  13882. */
  13883. abstract serialize?(): any;
  13884. /**
  13885. * Initializes the effect layer with the required options.
  13886. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  13887. */
  13888. protected _init(options: Partial<IEffectLayerOptions>): void;
  13889. /**
  13890. * Generates the index buffer of the full screen quad blending to the main canvas.
  13891. */
  13892. private _generateIndexBuffer;
  13893. /**
  13894. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  13895. */
  13896. private _genrateVertexBuffer;
  13897. /**
  13898. * Sets the main texture desired size which is the closest power of two
  13899. * of the engine canvas size.
  13900. */
  13901. private _setMainTextureSize;
  13902. /**
  13903. * Creates the main texture for the effect layer.
  13904. */
  13905. protected _createMainTexture(): void;
  13906. /**
  13907. * Checks for the readiness of the element composing the layer.
  13908. * @param subMesh the mesh to check for
  13909. * @param useInstances specify wether or not to use instances to render the mesh
  13910. * @param emissiveTexture the associated emissive texture used to generate the glow
  13911. * @return true if ready otherwise, false
  13912. */
  13913. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  13914. /**
  13915. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  13916. */
  13917. render(): void;
  13918. /**
  13919. * Determine if a given mesh will be used in the current effect.
  13920. * @param mesh mesh to test
  13921. * @returns true if the mesh will be used
  13922. */
  13923. hasMesh(mesh: AbstractMesh): boolean;
  13924. /**
  13925. * Returns true if the layer contains information to display, otherwise false.
  13926. * @returns true if the glow layer should be rendered
  13927. */
  13928. shouldRender(): boolean;
  13929. /**
  13930. * Returns true if the mesh should render, otherwise false.
  13931. * @param mesh The mesh to render
  13932. * @returns true if it should render otherwise false
  13933. */
  13934. protected _shouldRenderMesh(mesh: Mesh): boolean;
  13935. /**
  13936. * Returns true if the mesh should render, otherwise false.
  13937. * @param mesh The mesh to render
  13938. * @returns true if it should render otherwise false
  13939. */
  13940. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  13941. /**
  13942. * Renders the submesh passed in parameter to the generation map.
  13943. */
  13944. protected _renderSubMesh(subMesh: SubMesh): void;
  13945. /**
  13946. * Rebuild the required buffers.
  13947. * @hidden Internal use only.
  13948. */
  13949. _rebuild(): void;
  13950. /**
  13951. * Dispose only the render target textures and post process.
  13952. */
  13953. private _disposeTextureAndPostProcesses;
  13954. /**
  13955. * Dispose the highlight layer and free resources.
  13956. */
  13957. dispose(): void;
  13958. /**
  13959. * Gets the class name of the effect layer
  13960. * @returns the string with the class name of the effect layer
  13961. */
  13962. getClassName(): string;
  13963. /**
  13964. * Creates an effect layer from parsed effect layer data
  13965. * @param parsedEffectLayer defines effect layer data
  13966. * @param scene defines the current scene
  13967. * @param rootUrl defines the root URL containing the effect layer information
  13968. * @returns a parsed effect Layer
  13969. */
  13970. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  13971. }
  13972. }
  13973. declare module BABYLON {
  13974. interface AbstractScene {
  13975. /**
  13976. * The list of effect layers (highlights/glow) added to the scene
  13977. * @see http://doc.babylonjs.com/how_to/highlight_layer
  13978. * @see http://doc.babylonjs.com/how_to/glow_layer
  13979. */
  13980. effectLayers: Array<EffectLayer>;
  13981. /**
  13982. * Removes the given effect layer from this scene.
  13983. * @param toRemove defines the effect layer to remove
  13984. * @returns the index of the removed effect layer
  13985. */
  13986. removeEffectLayer(toRemove: EffectLayer): number;
  13987. /**
  13988. * Adds the given effect layer to this scene
  13989. * @param newEffectLayer defines the effect layer to add
  13990. */
  13991. addEffectLayer(newEffectLayer: EffectLayer): void;
  13992. }
  13993. /**
  13994. * Defines the layer scene component responsible to manage any effect layers
  13995. * in a given scene.
  13996. */
  13997. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  13998. /**
  13999. * The component name helpfull to identify the component in the list of scene components.
  14000. */
  14001. readonly name: string;
  14002. /**
  14003. * The scene the component belongs to.
  14004. */
  14005. scene: Scene;
  14006. private _engine;
  14007. private _renderEffects;
  14008. private _needStencil;
  14009. private _previousStencilState;
  14010. /**
  14011. * Creates a new instance of the component for the given scene
  14012. * @param scene Defines the scene to register the component in
  14013. */
  14014. constructor(scene: Scene);
  14015. /**
  14016. * Registers the component in a given scene
  14017. */
  14018. register(): void;
  14019. /**
  14020. * Rebuilds the elements related to this component in case of
  14021. * context lost for instance.
  14022. */
  14023. rebuild(): void;
  14024. /**
  14025. * Serializes the component data to the specified json object
  14026. * @param serializationObject The object to serialize to
  14027. */
  14028. serialize(serializationObject: any): void;
  14029. /**
  14030. * Adds all the element from the container to the scene
  14031. * @param container the container holding the elements
  14032. */
  14033. addFromContainer(container: AbstractScene): void;
  14034. /**
  14035. * Removes all the elements in the container from the scene
  14036. * @param container contains the elements to remove
  14037. */
  14038. removeFromContainer(container: AbstractScene): void;
  14039. /**
  14040. * Disposes the component and the associated ressources.
  14041. */
  14042. dispose(): void;
  14043. private _isReadyForMesh;
  14044. private _renderMainTexture;
  14045. private _setStencil;
  14046. private _setStencilBack;
  14047. private _draw;
  14048. private _drawCamera;
  14049. private _drawRenderingGroup;
  14050. }
  14051. }
  14052. declare module BABYLON {
  14053. interface AbstractScene {
  14054. /**
  14055. * Return a the first highlight layer of the scene with a given name.
  14056. * @param name The name of the highlight layer to look for.
  14057. * @return The highlight layer if found otherwise null.
  14058. */
  14059. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14060. }
  14061. /**
  14062. * Glow layer options. This helps customizing the behaviour
  14063. * of the glow layer.
  14064. */
  14065. interface IGlowLayerOptions {
  14066. /**
  14067. * Multiplication factor apply to the canvas size to compute the render target size
  14068. * used to generated the glowing objects (the smaller the faster).
  14069. */
  14070. mainTextureRatio: number;
  14071. /**
  14072. * Enforces a fixed size texture to ensure resize independant blur.
  14073. */
  14074. mainTextureFixedSize?: number;
  14075. /**
  14076. * How big is the kernel of the blur texture.
  14077. */
  14078. blurKernelSize: number;
  14079. /**
  14080. * The camera attached to the layer.
  14081. */
  14082. camera: Nullable<Camera>;
  14083. /**
  14084. * Enable MSAA by chosing the number of samples.
  14085. */
  14086. mainTextureSamples?: number;
  14087. /**
  14088. * The rendering group to draw the layer in.
  14089. */
  14090. renderingGroupId: number;
  14091. }
  14092. /**
  14093. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14094. *
  14095. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14096. * glowy meshes to your scene.
  14097. *
  14098. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14099. */
  14100. class GlowLayer extends EffectLayer {
  14101. /**
  14102. * Effect Name of the layer.
  14103. */
  14104. static readonly EffectName: string;
  14105. /**
  14106. * The default blur kernel size used for the glow.
  14107. */
  14108. static DefaultBlurKernelSize: number;
  14109. /**
  14110. * The default texture size ratio used for the glow.
  14111. */
  14112. static DefaultTextureRatio: number;
  14113. /**
  14114. * Sets the kernel size of the blur.
  14115. */
  14116. /**
  14117. * Gets the kernel size of the blur.
  14118. */
  14119. blurKernelSize: number;
  14120. /**
  14121. * Sets the glow intensity.
  14122. */
  14123. /**
  14124. * Gets the glow intensity.
  14125. */
  14126. intensity: number;
  14127. private _options;
  14128. private _intensity;
  14129. private _horizontalBlurPostprocess1;
  14130. private _verticalBlurPostprocess1;
  14131. private _horizontalBlurPostprocess2;
  14132. private _verticalBlurPostprocess2;
  14133. private _blurTexture1;
  14134. private _blurTexture2;
  14135. private _postProcesses1;
  14136. private _postProcesses2;
  14137. private _includedOnlyMeshes;
  14138. private _excludedMeshes;
  14139. /**
  14140. * Callback used to let the user override the color selection on a per mesh basis
  14141. */
  14142. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14143. /**
  14144. * Callback used to let the user override the texture selection on a per mesh basis
  14145. */
  14146. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14147. /**
  14148. * Instantiates a new glow Layer and references it to the scene.
  14149. * @param name The name of the layer
  14150. * @param scene The scene to use the layer in
  14151. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14152. */
  14153. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14154. /**
  14155. * Get the effect name of the layer.
  14156. * @return The effect name
  14157. */
  14158. getEffectName(): string;
  14159. /**
  14160. * Create the merge effect. This is the shader use to blit the information back
  14161. * to the main canvas at the end of the scene rendering.
  14162. */
  14163. protected _createMergeEffect(): Effect;
  14164. /**
  14165. * Creates the render target textures and post processes used in the glow layer.
  14166. */
  14167. protected _createTextureAndPostProcesses(): void;
  14168. /**
  14169. * Checks for the readiness of the element composing the layer.
  14170. * @param subMesh the mesh to check for
  14171. * @param useInstances specify wether or not to use instances to render the mesh
  14172. * @param emissiveTexture the associated emissive texture used to generate the glow
  14173. * @return true if ready otherwise, false
  14174. */
  14175. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14176. /**
  14177. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14178. */
  14179. needStencil(): boolean;
  14180. /**
  14181. * Implementation specific of rendering the generating effect on the main canvas.
  14182. * @param effect The effect used to render through
  14183. */
  14184. protected _internalRender(effect: Effect): void;
  14185. /**
  14186. * Sets the required values for both the emissive texture and and the main color.
  14187. */
  14188. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14189. /**
  14190. * Returns true if the mesh should render, otherwise false.
  14191. * @param mesh The mesh to render
  14192. * @returns true if it should render otherwise false
  14193. */
  14194. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14195. /**
  14196. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14197. * @param mesh The mesh to exclude from the glow layer
  14198. */
  14199. addExcludedMesh(mesh: Mesh): void;
  14200. /**
  14201. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14202. * @param mesh The mesh to remove
  14203. */
  14204. removeExcludedMesh(mesh: Mesh): void;
  14205. /**
  14206. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14207. * @param mesh The mesh to include in the glow layer
  14208. */
  14209. addIncludedOnlyMesh(mesh: Mesh): void;
  14210. /**
  14211. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14212. * @param mesh The mesh to remove
  14213. */
  14214. removeIncludedOnlyMesh(mesh: Mesh): void;
  14215. /**
  14216. * Determine if a given mesh will be used in the glow layer
  14217. * @param mesh The mesh to test
  14218. * @returns true if the mesh will be highlighted by the current glow layer
  14219. */
  14220. hasMesh(mesh: AbstractMesh): boolean;
  14221. /**
  14222. * Free any resources and references associated to a mesh.
  14223. * Internal use
  14224. * @param mesh The mesh to free.
  14225. * @hidden
  14226. */
  14227. _disposeMesh(mesh: Mesh): void;
  14228. /**
  14229. * Gets the class name of the effect layer
  14230. * @returns the string with the class name of the effect layer
  14231. */
  14232. getClassName(): string;
  14233. /**
  14234. * Serializes this glow layer
  14235. * @returns a serialized glow layer object
  14236. */
  14237. serialize(): any;
  14238. /**
  14239. * Creates a Glow Layer from parsed glow layer data
  14240. * @param parsedGlowLayer defines glow layer data
  14241. * @param scene defines the current scene
  14242. * @param rootUrl defines the root URL containing the glow layer information
  14243. * @returns a parsed Glow Layer
  14244. */
  14245. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14246. }
  14247. }
  14248. declare module BABYLON {
  14249. interface AbstractScene {
  14250. /**
  14251. * Return a the first highlight layer of the scene with a given name.
  14252. * @param name The name of the highlight layer to look for.
  14253. * @return The highlight layer if found otherwise null.
  14254. */
  14255. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14256. }
  14257. /**
  14258. * Highlight layer options. This helps customizing the behaviour
  14259. * of the highlight layer.
  14260. */
  14261. interface IHighlightLayerOptions {
  14262. /**
  14263. * Multiplication factor apply to the canvas size to compute the render target size
  14264. * used to generated the glowing objects (the smaller the faster).
  14265. */
  14266. mainTextureRatio: number;
  14267. /**
  14268. * Enforces a fixed size texture to ensure resize independant blur.
  14269. */
  14270. mainTextureFixedSize?: number;
  14271. /**
  14272. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14273. * of the picture to blur (the smaller the faster).
  14274. */
  14275. blurTextureSizeRatio: number;
  14276. /**
  14277. * How big in texel of the blur texture is the vertical blur.
  14278. */
  14279. blurVerticalSize: number;
  14280. /**
  14281. * How big in texel of the blur texture is the horizontal blur.
  14282. */
  14283. blurHorizontalSize: number;
  14284. /**
  14285. * Alpha blending mode used to apply the blur. Default is combine.
  14286. */
  14287. alphaBlendingMode: number;
  14288. /**
  14289. * The camera attached to the layer.
  14290. */
  14291. camera: Nullable<Camera>;
  14292. /**
  14293. * Should we display highlight as a solid stroke?
  14294. */
  14295. isStroke?: boolean;
  14296. /**
  14297. * The rendering group to draw the layer in.
  14298. */
  14299. renderingGroupId: number;
  14300. }
  14301. /**
  14302. * The highlight layer Helps adding a glow effect around a mesh.
  14303. *
  14304. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14305. * glowy meshes to your scene.
  14306. *
  14307. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14308. */
  14309. class HighlightLayer extends EffectLayer {
  14310. name: string;
  14311. /**
  14312. * Effect Name of the highlight layer.
  14313. */
  14314. static readonly EffectName: string;
  14315. /**
  14316. * The neutral color used during the preparation of the glow effect.
  14317. * This is black by default as the blend operation is a blend operation.
  14318. */
  14319. static NeutralColor: Color4;
  14320. /**
  14321. * Stencil value used for glowing meshes.
  14322. */
  14323. static GlowingMeshStencilReference: number;
  14324. /**
  14325. * Stencil value used for the other meshes in the scene.
  14326. */
  14327. static NormalMeshStencilReference: number;
  14328. /**
  14329. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14330. */
  14331. innerGlow: boolean;
  14332. /**
  14333. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14334. */
  14335. outerGlow: boolean;
  14336. /**
  14337. * Specifies the horizontal size of the blur.
  14338. */
  14339. /**
  14340. * Gets the horizontal size of the blur.
  14341. */
  14342. blurHorizontalSize: number;
  14343. /**
  14344. * Specifies the vertical size of the blur.
  14345. */
  14346. /**
  14347. * Gets the vertical size of the blur.
  14348. */
  14349. blurVerticalSize: number;
  14350. /**
  14351. * An event triggered when the highlight layer is being blurred.
  14352. */
  14353. onBeforeBlurObservable: Observable<HighlightLayer>;
  14354. /**
  14355. * An event triggered when the highlight layer has been blurred.
  14356. */
  14357. onAfterBlurObservable: Observable<HighlightLayer>;
  14358. private _instanceGlowingMeshStencilReference;
  14359. private _options;
  14360. private _downSamplePostprocess;
  14361. private _horizontalBlurPostprocess;
  14362. private _verticalBlurPostprocess;
  14363. private _blurTexture;
  14364. private _meshes;
  14365. private _excludedMeshes;
  14366. /**
  14367. * Instantiates a new highlight Layer and references it to the scene..
  14368. * @param name The name of the layer
  14369. * @param scene The scene to use the layer in
  14370. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14371. */
  14372. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14373. /**
  14374. * Get the effect name of the layer.
  14375. * @return The effect name
  14376. */
  14377. getEffectName(): string;
  14378. /**
  14379. * Create the merge effect. This is the shader use to blit the information back
  14380. * to the main canvas at the end of the scene rendering.
  14381. */
  14382. protected _createMergeEffect(): Effect;
  14383. /**
  14384. * Creates the render target textures and post processes used in the highlight layer.
  14385. */
  14386. protected _createTextureAndPostProcesses(): void;
  14387. /**
  14388. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14389. */
  14390. needStencil(): boolean;
  14391. /**
  14392. * Checks for the readiness of the element composing the layer.
  14393. * @param subMesh the mesh to check for
  14394. * @param useInstances specify wether or not to use instances to render the mesh
  14395. * @param emissiveTexture the associated emissive texture used to generate the glow
  14396. * @return true if ready otherwise, false
  14397. */
  14398. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14399. /**
  14400. * Implementation specific of rendering the generating effect on the main canvas.
  14401. * @param effect The effect used to render through
  14402. */
  14403. protected _internalRender(effect: Effect): void;
  14404. /**
  14405. * Returns true if the layer contains information to display, otherwise false.
  14406. */
  14407. shouldRender(): boolean;
  14408. /**
  14409. * Returns true if the mesh should render, otherwise false.
  14410. * @param mesh The mesh to render
  14411. * @returns true if it should render otherwise false
  14412. */
  14413. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14414. /**
  14415. * Sets the required values for both the emissive texture and and the main color.
  14416. */
  14417. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14418. /**
  14419. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14420. * @param mesh The mesh to exclude from the highlight layer
  14421. */
  14422. addExcludedMesh(mesh: Mesh): void;
  14423. /**
  14424. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14425. * @param mesh The mesh to highlight
  14426. */
  14427. removeExcludedMesh(mesh: Mesh): void;
  14428. /**
  14429. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14430. * @param mesh mesh to test
  14431. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14432. */
  14433. hasMesh(mesh: AbstractMesh): boolean;
  14434. /**
  14435. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14436. * @param mesh The mesh to highlight
  14437. * @param color The color of the highlight
  14438. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14439. */
  14440. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14441. /**
  14442. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14443. * @param mesh The mesh to highlight
  14444. */
  14445. removeMesh(mesh: Mesh): void;
  14446. /**
  14447. * Force the stencil to the normal expected value for none glowing parts
  14448. */
  14449. private _defaultStencilReference;
  14450. /**
  14451. * Free any resources and references associated to a mesh.
  14452. * Internal use
  14453. * @param mesh The mesh to free.
  14454. * @hidden
  14455. */
  14456. _disposeMesh(mesh: Mesh): void;
  14457. /**
  14458. * Dispose the highlight layer and free resources.
  14459. */
  14460. dispose(): void;
  14461. /**
  14462. * Gets the class name of the effect layer
  14463. * @returns the string with the class name of the effect layer
  14464. */
  14465. getClassName(): string;
  14466. /**
  14467. * Serializes this Highlight layer
  14468. * @returns a serialized Highlight layer object
  14469. */
  14470. serialize(): any;
  14471. /**
  14472. * Creates a Highlight layer from parsed Highlight layer data
  14473. * @param parsedHightlightLayer defines the Highlight layer data
  14474. * @param scene defines the current scene
  14475. * @param rootUrl defines the root URL containing the Highlight layer information
  14476. * @returns a parsed Highlight layer
  14477. */
  14478. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14479. }
  14480. }
  14481. declare module BABYLON {
  14482. /**
  14483. * This represents a full screen 2d layer.
  14484. * This can be usefull to display a picture in the background of your scene for instance.
  14485. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14486. */
  14487. class Layer {
  14488. /**
  14489. * Define the name of the layer.
  14490. */
  14491. name: string;
  14492. /**
  14493. * Define the texture the layer should display.
  14494. */
  14495. texture: Nullable<Texture>;
  14496. /**
  14497. * Is the layer in background or foreground.
  14498. */
  14499. isBackground: boolean;
  14500. /**
  14501. * Define the color of the layer (instead of texture).
  14502. */
  14503. color: Color4;
  14504. /**
  14505. * Define the scale of the layer in order to zoom in out of the texture.
  14506. */
  14507. scale: Vector2;
  14508. /**
  14509. * Define an offset for the layer in order to shift the texture.
  14510. */
  14511. offset: Vector2;
  14512. /**
  14513. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14514. */
  14515. alphaBlendingMode: number;
  14516. /**
  14517. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14518. * Alpha test will not mix with the background color in case of transparency.
  14519. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14520. */
  14521. alphaTest: boolean;
  14522. /**
  14523. * Define a mask to restrict the layer to only some of the scene cameras.
  14524. */
  14525. layerMask: number;
  14526. private _scene;
  14527. private _vertexBuffers;
  14528. private _indexBuffer;
  14529. private _effect;
  14530. private _alphaTestEffect;
  14531. /**
  14532. * An event triggered when the layer is disposed.
  14533. */
  14534. onDisposeObservable: Observable<Layer>;
  14535. private _onDisposeObserver;
  14536. /**
  14537. * Back compatibility with callback before the onDisposeObservable existed.
  14538. * The set callback will be triggered when the layer has been disposed.
  14539. */
  14540. onDispose: () => void;
  14541. /**
  14542. * An event triggered before rendering the scene
  14543. */
  14544. onBeforeRenderObservable: Observable<Layer>;
  14545. private _onBeforeRenderObserver;
  14546. /**
  14547. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14548. * The set callback will be triggered just before rendering the layer.
  14549. */
  14550. onBeforeRender: () => void;
  14551. /**
  14552. * An event triggered after rendering the scene
  14553. */
  14554. onAfterRenderObservable: Observable<Layer>;
  14555. private _onAfterRenderObserver;
  14556. /**
  14557. * Back compatibility with callback before the onAfterRenderObservable existed.
  14558. * The set callback will be triggered just after rendering the layer.
  14559. */
  14560. onAfterRender: () => void;
  14561. /**
  14562. * Instantiates a new layer.
  14563. * This represents a full screen 2d layer.
  14564. * This can be usefull to display a picture in the background of your scene for instance.
  14565. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14566. * @param name Define the name of the layer in the scene
  14567. * @param imgUrl Define the url of the texture to display in the layer
  14568. * @param scene Define the scene the layer belongs to
  14569. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14570. * @param color Defines a color for the layer
  14571. */
  14572. constructor(
  14573. /**
  14574. * Define the name of the layer.
  14575. */
  14576. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14577. private _createIndexBuffer;
  14578. /** @hidden */
  14579. _rebuild(): void;
  14580. /**
  14581. * Renders the layer in the scene.
  14582. */
  14583. render(): void;
  14584. /**
  14585. * Disposes and releases the associated ressources.
  14586. */
  14587. dispose(): void;
  14588. }
  14589. }
  14590. declare module BABYLON {
  14591. interface AbstractScene {
  14592. /**
  14593. * The list of layers (background and foreground) of the scene
  14594. */
  14595. layers: Array<Layer>;
  14596. }
  14597. /**
  14598. * Defines the layer scene component responsible to manage any layers
  14599. * in a given scene.
  14600. */
  14601. class LayerSceneComponent implements ISceneComponent {
  14602. /**
  14603. * The component name helpfull to identify the component in the list of scene components.
  14604. */
  14605. readonly name: string;
  14606. /**
  14607. * The scene the component belongs to.
  14608. */
  14609. scene: Scene;
  14610. private _engine;
  14611. /**
  14612. * Creates a new instance of the component for the given scene
  14613. * @param scene Defines the scene to register the component in
  14614. */
  14615. constructor(scene: Scene);
  14616. /**
  14617. * Registers the component in a given scene
  14618. */
  14619. register(): void;
  14620. /**
  14621. * Rebuilds the elements related to this component in case of
  14622. * context lost for instance.
  14623. */
  14624. rebuild(): void;
  14625. /**
  14626. * Disposes the component and the associated ressources.
  14627. */
  14628. dispose(): void;
  14629. private _draw;
  14630. private _drawBackground;
  14631. private _drawForeground;
  14632. }
  14633. }
  14634. declare module BABYLON {
  14635. /**
  14636. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14637. * It controls one of the indiviual texture used in the effect.
  14638. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14639. */
  14640. class LensFlare {
  14641. /**
  14642. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14643. */
  14644. size: number;
  14645. /**
  14646. * 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.
  14647. */
  14648. position: number;
  14649. /**
  14650. * Define the lens color.
  14651. */
  14652. color: Color3;
  14653. /**
  14654. * Define the lens texture.
  14655. */
  14656. texture: Nullable<Texture>;
  14657. /**
  14658. * Define the alpha mode to render this particular lens.
  14659. */
  14660. alphaMode: number;
  14661. private _system;
  14662. /**
  14663. * Creates a new Lens Flare.
  14664. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14665. * It controls one of the indiviual texture used in the effect.
  14666. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14667. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  14668. * @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.
  14669. * @param color Define the lens color
  14670. * @param imgUrl Define the lens texture url
  14671. * @param system Define the `lensFlareSystem` this flare is part of
  14672. * @returns The newly created Lens Flare
  14673. */
  14674. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  14675. /**
  14676. * Instantiates a new Lens Flare.
  14677. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14678. * It controls one of the indiviual texture used in the effect.
  14679. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14680. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  14681. * @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.
  14682. * @param color Define the lens color
  14683. * @param imgUrl Define the lens texture url
  14684. * @param system Define the `lensFlareSystem` this flare is part of
  14685. */
  14686. constructor(
  14687. /**
  14688. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14689. */
  14690. size: number,
  14691. /**
  14692. * 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.
  14693. */
  14694. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  14695. /**
  14696. * Dispose and release the lens flare with its associated resources.
  14697. */
  14698. dispose(): void;
  14699. }
  14700. }
  14701. declare module BABYLON {
  14702. /**
  14703. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14704. * It is usually composed of several `BABYLON.lensFlare`.
  14705. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14706. */
  14707. class LensFlareSystem {
  14708. /**
  14709. * Define the name of the lens flare system
  14710. */
  14711. name: string;
  14712. /**
  14713. * List of lens flares used in this system.
  14714. */
  14715. lensFlares: LensFlare[];
  14716. /**
  14717. * Define a limit from the border the lens flare can be visible.
  14718. */
  14719. borderLimit: number;
  14720. /**
  14721. * Define a viewport border we do not want to see the lens flare in.
  14722. */
  14723. viewportBorder: number;
  14724. /**
  14725. * Define a predicate which could limit the list of meshes able to occlude the effect.
  14726. */
  14727. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  14728. /**
  14729. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  14730. */
  14731. layerMask: number;
  14732. /**
  14733. * Define the id of the lens flare system in the scene.
  14734. * (equal to name by default)
  14735. */
  14736. id: string;
  14737. private _scene;
  14738. private _emitter;
  14739. private _vertexBuffers;
  14740. private _indexBuffer;
  14741. private _effect;
  14742. private _positionX;
  14743. private _positionY;
  14744. private _isEnabled;
  14745. /**
  14746. * Instantiates a lens flare system.
  14747. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14748. * It is usually composed of several `BABYLON.lensFlare`.
  14749. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14750. * @param name Define the name of the lens flare system in the scene
  14751. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  14752. * @param scene Define the scene the lens flare system belongs to
  14753. */
  14754. constructor(
  14755. /**
  14756. * Define the name of the lens flare system
  14757. */
  14758. name: string, emitter: any, scene: Scene);
  14759. /**
  14760. * Define if the lens flare system is enabled.
  14761. */
  14762. isEnabled: boolean;
  14763. /**
  14764. * Get the scene the effects belongs to.
  14765. * @returns the scene holding the lens flare system
  14766. */
  14767. getScene(): Scene;
  14768. /**
  14769. * Get the emitter of the lens flare system.
  14770. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14771. * @returns the emitter of the lens flare system
  14772. */
  14773. getEmitter(): any;
  14774. /**
  14775. * Set the emitter of the lens flare system.
  14776. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14777. * @param newEmitter Define the new emitter of the system
  14778. */
  14779. setEmitter(newEmitter: any): void;
  14780. /**
  14781. * Get the lens flare system emitter position.
  14782. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  14783. * @returns the position
  14784. */
  14785. getEmitterPosition(): Vector3;
  14786. /**
  14787. * @hidden
  14788. */
  14789. computeEffectivePosition(globalViewport: Viewport): boolean;
  14790. /** @hidden */
  14791. _isVisible(): boolean;
  14792. /**
  14793. * @hidden
  14794. */
  14795. render(): boolean;
  14796. /**
  14797. * Dispose and release the lens flare with its associated resources.
  14798. */
  14799. dispose(): void;
  14800. /**
  14801. * Parse a lens flare system from a JSON repressentation
  14802. * @param parsedLensFlareSystem Define the JSON to parse
  14803. * @param scene Define the scene the parsed system should be instantiated in
  14804. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  14805. * @returns the parsed system
  14806. */
  14807. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  14808. /**
  14809. * Serialize the current Lens Flare System into a JSON representation.
  14810. * @returns the serialized JSON
  14811. */
  14812. serialize(): any;
  14813. }
  14814. }
  14815. declare module BABYLON {
  14816. interface AbstractScene {
  14817. /**
  14818. * The list of lens flare system added to the scene
  14819. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14820. */
  14821. lensFlareSystems: Array<LensFlareSystem>;
  14822. /**
  14823. * Removes the given lens flare system from this scene.
  14824. * @param toRemove The lens flare system to remove
  14825. * @returns The index of the removed lens flare system
  14826. */
  14827. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  14828. /**
  14829. * Adds the given lens flare system to this scene
  14830. * @param newLensFlareSystem The lens flare system to add
  14831. */
  14832. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  14833. /**
  14834. * Gets a lens flare system using its name
  14835. * @param name defines the name to look for
  14836. * @returns the lens flare system or null if not found
  14837. */
  14838. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  14839. /**
  14840. * Gets a lens flare system using its id
  14841. * @param id defines the id to look for
  14842. * @returns the lens flare system or null if not found
  14843. */
  14844. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  14845. }
  14846. /**
  14847. * Defines the lens flare scene component responsible to manage any lens flares
  14848. * in a given scene.
  14849. */
  14850. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  14851. /**
  14852. * The component name helpfull to identify the component in the list of scene components.
  14853. */
  14854. readonly name: string;
  14855. /**
  14856. * The scene the component belongs to.
  14857. */
  14858. scene: Scene;
  14859. /**
  14860. * Creates a new instance of the component for the given scene
  14861. * @param scene Defines the scene to register the component in
  14862. */
  14863. constructor(scene: Scene);
  14864. /**
  14865. * Registers the component in a given scene
  14866. */
  14867. register(): void;
  14868. /**
  14869. * Rebuilds the elements related to this component in case of
  14870. * context lost for instance.
  14871. */
  14872. rebuild(): void;
  14873. /**
  14874. * Adds all the element from the container to the scene
  14875. * @param container the container holding the elements
  14876. */
  14877. addFromContainer(container: AbstractScene): void;
  14878. /**
  14879. * Removes all the elements in the container from the scene
  14880. * @param container contains the elements to remove
  14881. */
  14882. removeFromContainer(container: AbstractScene): void;
  14883. /**
  14884. * Serializes the component data to the specified json object
  14885. * @param serializationObject The object to serialize to
  14886. */
  14887. serialize(serializationObject: any): void;
  14888. /**
  14889. * Disposes the component and the associated ressources.
  14890. */
  14891. dispose(): void;
  14892. private _draw;
  14893. }
  14894. }
  14895. declare module BABYLON {
  14896. /**
  14897. * A directional light is defined by a direction (what a surprise!).
  14898. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  14899. * 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.
  14900. * Documentation: https://doc.babylonjs.com/babylon101/lights
  14901. */
  14902. class DirectionalLight extends ShadowLight {
  14903. private _shadowFrustumSize;
  14904. /**
  14905. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  14906. */
  14907. /**
  14908. * Specifies a fix frustum size for the shadow generation.
  14909. */
  14910. shadowFrustumSize: number;
  14911. private _shadowOrthoScale;
  14912. /**
  14913. * Gets the shadow projection scale against the optimal computed one.
  14914. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  14915. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  14916. */
  14917. /**
  14918. * Sets the shadow projection scale against the optimal computed one.
  14919. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  14920. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  14921. */
  14922. shadowOrthoScale: number;
  14923. /**
  14924. * Automatically compute the projection matrix to best fit (including all the casters)
  14925. * on each frame.
  14926. */
  14927. autoUpdateExtends: boolean;
  14928. private _orthoLeft;
  14929. private _orthoRight;
  14930. private _orthoTop;
  14931. private _orthoBottom;
  14932. /**
  14933. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  14934. * The directional light is emitted from everywhere in the given direction.
  14935. * It can cast shadows.
  14936. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14937. * @param name The friendly name of the light
  14938. * @param direction The direction of the light
  14939. * @param scene The scene the light belongs to
  14940. */
  14941. constructor(name: string, direction: Vector3, scene: Scene);
  14942. /**
  14943. * Returns the string "DirectionalLight".
  14944. * @return The class name
  14945. */
  14946. getClassName(): string;
  14947. /**
  14948. * Returns the integer 1.
  14949. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14950. */
  14951. getTypeID(): number;
  14952. /**
  14953. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  14954. * Returns the DirectionalLight Shadow projection matrix.
  14955. */
  14956. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14957. /**
  14958. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  14959. * Returns the DirectionalLight Shadow projection matrix.
  14960. */
  14961. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  14962. /**
  14963. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  14964. * Returns the DirectionalLight Shadow projection matrix.
  14965. */
  14966. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14967. protected _buildUniformLayout(): void;
  14968. /**
  14969. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  14970. * @param effect The effect to update
  14971. * @param lightIndex The index of the light in the effect to update
  14972. * @returns The directional light
  14973. */
  14974. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  14975. /**
  14976. * Gets the minZ used for shadow according to both the scene and the light.
  14977. *
  14978. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  14979. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  14980. * @param activeCamera The camera we are returning the min for
  14981. * @returns the depth min z
  14982. */
  14983. getDepthMinZ(activeCamera: Camera): number;
  14984. /**
  14985. * Gets the maxZ used for shadow according to both the scene and the light.
  14986. *
  14987. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  14988. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  14989. * @param activeCamera The camera we are returning the max for
  14990. * @returns the depth max z
  14991. */
  14992. getDepthMaxZ(activeCamera: Camera): number;
  14993. /**
  14994. * Prepares the list of defines specific to the light type.
  14995. * @param defines the list of defines
  14996. * @param lightIndex defines the index of the light for the effect
  14997. */
  14998. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14999. }
  15000. }
  15001. declare module BABYLON {
  15002. /**
  15003. * The HemisphericLight simulates the ambient environment light,
  15004. * so the passed direction is the light reflection direction, not the incoming direction.
  15005. */
  15006. class HemisphericLight extends Light {
  15007. /**
  15008. * The groundColor is the light in the opposite direction to the one specified during creation.
  15009. * 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.
  15010. */
  15011. groundColor: Color3;
  15012. /**
  15013. * The light reflection direction, not the incoming direction.
  15014. */
  15015. direction: Vector3;
  15016. /**
  15017. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15018. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15019. * The HemisphericLight can't cast shadows.
  15020. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15021. * @param name The friendly name of the light
  15022. * @param direction The direction of the light reflection
  15023. * @param scene The scene the light belongs to
  15024. */
  15025. constructor(name: string, direction: Vector3, scene: Scene);
  15026. protected _buildUniformLayout(): void;
  15027. /**
  15028. * Returns the string "HemisphericLight".
  15029. * @return The class name
  15030. */
  15031. getClassName(): string;
  15032. /**
  15033. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15034. * Returns the updated direction.
  15035. * @param target The target the direction should point to
  15036. * @return The computed direction
  15037. */
  15038. setDirectionToTarget(target: Vector3): Vector3;
  15039. /**
  15040. * Returns the shadow generator associated to the light.
  15041. * @returns Always null for hemispheric lights because it does not support shadows.
  15042. */
  15043. getShadowGenerator(): Nullable<IShadowGenerator>;
  15044. /**
  15045. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15046. * @param effect The effect to update
  15047. * @param lightIndex The index of the light in the effect to update
  15048. * @returns The hemispheric light
  15049. */
  15050. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15051. /**
  15052. * Computes the world matrix of the node
  15053. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15054. * @param useWasUpdatedFlag defines a reserved property
  15055. * @returns the world matrix
  15056. */
  15057. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15058. /**
  15059. * Returns the integer 3.
  15060. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15061. */
  15062. getTypeID(): number;
  15063. /**
  15064. * Prepares the list of defines specific to the light type.
  15065. * @param defines the list of defines
  15066. * @param lightIndex defines the index of the light for the effect
  15067. */
  15068. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15069. }
  15070. }
  15071. declare module BABYLON {
  15072. /**
  15073. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15074. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15075. * 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.
  15076. */
  15077. abstract class Light extends Node {
  15078. /**
  15079. * Falloff Default: light is falling off following the material specification:
  15080. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15081. */
  15082. static readonly FALLOFF_DEFAULT: number;
  15083. /**
  15084. * Falloff Physical: light is falling off following the inverse squared distance law.
  15085. */
  15086. static readonly FALLOFF_PHYSICAL: number;
  15087. /**
  15088. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15089. * to enhance interoperability with other engines.
  15090. */
  15091. static readonly FALLOFF_GLTF: number;
  15092. /**
  15093. * Falloff Standard: light is falling off like in the standard material
  15094. * to enhance interoperability with other materials.
  15095. */
  15096. static readonly FALLOFF_STANDARD: number;
  15097. /**
  15098. * If every light affecting the material is in this lightmapMode,
  15099. * material.lightmapTexture adds or multiplies
  15100. * (depends on material.useLightmapAsShadowmap)
  15101. * after every other light calculations.
  15102. */
  15103. static readonly LIGHTMAP_DEFAULT: number;
  15104. /**
  15105. * material.lightmapTexture as only diffuse lighting from this light
  15106. * adds only specular lighting from this light
  15107. * adds dynamic shadows
  15108. */
  15109. static readonly LIGHTMAP_SPECULAR: number;
  15110. /**
  15111. * material.lightmapTexture as only lighting
  15112. * no light calculation from this light
  15113. * only adds dynamic shadows from this light
  15114. */
  15115. static readonly LIGHTMAP_SHADOWSONLY: number;
  15116. /**
  15117. * Each light type uses the default quantity according to its type:
  15118. * point/spot lights use luminous intensity
  15119. * directional lights use illuminance
  15120. */
  15121. static readonly INTENSITYMODE_AUTOMATIC: number;
  15122. /**
  15123. * lumen (lm)
  15124. */
  15125. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15126. /**
  15127. * candela (lm/sr)
  15128. */
  15129. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15130. /**
  15131. * lux (lm/m^2)
  15132. */
  15133. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15134. /**
  15135. * nit (cd/m^2)
  15136. */
  15137. static readonly INTENSITYMODE_LUMINANCE: number;
  15138. /**
  15139. * Light type const id of the point light.
  15140. */
  15141. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15142. /**
  15143. * Light type const id of the directional light.
  15144. */
  15145. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15146. /**
  15147. * Light type const id of the spot light.
  15148. */
  15149. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15150. /**
  15151. * Light type const id of the hemispheric light.
  15152. */
  15153. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15154. /**
  15155. * Diffuse gives the basic color to an object.
  15156. */
  15157. diffuse: Color3;
  15158. /**
  15159. * Specular produces a highlight color on an object.
  15160. * Note: This is note affecting PBR materials.
  15161. */
  15162. specular: Color3;
  15163. /**
  15164. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15165. * falling off base on range or angle.
  15166. * This can be set to any values in Light.FALLOFF_x.
  15167. *
  15168. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15169. * other types of materials.
  15170. */
  15171. falloffType: number;
  15172. /**
  15173. * Strength of the light.
  15174. * Note: By default it is define in the framework own unit.
  15175. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15176. */
  15177. intensity: number;
  15178. private _range;
  15179. protected _inverseSquaredRange: number;
  15180. /**
  15181. * Defines how far from the source the light is impacting in scene units.
  15182. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15183. */
  15184. /**
  15185. * Defines how far from the source the light is impacting in scene units.
  15186. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15187. */
  15188. range: number;
  15189. /**
  15190. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15191. * of light.
  15192. */
  15193. private _photometricScale;
  15194. private _intensityMode;
  15195. /**
  15196. * Gets the photometric scale used to interpret the intensity.
  15197. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15198. */
  15199. /**
  15200. * Sets the photometric scale used to interpret the intensity.
  15201. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15202. */
  15203. intensityMode: number;
  15204. private _radius;
  15205. /**
  15206. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15207. */
  15208. /**
  15209. * sets the light radius used by PBR Materials to simulate soft area lights.
  15210. */
  15211. radius: number;
  15212. private _renderPriority;
  15213. /**
  15214. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15215. * exceeding the number allowed of the materials.
  15216. */
  15217. renderPriority: number;
  15218. private _shadowEnabled;
  15219. /**
  15220. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15221. * the current shadow generator.
  15222. */
  15223. /**
  15224. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15225. * the current shadow generator.
  15226. */
  15227. shadowEnabled: boolean;
  15228. private _includedOnlyMeshes;
  15229. /**
  15230. * Gets the only meshes impacted by this light.
  15231. */
  15232. /**
  15233. * Sets the only meshes impacted by this light.
  15234. */
  15235. includedOnlyMeshes: AbstractMesh[];
  15236. private _excludedMeshes;
  15237. /**
  15238. * Gets the meshes not impacted by this light.
  15239. */
  15240. /**
  15241. * Sets the meshes not impacted by this light.
  15242. */
  15243. excludedMeshes: AbstractMesh[];
  15244. private _excludeWithLayerMask;
  15245. /**
  15246. * Gets the layer id use to find what meshes are not impacted by the light.
  15247. * Inactive if 0
  15248. */
  15249. /**
  15250. * Sets the layer id use to find what meshes are not impacted by the light.
  15251. * Inactive if 0
  15252. */
  15253. excludeWithLayerMask: number;
  15254. private _includeOnlyWithLayerMask;
  15255. /**
  15256. * Gets the layer id use to find what meshes are impacted by the light.
  15257. * Inactive if 0
  15258. */
  15259. /**
  15260. * Sets the layer id use to find what meshes are impacted by the light.
  15261. * Inactive if 0
  15262. */
  15263. includeOnlyWithLayerMask: number;
  15264. private _lightmapMode;
  15265. /**
  15266. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15267. */
  15268. /**
  15269. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15270. */
  15271. lightmapMode: number;
  15272. /**
  15273. * Shadow generator associted to the light.
  15274. * @hidden Internal use only.
  15275. */
  15276. _shadowGenerator: Nullable<IShadowGenerator>;
  15277. /**
  15278. * @hidden Internal use only.
  15279. */
  15280. _excludedMeshesIds: string[];
  15281. /**
  15282. * @hidden Internal use only.
  15283. */
  15284. _includedOnlyMeshesIds: string[];
  15285. /**
  15286. * The current light unifom buffer.
  15287. * @hidden Internal use only.
  15288. */
  15289. _uniformBuffer: UniformBuffer;
  15290. /**
  15291. * Creates a Light object in the scene.
  15292. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15293. * @param name The firendly name of the light
  15294. * @param scene The scene the light belongs too
  15295. */
  15296. constructor(name: string, scene: Scene);
  15297. protected abstract _buildUniformLayout(): void;
  15298. /**
  15299. * Sets the passed Effect "effect" with the Light information.
  15300. * @param effect The effect to update
  15301. * @param lightIndex The index of the light in the effect to update
  15302. * @returns The light
  15303. */
  15304. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15305. /**
  15306. * Returns the string "Light".
  15307. * @returns the class name
  15308. */
  15309. getClassName(): string;
  15310. /**
  15311. * Converts the light information to a readable string for debug purpose.
  15312. * @param fullDetails Supports for multiple levels of logging within scene loading
  15313. * @returns the human readable light info
  15314. */
  15315. toString(fullDetails?: boolean): string;
  15316. /** @hidden */
  15317. protected _syncParentEnabledState(): void;
  15318. /**
  15319. * Set the enabled state of this node.
  15320. * @param value - the new enabled state
  15321. */
  15322. setEnabled(value: boolean): void;
  15323. /**
  15324. * Returns the Light associated shadow generator if any.
  15325. * @return the associated shadow generator.
  15326. */
  15327. getShadowGenerator(): Nullable<IShadowGenerator>;
  15328. /**
  15329. * Returns a Vector3, the absolute light position in the World.
  15330. * @returns the world space position of the light
  15331. */
  15332. getAbsolutePosition(): Vector3;
  15333. /**
  15334. * Specifies if the light will affect the passed mesh.
  15335. * @param mesh The mesh to test against the light
  15336. * @return true the mesh is affected otherwise, false.
  15337. */
  15338. canAffectMesh(mesh: AbstractMesh): boolean;
  15339. /**
  15340. * Sort function to order lights for rendering.
  15341. * @param a First Light object to compare to second.
  15342. * @param b Second Light object to compare first.
  15343. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15344. */
  15345. static CompareLightsPriority(a: Light, b: Light): number;
  15346. /**
  15347. * Releases resources associated with this node.
  15348. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15349. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15350. */
  15351. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15352. /**
  15353. * Returns the light type ID (integer).
  15354. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15355. */
  15356. getTypeID(): number;
  15357. /**
  15358. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15359. * @returns the scaled intensity in intensity mode unit
  15360. */
  15361. getScaledIntensity(): number;
  15362. /**
  15363. * Returns a new Light object, named "name", from the current one.
  15364. * @param name The name of the cloned light
  15365. * @returns the new created light
  15366. */
  15367. clone(name: string): Nullable<Light>;
  15368. /**
  15369. * Serializes the current light into a Serialization object.
  15370. * @returns the serialized object.
  15371. */
  15372. serialize(): any;
  15373. /**
  15374. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15375. * This new light is named "name" and added to the passed scene.
  15376. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15377. * @param name The friendly name of the light
  15378. * @param scene The scene the new light will belong to
  15379. * @returns the constructor function
  15380. */
  15381. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15382. /**
  15383. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15384. * @param parsedLight The JSON representation of the light
  15385. * @param scene The scene to create the parsed light in
  15386. * @returns the created light after parsing
  15387. */
  15388. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15389. private _hookArrayForExcluded;
  15390. private _hookArrayForIncludedOnly;
  15391. private _resyncMeshes;
  15392. /**
  15393. * Forces the meshes to update their light related information in their rendering used effects
  15394. * @hidden Internal Use Only
  15395. */
  15396. _markMeshesAsLightDirty(): void;
  15397. /**
  15398. * Recomputes the cached photometric scale if needed.
  15399. */
  15400. private _computePhotometricScale;
  15401. /**
  15402. * Returns the Photometric Scale according to the light type and intensity mode.
  15403. */
  15404. private _getPhotometricScale;
  15405. /**
  15406. * Reorder the light in the scene according to their defined priority.
  15407. * @hidden Internal Use Only
  15408. */
  15409. _reorderLightsInScene(): void;
  15410. /**
  15411. * Prepares the list of defines specific to the light type.
  15412. * @param defines the list of defines
  15413. * @param lightIndex defines the index of the light for the effect
  15414. */
  15415. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15416. }
  15417. }
  15418. declare module BABYLON {
  15419. /**
  15420. * A point light is a light defined by an unique point in world space.
  15421. * The light is emitted in every direction from this point.
  15422. * A good example of a point light is a standard light bulb.
  15423. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15424. */
  15425. class PointLight extends ShadowLight {
  15426. private _shadowAngle;
  15427. /**
  15428. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15429. * This specifies what angle the shadow will use to be created.
  15430. *
  15431. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15432. */
  15433. /**
  15434. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15435. * This specifies what angle the shadow will use to be created.
  15436. *
  15437. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15438. */
  15439. shadowAngle: number;
  15440. /**
  15441. * Gets the direction if it has been set.
  15442. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15443. */
  15444. /**
  15445. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15446. */
  15447. direction: Vector3;
  15448. /**
  15449. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15450. * A PointLight emits the light in every direction.
  15451. * It can cast shadows.
  15452. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15453. * ```javascript
  15454. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15455. * ```
  15456. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15457. * @param name The light friendly name
  15458. * @param position The position of the point light in the scene
  15459. * @param scene The scene the lights belongs to
  15460. */
  15461. constructor(name: string, position: Vector3, scene: Scene);
  15462. /**
  15463. * Returns the string "PointLight"
  15464. * @returns the class name
  15465. */
  15466. getClassName(): string;
  15467. /**
  15468. * Returns the integer 0.
  15469. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15470. */
  15471. getTypeID(): number;
  15472. /**
  15473. * Specifies wether or not the shadowmap should be a cube texture.
  15474. * @returns true if the shadowmap needs to be a cube texture.
  15475. */
  15476. needCube(): boolean;
  15477. /**
  15478. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15479. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15480. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15481. */
  15482. getShadowDirection(faceIndex?: number): Vector3;
  15483. /**
  15484. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15485. * - fov = PI / 2
  15486. * - aspect ratio : 1.0
  15487. * - z-near and far equal to the active camera minZ and maxZ.
  15488. * Returns the PointLight.
  15489. */
  15490. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15491. protected _buildUniformLayout(): void;
  15492. /**
  15493. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15494. * @param effect The effect to update
  15495. * @param lightIndex The index of the light in the effect to update
  15496. * @returns The point light
  15497. */
  15498. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15499. /**
  15500. * Prepares the list of defines specific to the light type.
  15501. * @param defines the list of defines
  15502. * @param lightIndex defines the index of the light for the effect
  15503. */
  15504. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15505. }
  15506. }
  15507. declare module BABYLON {
  15508. /**
  15509. * Interface describing all the common properties and methods a shadow light needs to implement.
  15510. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15511. * as well as binding the different shadow properties to the effects.
  15512. */
  15513. interface IShadowLight extends Light {
  15514. /**
  15515. * The light id in the scene (used in scene.findLighById for instance)
  15516. */
  15517. id: string;
  15518. /**
  15519. * The position the shdow will be casted from.
  15520. */
  15521. position: Vector3;
  15522. /**
  15523. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15524. */
  15525. direction: Vector3;
  15526. /**
  15527. * The transformed position. Position of the light in world space taking parenting in account.
  15528. */
  15529. transformedPosition: Vector3;
  15530. /**
  15531. * The transformed direction. Direction of the light in world space taking parenting in account.
  15532. */
  15533. transformedDirection: Vector3;
  15534. /**
  15535. * The friendly name of the light in the scene.
  15536. */
  15537. name: string;
  15538. /**
  15539. * Defines the shadow projection clipping minimum z value.
  15540. */
  15541. shadowMinZ: number;
  15542. /**
  15543. * Defines the shadow projection clipping maximum z value.
  15544. */
  15545. shadowMaxZ: number;
  15546. /**
  15547. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15548. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15549. */
  15550. computeTransformedInformation(): boolean;
  15551. /**
  15552. * Gets the scene the light belongs to.
  15553. * @returns The scene
  15554. */
  15555. getScene(): Scene;
  15556. /**
  15557. * Callback defining a custom Projection Matrix Builder.
  15558. * This can be used to override the default projection matrix computation.
  15559. */
  15560. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15561. /**
  15562. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15563. * @param matrix The materix to updated with the projection information
  15564. * @param viewMatrix The transform matrix of the light
  15565. * @param renderList The list of mesh to render in the map
  15566. * @returns The current light
  15567. */
  15568. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15569. /**
  15570. * Gets the current depth scale used in ESM.
  15571. * @returns The scale
  15572. */
  15573. getDepthScale(): number;
  15574. /**
  15575. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15576. * @returns true if a cube texture needs to be use
  15577. */
  15578. needCube(): boolean;
  15579. /**
  15580. * Detects if the projection matrix requires to be recomputed this frame.
  15581. * @returns true if it requires to be recomputed otherwise, false.
  15582. */
  15583. needProjectionMatrixCompute(): boolean;
  15584. /**
  15585. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15586. */
  15587. forceProjectionMatrixCompute(): void;
  15588. /**
  15589. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15590. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15591. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15592. */
  15593. getShadowDirection(faceIndex?: number): Vector3;
  15594. /**
  15595. * Gets the minZ used for shadow according to both the scene and the light.
  15596. * @param activeCamera The camera we are returning the min for
  15597. * @returns the depth min z
  15598. */
  15599. getDepthMinZ(activeCamera: Camera): number;
  15600. /**
  15601. * Gets the maxZ used for shadow according to both the scene and the light.
  15602. * @param activeCamera The camera we are returning the max for
  15603. * @returns the depth max z
  15604. */
  15605. getDepthMaxZ(activeCamera: Camera): number;
  15606. }
  15607. /**
  15608. * Base implementation IShadowLight
  15609. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15610. */
  15611. abstract class ShadowLight extends Light implements IShadowLight {
  15612. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15613. protected _position: Vector3;
  15614. protected _setPosition(value: Vector3): void;
  15615. /**
  15616. * Sets the position the shadow will be casted from. Also use as the light position for both
  15617. * point and spot lights.
  15618. */
  15619. /**
  15620. * Sets the position the shadow will be casted from. Also use as the light position for both
  15621. * point and spot lights.
  15622. */
  15623. position: Vector3;
  15624. protected _direction: Vector3;
  15625. protected _setDirection(value: Vector3): void;
  15626. /**
  15627. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  15628. * Also use as the light direction on spot and directional lights.
  15629. */
  15630. /**
  15631. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  15632. * Also use as the light direction on spot and directional lights.
  15633. */
  15634. direction: Vector3;
  15635. private _shadowMinZ;
  15636. /**
  15637. * Gets the shadow projection clipping minimum z value.
  15638. */
  15639. /**
  15640. * Sets the shadow projection clipping minimum z value.
  15641. */
  15642. shadowMinZ: number;
  15643. private _shadowMaxZ;
  15644. /**
  15645. * Sets the shadow projection clipping maximum z value.
  15646. */
  15647. /**
  15648. * Gets the shadow projection clipping maximum z value.
  15649. */
  15650. shadowMaxZ: number;
  15651. /**
  15652. * Callback defining a custom Projection Matrix Builder.
  15653. * This can be used to override the default projection matrix computation.
  15654. */
  15655. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15656. /**
  15657. * The transformed position. Position of the light in world space taking parenting in account.
  15658. */
  15659. transformedPosition: Vector3;
  15660. /**
  15661. * The transformed direction. Direction of the light in world space taking parenting in account.
  15662. */
  15663. transformedDirection: Vector3;
  15664. private _needProjectionMatrixCompute;
  15665. /**
  15666. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15667. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15668. */
  15669. computeTransformedInformation(): boolean;
  15670. /**
  15671. * Return the depth scale used for the shadow map.
  15672. * @returns the depth scale.
  15673. */
  15674. getDepthScale(): number;
  15675. /**
  15676. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15677. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15678. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15679. */
  15680. getShadowDirection(faceIndex?: number): Vector3;
  15681. /**
  15682. * Returns the ShadowLight absolute position in the World.
  15683. * @returns the position vector in world space
  15684. */
  15685. getAbsolutePosition(): Vector3;
  15686. /**
  15687. * Sets the ShadowLight direction toward the passed target.
  15688. * @param target The point tot target in local space
  15689. * @returns the updated ShadowLight direction
  15690. */
  15691. setDirectionToTarget(target: Vector3): Vector3;
  15692. /**
  15693. * Returns the light rotation in euler definition.
  15694. * @returns the x y z rotation in local space.
  15695. */
  15696. getRotation(): Vector3;
  15697. /**
  15698. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15699. * @returns true if a cube texture needs to be use
  15700. */
  15701. needCube(): boolean;
  15702. /**
  15703. * Detects if the projection matrix requires to be recomputed this frame.
  15704. * @returns true if it requires to be recomputed otherwise, false.
  15705. */
  15706. needProjectionMatrixCompute(): boolean;
  15707. /**
  15708. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15709. */
  15710. forceProjectionMatrixCompute(): void;
  15711. /** @hidden */
  15712. _initCache(): void;
  15713. /** @hidden */
  15714. _isSynchronized(): boolean;
  15715. /**
  15716. * Computes the world matrix of the node
  15717. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15718. * @returns the world matrix
  15719. */
  15720. computeWorldMatrix(force?: boolean): Matrix;
  15721. /**
  15722. * Gets the minZ used for shadow according to both the scene and the light.
  15723. * @param activeCamera The camera we are returning the min for
  15724. * @returns the depth min z
  15725. */
  15726. getDepthMinZ(activeCamera: Camera): number;
  15727. /**
  15728. * Gets the maxZ used for shadow according to both the scene and the light.
  15729. * @param activeCamera The camera we are returning the max for
  15730. * @returns the depth max z
  15731. */
  15732. getDepthMaxZ(activeCamera: Camera): number;
  15733. /**
  15734. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15735. * @param matrix The materix to updated with the projection information
  15736. * @param viewMatrix The transform matrix of the light
  15737. * @param renderList The list of mesh to render in the map
  15738. * @returns The current light
  15739. */
  15740. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15741. }
  15742. }
  15743. declare module BABYLON {
  15744. /**
  15745. * A spot light is defined by a position, a direction, an angle, and an exponent.
  15746. * These values define a cone of light starting from the position, emitting toward the direction.
  15747. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  15748. * and the exponent defines the speed of the decay of the light with distance (reach).
  15749. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15750. */
  15751. class SpotLight extends ShadowLight {
  15752. private _angle;
  15753. private _innerAngle;
  15754. private _cosHalfAngle;
  15755. private _lightAngleScale;
  15756. private _lightAngleOffset;
  15757. /**
  15758. * Gets the cone angle of the spot light in Radians.
  15759. */
  15760. /**
  15761. * Sets the cone angle of the spot light in Radians.
  15762. */
  15763. angle: number;
  15764. /**
  15765. * Only used in gltf falloff mode, this defines the angle where
  15766. * the directional falloff will start before cutting at angle which could be seen
  15767. * as outer angle.
  15768. */
  15769. /**
  15770. * Only used in gltf falloff mode, this defines the angle where
  15771. * the directional falloff will start before cutting at angle which could be seen
  15772. * as outer angle.
  15773. */
  15774. innerAngle: number;
  15775. private _shadowAngleScale;
  15776. /**
  15777. * Allows scaling the angle of the light for shadow generation only.
  15778. */
  15779. /**
  15780. * Allows scaling the angle of the light for shadow generation only.
  15781. */
  15782. shadowAngleScale: number;
  15783. /**
  15784. * The light decay speed with the distance from the emission spot.
  15785. */
  15786. exponent: number;
  15787. private _projectionTextureMatrix;
  15788. /**
  15789. * Allows reading the projecton texture
  15790. */
  15791. readonly projectionTextureMatrix: Matrix;
  15792. protected _projectionTextureLightNear: number;
  15793. /**
  15794. * Gets the near clip of the Spotlight for texture projection.
  15795. */
  15796. /**
  15797. * Sets the near clip of the Spotlight for texture projection.
  15798. */
  15799. projectionTextureLightNear: number;
  15800. protected _projectionTextureLightFar: number;
  15801. /**
  15802. * Gets the far clip of the Spotlight for texture projection.
  15803. */
  15804. /**
  15805. * Sets the far clip of the Spotlight for texture projection.
  15806. */
  15807. projectionTextureLightFar: number;
  15808. protected _projectionTextureUpDirection: Vector3;
  15809. /**
  15810. * Gets the Up vector of the Spotlight for texture projection.
  15811. */
  15812. /**
  15813. * Sets the Up vector of the Spotlight for texture projection.
  15814. */
  15815. projectionTextureUpDirection: Vector3;
  15816. private _projectionTexture;
  15817. /**
  15818. * Gets the projection texture of the light.
  15819. */
  15820. /**
  15821. * Sets the projection texture of the light.
  15822. */
  15823. projectionTexture: Nullable<BaseTexture>;
  15824. private _projectionTextureViewLightDirty;
  15825. private _projectionTextureProjectionLightDirty;
  15826. private _projectionTextureDirty;
  15827. private _projectionTextureViewTargetVector;
  15828. private _projectionTextureViewLightMatrix;
  15829. private _projectionTextureProjectionLightMatrix;
  15830. private _projectionTextureScalingMatrix;
  15831. /**
  15832. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  15833. * It can cast shadows.
  15834. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15835. * @param name The light friendly name
  15836. * @param position The position of the spot light in the scene
  15837. * @param direction The direction of the light in the scene
  15838. * @param angle The cone angle of the light in Radians
  15839. * @param exponent The light decay speed with the distance from the emission spot
  15840. * @param scene The scene the lights belongs to
  15841. */
  15842. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  15843. /**
  15844. * Returns the string "SpotLight".
  15845. * @returns the class name
  15846. */
  15847. getClassName(): string;
  15848. /**
  15849. * Returns the integer 2.
  15850. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15851. */
  15852. getTypeID(): number;
  15853. /**
  15854. * Overrides the direction setter to recompute the projection texture view light Matrix.
  15855. */
  15856. protected _setDirection(value: Vector3): void;
  15857. /**
  15858. * Overrides the position setter to recompute the projection texture view light Matrix.
  15859. */
  15860. protected _setPosition(value: Vector3): void;
  15861. /**
  15862. * 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.
  15863. * Returns the SpotLight.
  15864. */
  15865. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15866. protected _computeProjectionTextureViewLightMatrix(): void;
  15867. protected _computeProjectionTextureProjectionLightMatrix(): void;
  15868. /**
  15869. * Main function for light texture projection matrix computing.
  15870. */
  15871. protected _computeProjectionTextureMatrix(): void;
  15872. protected _buildUniformLayout(): void;
  15873. private _computeAngleValues;
  15874. /**
  15875. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  15876. * @param effect The effect to update
  15877. * @param lightIndex The index of the light in the effect to update
  15878. * @returns The spot light
  15879. */
  15880. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  15881. /**
  15882. * Disposes the light and the associated resources.
  15883. */
  15884. dispose(): void;
  15885. /**
  15886. * Prepares the list of defines specific to the light type.
  15887. * @param defines the list of defines
  15888. * @param lightIndex defines the index of the light for the effect
  15889. */
  15890. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15891. }
  15892. }
  15893. declare module BABYLON {
  15894. /**
  15895. * Interface used to present a loading screen while loading a scene
  15896. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  15897. */
  15898. interface ILoadingScreen {
  15899. /**
  15900. * Function called to display the loading screen
  15901. */
  15902. displayLoadingUI: () => void;
  15903. /**
  15904. * Function called to hide the loading screen
  15905. */
  15906. hideLoadingUI: () => void;
  15907. /**
  15908. * Gets or sets the color to use for the background
  15909. */
  15910. loadingUIBackgroundColor: string;
  15911. /**
  15912. * Gets or sets the text to display while loading
  15913. */
  15914. loadingUIText: string;
  15915. }
  15916. /**
  15917. * Class used for the default loading screen
  15918. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  15919. */
  15920. class DefaultLoadingScreen implements ILoadingScreen {
  15921. private _renderingCanvas;
  15922. private _loadingText;
  15923. private _loadingDivBackgroundColor;
  15924. private _loadingDiv;
  15925. private _loadingTextDiv;
  15926. /**
  15927. * Creates a new default loading screen
  15928. * @param _renderingCanvas defines the canvas used to render the scene
  15929. * @param _loadingText defines the default text to display
  15930. * @param _loadingDivBackgroundColor defines the default background color
  15931. */
  15932. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  15933. /**
  15934. * Function called to display the loading screen
  15935. */
  15936. displayLoadingUI(): void;
  15937. /**
  15938. * Function called to hide the loading screen
  15939. */
  15940. hideLoadingUI(): void;
  15941. /**
  15942. * Gets or sets the text to display while loading
  15943. */
  15944. loadingUIText: string;
  15945. /**
  15946. * Gets or sets the color to use for the background
  15947. */
  15948. loadingUIBackgroundColor: string;
  15949. private _resizeLoadingUI;
  15950. }
  15951. }
  15952. declare module BABYLON {
  15953. /**
  15954. * Class used to represent data loading progression
  15955. */
  15956. class SceneLoaderProgressEvent {
  15957. /** defines if data length to load can be evaluated */
  15958. readonly lengthComputable: boolean;
  15959. /** defines the loaded data length */
  15960. readonly loaded: number;
  15961. /** defines the data length to load */
  15962. readonly total: number;
  15963. /**
  15964. * Create a new progress event
  15965. * @param lengthComputable defines if data length to load can be evaluated
  15966. * @param loaded defines the loaded data length
  15967. * @param total defines the data length to load
  15968. */
  15969. constructor(
  15970. /** defines if data length to load can be evaluated */
  15971. lengthComputable: boolean,
  15972. /** defines the loaded data length */
  15973. loaded: number,
  15974. /** defines the data length to load */
  15975. total: number);
  15976. /**
  15977. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  15978. * @param event defines the source event
  15979. * @returns a new SceneLoaderProgressEvent
  15980. */
  15981. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  15982. }
  15983. /**
  15984. * Interface used by SceneLoader plugins to define supported file extensions
  15985. */
  15986. interface ISceneLoaderPluginExtensions {
  15987. /**
  15988. * Defines the list of supported extensions
  15989. */
  15990. [extension: string]: {
  15991. isBinary: boolean;
  15992. };
  15993. }
  15994. /**
  15995. * Interface used by SceneLoader plugin factory
  15996. */
  15997. interface ISceneLoaderPluginFactory {
  15998. /**
  15999. * Defines the name of the factory
  16000. */
  16001. name: string;
  16002. /**
  16003. * Function called to create a new plugin
  16004. * @return the new plugin
  16005. */
  16006. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16007. /**
  16008. * Boolean indicating if the plugin can direct load specific data
  16009. */
  16010. canDirectLoad?: (data: string) => boolean;
  16011. }
  16012. /**
  16013. * Interface used to define a SceneLoader plugin
  16014. */
  16015. interface ISceneLoaderPlugin {
  16016. /**
  16017. * The friendly name of this plugin.
  16018. */
  16019. name: string;
  16020. /**
  16021. * The file extensions supported by this plugin.
  16022. */
  16023. extensions: string | ISceneLoaderPluginExtensions;
  16024. /**
  16025. * Import meshes into a scene.
  16026. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16027. * @param scene The scene to import into
  16028. * @param data The data to import
  16029. * @param rootUrl The root url for scene and resources
  16030. * @param meshes The meshes array to import into
  16031. * @param particleSystems The particle systems array to import into
  16032. * @param skeletons The skeletons array to import into
  16033. * @param onError The callback when import fails
  16034. * @returns True if successful or false otherwise
  16035. */
  16036. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16037. /**
  16038. * Load into a scene.
  16039. * @param scene The scene to load into
  16040. * @param data The data to import
  16041. * @param rootUrl The root url for scene and resources
  16042. * @param onError The callback when import fails
  16043. * @returns true if successful or false otherwise
  16044. */
  16045. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16046. /**
  16047. * The callback that returns true if the data can be directly loaded.
  16048. */
  16049. canDirectLoad?: (data: string) => boolean;
  16050. /**
  16051. * The callback that allows custom handling of the root url based on the response url.
  16052. */
  16053. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16054. /**
  16055. * Load into an asset container.
  16056. * @param scene The scene to load into
  16057. * @param data The data to import
  16058. * @param rootUrl The root url for scene and resources
  16059. * @param onError The callback when import fails
  16060. * @returns The loaded asset container
  16061. */
  16062. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16063. }
  16064. /**
  16065. * Interface used to define an async SceneLoader plugin
  16066. */
  16067. interface ISceneLoaderPluginAsync {
  16068. /**
  16069. * The friendly name of this plugin.
  16070. */
  16071. name: string;
  16072. /**
  16073. * The file extensions supported by this plugin.
  16074. */
  16075. extensions: string | ISceneLoaderPluginExtensions;
  16076. /**
  16077. * Import meshes into a scene.
  16078. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16079. * @param scene The scene to import into
  16080. * @param data The data to import
  16081. * @param rootUrl The root url for scene and resources
  16082. * @param onProgress The callback when the load progresses
  16083. * @param fileName Defines the name of the file to load
  16084. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16085. */
  16086. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16087. meshes: AbstractMesh[];
  16088. particleSystems: IParticleSystem[];
  16089. skeletons: Skeleton[];
  16090. animationGroups: AnimationGroup[];
  16091. }>;
  16092. /**
  16093. * Load into a scene.
  16094. * @param scene The scene to load into
  16095. * @param data The data to import
  16096. * @param rootUrl The root url for scene and resources
  16097. * @param onProgress The callback when the load progresses
  16098. * @param fileName Defines the name of the file to load
  16099. * @returns Nothing
  16100. */
  16101. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16102. /**
  16103. * The callback that returns true if the data can be directly loaded.
  16104. */
  16105. canDirectLoad?: (data: string) => boolean;
  16106. /**
  16107. * The callback that allows custom handling of the root url based on the response url.
  16108. */
  16109. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16110. /**
  16111. * Load into an asset container.
  16112. * @param scene The scene to load into
  16113. * @param data The data to import
  16114. * @param rootUrl The root url for scene and resources
  16115. * @param onProgress The callback when the load progresses
  16116. * @param fileName Defines the name of the file to load
  16117. * @returns The loaded asset container
  16118. */
  16119. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16120. }
  16121. /**
  16122. * Class used to load scene from various file formats using registered plugins
  16123. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16124. */
  16125. class SceneLoader {
  16126. private static _ForceFullSceneLoadingForIncremental;
  16127. private static _ShowLoadingScreen;
  16128. private static _CleanBoneMatrixWeights;
  16129. /**
  16130. * No logging while loading
  16131. */
  16132. static readonly NO_LOGGING: number;
  16133. /**
  16134. * Minimal logging while loading
  16135. */
  16136. static readonly MINIMAL_LOGGING: number;
  16137. /**
  16138. * Summary logging while loading
  16139. */
  16140. static readonly SUMMARY_LOGGING: number;
  16141. /**
  16142. * Detailled logging while loading
  16143. */
  16144. static readonly DETAILED_LOGGING: number;
  16145. private static _loggingLevel;
  16146. /**
  16147. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16148. */
  16149. static ForceFullSceneLoadingForIncremental: boolean;
  16150. /**
  16151. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16152. */
  16153. static ShowLoadingScreen: boolean;
  16154. /**
  16155. * Defines the current logging level (while loading the scene)
  16156. * @ignorenaming
  16157. */
  16158. static loggingLevel: number;
  16159. /**
  16160. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16161. */
  16162. static CleanBoneMatrixWeights: boolean;
  16163. /**
  16164. * Event raised when a plugin is used to load a scene
  16165. */
  16166. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16167. private static _registeredPlugins;
  16168. private static _getDefaultPlugin;
  16169. private static _getPluginForExtension;
  16170. private static _getPluginForDirectLoad;
  16171. private static _getPluginForFilename;
  16172. private static _getDirectLoad;
  16173. private static _loadData;
  16174. private static _getFileInfo;
  16175. /**
  16176. * Gets a plugin that can load the given extension
  16177. * @param extension defines the extension to load
  16178. * @returns a plugin or null if none works
  16179. */
  16180. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16181. /**
  16182. * Gets a boolean indicating that the given extension can be loaded
  16183. * @param extension defines the extension to load
  16184. * @returns true if the extension is supported
  16185. */
  16186. static IsPluginForExtensionAvailable(extension: string): boolean;
  16187. /**
  16188. * Adds a new plugin to the list of registered plugins
  16189. * @param plugin defines the plugin to add
  16190. */
  16191. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16192. /**
  16193. * Import meshes into a scene
  16194. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16195. * @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)
  16196. * @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)
  16197. * @param scene the instance of BABYLON.Scene to append to
  16198. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16199. * @param onProgress a callback with a progress event for each file being loaded
  16200. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16201. * @param pluginExtension the extension used to determine the plugin
  16202. * @returns The loaded plugin
  16203. */
  16204. 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>;
  16205. /**
  16206. * Import meshes into a scene
  16207. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16208. * @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)
  16209. * @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)
  16210. * @param scene the instance of BABYLON.Scene to append to
  16211. * @param onProgress a callback with a progress event for each file being loaded
  16212. * @param pluginExtension the extension used to determine the plugin
  16213. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16214. */
  16215. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16216. meshes: AbstractMesh[];
  16217. particleSystems: IParticleSystem[];
  16218. skeletons: Skeleton[];
  16219. animationGroups: AnimationGroup[];
  16220. }>;
  16221. /**
  16222. * Load a scene
  16223. * @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)
  16224. * @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)
  16225. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16226. * @param onSuccess a callback with the scene when import succeeds
  16227. * @param onProgress a callback with a progress event for each file being loaded
  16228. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16229. * @param pluginExtension the extension used to determine the plugin
  16230. * @returns The loaded plugin
  16231. */
  16232. 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>;
  16233. /**
  16234. * Load a scene
  16235. * @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)
  16236. * @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)
  16237. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16238. * @param onProgress a callback with a progress event for each file being loaded
  16239. * @param pluginExtension the extension used to determine the plugin
  16240. * @returns The loaded scene
  16241. */
  16242. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16243. /**
  16244. * Append a scene
  16245. * @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)
  16246. * @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)
  16247. * @param scene is the instance of BABYLON.Scene to append to
  16248. * @param onSuccess a callback with the scene when import succeeds
  16249. * @param onProgress a callback with a progress event for each file being loaded
  16250. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16251. * @param pluginExtension the extension used to determine the plugin
  16252. * @returns The loaded plugin
  16253. */
  16254. 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>;
  16255. /**
  16256. * Append a scene
  16257. * @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)
  16258. * @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)
  16259. * @param scene is the instance of BABYLON.Scene to append to
  16260. * @param onProgress a callback with a progress event for each file being loaded
  16261. * @param pluginExtension the extension used to determine the plugin
  16262. * @returns The given scene
  16263. */
  16264. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16265. /**
  16266. * Load a scene into an asset container
  16267. * @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)
  16268. * @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)
  16269. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16270. * @param onSuccess a callback with the scene when import succeeds
  16271. * @param onProgress a callback with a progress event for each file being loaded
  16272. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16273. * @param pluginExtension the extension used to determine the plugin
  16274. * @returns The loaded plugin
  16275. */
  16276. 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>;
  16277. /**
  16278. * Load a scene into an asset container
  16279. * @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)
  16280. * @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)
  16281. * @param scene is the instance of BABYLON.Scene to append to
  16282. * @param onProgress a callback with a progress event for each file being loaded
  16283. * @param pluginExtension the extension used to determine the plugin
  16284. * @returns The loaded asset container
  16285. */
  16286. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16287. }
  16288. }
  16289. declare module BABYLON {
  16290. /**
  16291. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16292. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16293. * 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;
  16294. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16295. */
  16296. class ColorCurves {
  16297. private _dirty;
  16298. private _tempColor;
  16299. private _globalCurve;
  16300. private _highlightsCurve;
  16301. private _midtonesCurve;
  16302. private _shadowsCurve;
  16303. private _positiveCurve;
  16304. private _negativeCurve;
  16305. private _globalHue;
  16306. private _globalDensity;
  16307. private _globalSaturation;
  16308. private _globalExposure;
  16309. /**
  16310. * Gets the global Hue value.
  16311. * 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).
  16312. */
  16313. /**
  16314. * Sets the global Hue value.
  16315. * 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).
  16316. */
  16317. globalHue: number;
  16318. /**
  16319. * Gets the global Density value.
  16320. * 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.
  16321. * Values less than zero provide a filter of opposite hue.
  16322. */
  16323. /**
  16324. * Sets the global Density value.
  16325. * 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.
  16326. * Values less than zero provide a filter of opposite hue.
  16327. */
  16328. globalDensity: number;
  16329. /**
  16330. * Gets the global Saturation value.
  16331. * 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.
  16332. */
  16333. /**
  16334. * Sets the global Saturation value.
  16335. * 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.
  16336. */
  16337. globalSaturation: number;
  16338. /**
  16339. * Gets the global Exposure value.
  16340. * 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.
  16341. */
  16342. /**
  16343. * Sets the global Exposure value.
  16344. * 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.
  16345. */
  16346. globalExposure: number;
  16347. private _highlightsHue;
  16348. private _highlightsDensity;
  16349. private _highlightsSaturation;
  16350. private _highlightsExposure;
  16351. /**
  16352. * Gets the highlights Hue value.
  16353. * 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).
  16354. */
  16355. /**
  16356. * Sets the highlights Hue value.
  16357. * 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).
  16358. */
  16359. highlightsHue: number;
  16360. /**
  16361. * Gets the highlights Density value.
  16362. * 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.
  16363. * Values less than zero provide a filter of opposite hue.
  16364. */
  16365. /**
  16366. * Sets the highlights Density value.
  16367. * 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.
  16368. * Values less than zero provide a filter of opposite hue.
  16369. */
  16370. highlightsDensity: number;
  16371. /**
  16372. * Gets the highlights Saturation value.
  16373. * 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.
  16374. */
  16375. /**
  16376. * Sets the highlights Saturation value.
  16377. * 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.
  16378. */
  16379. highlightsSaturation: number;
  16380. /**
  16381. * Gets the highlights Exposure value.
  16382. * 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.
  16383. */
  16384. /**
  16385. * Sets the highlights Exposure value.
  16386. * 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.
  16387. */
  16388. highlightsExposure: number;
  16389. private _midtonesHue;
  16390. private _midtonesDensity;
  16391. private _midtonesSaturation;
  16392. private _midtonesExposure;
  16393. /**
  16394. * Gets the midtones Hue value.
  16395. * 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).
  16396. */
  16397. /**
  16398. * Sets the midtones Hue value.
  16399. * 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).
  16400. */
  16401. midtonesHue: number;
  16402. /**
  16403. * Gets the midtones Density value.
  16404. * 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.
  16405. * Values less than zero provide a filter of opposite hue.
  16406. */
  16407. /**
  16408. * Sets the midtones Density value.
  16409. * 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.
  16410. * Values less than zero provide a filter of opposite hue.
  16411. */
  16412. midtonesDensity: number;
  16413. /**
  16414. * Gets the midtones Saturation value.
  16415. * 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.
  16416. */
  16417. /**
  16418. * Sets the midtones Saturation value.
  16419. * 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.
  16420. */
  16421. midtonesSaturation: number;
  16422. /**
  16423. * Gets the midtones Exposure value.
  16424. * 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.
  16425. */
  16426. /**
  16427. * Sets the midtones Exposure value.
  16428. * 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.
  16429. */
  16430. midtonesExposure: number;
  16431. private _shadowsHue;
  16432. private _shadowsDensity;
  16433. private _shadowsSaturation;
  16434. private _shadowsExposure;
  16435. /**
  16436. * Gets the shadows Hue value.
  16437. * 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).
  16438. */
  16439. /**
  16440. * Sets the shadows Hue value.
  16441. * 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).
  16442. */
  16443. shadowsHue: number;
  16444. /**
  16445. * Gets the shadows Density value.
  16446. * 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.
  16447. * Values less than zero provide a filter of opposite hue.
  16448. */
  16449. /**
  16450. * Sets the shadows Density value.
  16451. * 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.
  16452. * Values less than zero provide a filter of opposite hue.
  16453. */
  16454. shadowsDensity: number;
  16455. /**
  16456. * Gets the shadows Saturation value.
  16457. * 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.
  16458. */
  16459. /**
  16460. * Sets the shadows Saturation value.
  16461. * 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.
  16462. */
  16463. shadowsSaturation: number;
  16464. /**
  16465. * Gets the shadows Exposure value.
  16466. * 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.
  16467. */
  16468. /**
  16469. * Sets the shadows Exposure value.
  16470. * 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.
  16471. */
  16472. shadowsExposure: number;
  16473. /**
  16474. * Returns the class name
  16475. * @returns The class name
  16476. */
  16477. getClassName(): string;
  16478. /**
  16479. * Binds the color curves to the shader.
  16480. * @param colorCurves The color curve to bind
  16481. * @param effect The effect to bind to
  16482. * @param positiveUniform The positive uniform shader parameter
  16483. * @param neutralUniform The neutral uniform shader parameter
  16484. * @param negativeUniform The negative uniform shader parameter
  16485. */
  16486. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16487. /**
  16488. * Prepare the list of uniforms associated with the ColorCurves effects.
  16489. * @param uniformsList The list of uniforms used in the effect
  16490. */
  16491. static PrepareUniforms(uniformsList: string[]): void;
  16492. /**
  16493. * Returns color grading data based on a hue, density, saturation and exposure value.
  16494. * @param filterHue The hue of the color filter.
  16495. * @param filterDensity The density of the color filter.
  16496. * @param saturation The saturation.
  16497. * @param exposure The exposure.
  16498. * @param result The result data container.
  16499. */
  16500. private getColorGradingDataToRef;
  16501. /**
  16502. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16503. * @param value The input slider value in range [-100,100].
  16504. * @returns Adjusted value.
  16505. */
  16506. private static applyColorGradingSliderNonlinear;
  16507. /**
  16508. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16509. * @param hue The hue (H) input.
  16510. * @param saturation The saturation (S) input.
  16511. * @param brightness The brightness (B) input.
  16512. * @result An RGBA color represented as Vector4.
  16513. */
  16514. private static fromHSBToRef;
  16515. /**
  16516. * Returns a value clamped between min and max
  16517. * @param value The value to clamp
  16518. * @param min The minimum of value
  16519. * @param max The maximum of value
  16520. * @returns The clamped value.
  16521. */
  16522. private static clamp;
  16523. /**
  16524. * Clones the current color curve instance.
  16525. * @return The cloned curves
  16526. */
  16527. clone(): ColorCurves;
  16528. /**
  16529. * Serializes the current color curve instance to a json representation.
  16530. * @return a JSON representation
  16531. */
  16532. serialize(): any;
  16533. /**
  16534. * Parses the color curve from a json representation.
  16535. * @param source the JSON source to parse
  16536. * @return The parsed curves
  16537. */
  16538. static Parse(source: any): ColorCurves;
  16539. }
  16540. }
  16541. declare module BABYLON {
  16542. /**
  16543. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16544. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16545. */
  16546. class EffectFallbacks {
  16547. private _defines;
  16548. private _currentRank;
  16549. private _maxRank;
  16550. private _mesh;
  16551. /**
  16552. * Removes the fallback from the bound mesh.
  16553. */
  16554. unBindMesh(): void;
  16555. /**
  16556. * Adds a fallback on the specified property.
  16557. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16558. * @param define The name of the define in the shader
  16559. */
  16560. addFallback(rank: number, define: string): void;
  16561. /**
  16562. * Sets the mesh to use CPU skinning when needing to fallback.
  16563. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16564. * @param mesh The mesh to use the fallbacks.
  16565. */
  16566. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16567. /**
  16568. * Checks to see if more fallbacks are still availible.
  16569. */
  16570. readonly isMoreFallbacks: boolean;
  16571. /**
  16572. * Removes the defines that shoould be removed when falling back.
  16573. * @param currentDefines defines the current define statements for the shader.
  16574. * @param effect defines the current effect we try to compile
  16575. * @returns The resulting defines with defines of the current rank removed.
  16576. */
  16577. reduce(currentDefines: string, effect: Effect): string;
  16578. }
  16579. /**
  16580. * Options to be used when creating an effect.
  16581. */
  16582. class EffectCreationOptions {
  16583. /**
  16584. * Atrributes that will be used in the shader.
  16585. */
  16586. attributes: string[];
  16587. /**
  16588. * Uniform varible names that will be set in the shader.
  16589. */
  16590. uniformsNames: string[];
  16591. /**
  16592. * Uniform buffer varible names that will be set in the shader.
  16593. */
  16594. uniformBuffersNames: string[];
  16595. /**
  16596. * Sampler texture variable names that will be set in the shader.
  16597. */
  16598. samplers: string[];
  16599. /**
  16600. * Define statements that will be set in the shader.
  16601. */
  16602. defines: any;
  16603. /**
  16604. * Possible fallbacks for this effect to improve performance when needed.
  16605. */
  16606. fallbacks: Nullable<EffectFallbacks>;
  16607. /**
  16608. * Callback that will be called when the shader is compiled.
  16609. */
  16610. onCompiled: Nullable<(effect: Effect) => void>;
  16611. /**
  16612. * Callback that will be called if an error occurs during shader compilation.
  16613. */
  16614. onError: Nullable<(effect: Effect, errors: string) => void>;
  16615. /**
  16616. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16617. */
  16618. indexParameters: any;
  16619. /**
  16620. * Max number of lights that can be used in the shader.
  16621. */
  16622. maxSimultaneousLights: number;
  16623. /**
  16624. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  16625. */
  16626. transformFeedbackVaryings: Nullable<string[]>;
  16627. }
  16628. /**
  16629. * Effect containing vertex and fragment shader that can be executed on an object.
  16630. */
  16631. class Effect {
  16632. /**
  16633. * Name of the effect.
  16634. */
  16635. name: any;
  16636. /**
  16637. * String container all the define statements that should be set on the shader.
  16638. */
  16639. defines: string;
  16640. /**
  16641. * Callback that will be called when the shader is compiled.
  16642. */
  16643. onCompiled: Nullable<(effect: Effect) => void>;
  16644. /**
  16645. * Callback that will be called if an error occurs during shader compilation.
  16646. */
  16647. onError: Nullable<(effect: Effect, errors: string) => void>;
  16648. /**
  16649. * Callback that will be called when effect is bound.
  16650. */
  16651. onBind: Nullable<(effect: Effect) => void>;
  16652. /**
  16653. * Unique ID of the effect.
  16654. */
  16655. uniqueId: number;
  16656. /**
  16657. * Observable that will be called when the shader is compiled.
  16658. */
  16659. onCompileObservable: Observable<Effect>;
  16660. /**
  16661. * Observable that will be called if an error occurs during shader compilation.
  16662. */
  16663. onErrorObservable: Observable<Effect>;
  16664. /** @hidden */
  16665. _onBindObservable: Nullable<Observable<Effect>>;
  16666. /**
  16667. * Observable that will be called when effect is bound.
  16668. */
  16669. readonly onBindObservable: Observable<Effect>;
  16670. /** @hidden */
  16671. _bonesComputationForcedToCPU: boolean;
  16672. private static _uniqueIdSeed;
  16673. private _engine;
  16674. private _uniformBuffersNames;
  16675. private _uniformsNames;
  16676. private _samplers;
  16677. private _isReady;
  16678. private _compilationError;
  16679. private _attributesNames;
  16680. private _attributes;
  16681. private _uniforms;
  16682. /**
  16683. * Key for the effect.
  16684. * @hidden
  16685. */
  16686. _key: string;
  16687. private _indexParameters;
  16688. private _fallbacks;
  16689. private _vertexSourceCode;
  16690. private _fragmentSourceCode;
  16691. private _vertexSourceCodeOverride;
  16692. private _fragmentSourceCodeOverride;
  16693. private _transformFeedbackVaryings;
  16694. /**
  16695. * Compiled shader to webGL program.
  16696. * @hidden
  16697. */
  16698. _program: WebGLProgram;
  16699. private _valueCache;
  16700. private static _baseCache;
  16701. /**
  16702. * Instantiates an effect.
  16703. * An effect can be used to create/manage/execute vertex and fragment shaders.
  16704. * @param baseName Name of the effect.
  16705. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  16706. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  16707. * @param samplers List of sampler variables that will be passed to the shader.
  16708. * @param engine Engine to be used to render the effect
  16709. * @param defines Define statements to be added to the shader.
  16710. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  16711. * @param onCompiled Callback that will be called when the shader is compiled.
  16712. * @param onError Callback that will be called if an error occurs during shader compilation.
  16713. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16714. */
  16715. 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);
  16716. /**
  16717. * Unique key for this effect
  16718. */
  16719. readonly key: string;
  16720. /**
  16721. * If the effect has been compiled and prepared.
  16722. * @returns if the effect is compiled and prepared.
  16723. */
  16724. isReady(): boolean;
  16725. /**
  16726. * The engine the effect was initialized with.
  16727. * @returns the engine.
  16728. */
  16729. getEngine(): Engine;
  16730. /**
  16731. * The compiled webGL program for the effect
  16732. * @returns the webGL program.
  16733. */
  16734. getProgram(): WebGLProgram;
  16735. /**
  16736. * The set of names of attribute variables for the shader.
  16737. * @returns An array of attribute names.
  16738. */
  16739. getAttributesNames(): string[];
  16740. /**
  16741. * Returns the attribute at the given index.
  16742. * @param index The index of the attribute.
  16743. * @returns The location of the attribute.
  16744. */
  16745. getAttributeLocation(index: number): number;
  16746. /**
  16747. * Returns the attribute based on the name of the variable.
  16748. * @param name of the attribute to look up.
  16749. * @returns the attribute location.
  16750. */
  16751. getAttributeLocationByName(name: string): number;
  16752. /**
  16753. * The number of attributes.
  16754. * @returns the numnber of attributes.
  16755. */
  16756. getAttributesCount(): number;
  16757. /**
  16758. * Gets the index of a uniform variable.
  16759. * @param uniformName of the uniform to look up.
  16760. * @returns the index.
  16761. */
  16762. getUniformIndex(uniformName: string): number;
  16763. /**
  16764. * Returns the attribute based on the name of the variable.
  16765. * @param uniformName of the uniform to look up.
  16766. * @returns the location of the uniform.
  16767. */
  16768. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  16769. /**
  16770. * Returns an array of sampler variable names
  16771. * @returns The array of sampler variable neames.
  16772. */
  16773. getSamplers(): string[];
  16774. /**
  16775. * The error from the last compilation.
  16776. * @returns the error string.
  16777. */
  16778. getCompilationError(): string;
  16779. /**
  16780. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  16781. * @param func The callback to be used.
  16782. */
  16783. executeWhenCompiled(func: (effect: Effect) => void): void;
  16784. /** @hidden */
  16785. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  16786. /** @hidden */
  16787. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  16788. /** @hidden */
  16789. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  16790. private _processShaderConversion;
  16791. private _processIncludes;
  16792. private _processPrecision;
  16793. /**
  16794. * Recompiles the webGL program
  16795. * @param vertexSourceCode The source code for the vertex shader.
  16796. * @param fragmentSourceCode The source code for the fragment shader.
  16797. * @param onCompiled Callback called when completed.
  16798. * @param onError Callback called on error.
  16799. * @hidden
  16800. */
  16801. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  16802. /**
  16803. * Gets the uniform locations of the the specified variable names
  16804. * @param names THe names of the variables to lookup.
  16805. * @returns Array of locations in the same order as variable names.
  16806. */
  16807. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  16808. /**
  16809. * Prepares the effect
  16810. * @hidden
  16811. */
  16812. _prepareEffect(): void;
  16813. /**
  16814. * Checks if the effect is supported. (Must be called after compilation)
  16815. */
  16816. readonly isSupported: boolean;
  16817. /**
  16818. * Binds a texture to the engine to be used as output of the shader.
  16819. * @param channel Name of the output variable.
  16820. * @param texture Texture to bind.
  16821. * @hidden
  16822. */
  16823. _bindTexture(channel: string, texture: InternalTexture): void;
  16824. /**
  16825. * Sets a texture on the engine to be used in the shader.
  16826. * @param channel Name of the sampler variable.
  16827. * @param texture Texture to set.
  16828. */
  16829. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  16830. /**
  16831. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  16832. * @param channel Name of the sampler variable.
  16833. * @param texture Texture to set.
  16834. */
  16835. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  16836. /**
  16837. * Sets an array of textures on the engine to be used in the shader.
  16838. * @param channel Name of the variable.
  16839. * @param textures Textures to set.
  16840. */
  16841. setTextureArray(channel: string, textures: BaseTexture[]): void;
  16842. /**
  16843. * 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)
  16844. * @param channel Name of the sampler variable.
  16845. * @param postProcess Post process to get the input texture from.
  16846. */
  16847. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  16848. /**
  16849. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  16850. * 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)
  16851. * @param channel Name of the sampler variable.
  16852. * @param postProcess Post process to get the output texture from.
  16853. */
  16854. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  16855. /** @hidden */
  16856. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  16857. /** @hidden */
  16858. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  16859. /** @hidden */
  16860. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  16861. /** @hidden */
  16862. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  16863. /**
  16864. * Binds a buffer to a uniform.
  16865. * @param buffer Buffer to bind.
  16866. * @param name Name of the uniform variable to bind to.
  16867. */
  16868. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  16869. /**
  16870. * Binds block to a uniform.
  16871. * @param blockName Name of the block to bind.
  16872. * @param index Index to bind.
  16873. */
  16874. bindUniformBlock(blockName: string, index: number): void;
  16875. /**
  16876. * Sets an interger value on a uniform variable.
  16877. * @param uniformName Name of the variable.
  16878. * @param value Value to be set.
  16879. * @returns this effect.
  16880. */
  16881. setInt(uniformName: string, value: number): Effect;
  16882. /**
  16883. * Sets an int array on a uniform variable.
  16884. * @param uniformName Name of the variable.
  16885. * @param array array to be set.
  16886. * @returns this effect.
  16887. */
  16888. setIntArray(uniformName: string, array: Int32Array): Effect;
  16889. /**
  16890. * 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)
  16891. * @param uniformName Name of the variable.
  16892. * @param array array to be set.
  16893. * @returns this effect.
  16894. */
  16895. setIntArray2(uniformName: string, array: Int32Array): Effect;
  16896. /**
  16897. * 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)
  16898. * @param uniformName Name of the variable.
  16899. * @param array array to be set.
  16900. * @returns this effect.
  16901. */
  16902. setIntArray3(uniformName: string, array: Int32Array): Effect;
  16903. /**
  16904. * 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)
  16905. * @param uniformName Name of the variable.
  16906. * @param array array to be set.
  16907. * @returns this effect.
  16908. */
  16909. setIntArray4(uniformName: string, array: Int32Array): Effect;
  16910. /**
  16911. * Sets an float array on a uniform variable.
  16912. * @param uniformName Name of the variable.
  16913. * @param array array to be set.
  16914. * @returns this effect.
  16915. */
  16916. setFloatArray(uniformName: string, array: Float32Array): Effect;
  16917. /**
  16918. * 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)
  16919. * @param uniformName Name of the variable.
  16920. * @param array array to be set.
  16921. * @returns this effect.
  16922. */
  16923. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  16924. /**
  16925. * 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)
  16926. * @param uniformName Name of the variable.
  16927. * @param array array to be set.
  16928. * @returns this effect.
  16929. */
  16930. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  16931. /**
  16932. * 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)
  16933. * @param uniformName Name of the variable.
  16934. * @param array array to be set.
  16935. * @returns this effect.
  16936. */
  16937. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  16938. /**
  16939. * Sets an array on a uniform variable.
  16940. * @param uniformName Name of the variable.
  16941. * @param array array to be set.
  16942. * @returns this effect.
  16943. */
  16944. setArray(uniformName: string, array: number[]): Effect;
  16945. /**
  16946. * 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)
  16947. * @param uniformName Name of the variable.
  16948. * @param array array to be set.
  16949. * @returns this effect.
  16950. */
  16951. setArray2(uniformName: string, array: number[]): Effect;
  16952. /**
  16953. * 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)
  16954. * @param uniformName Name of the variable.
  16955. * @param array array to be set.
  16956. * @returns this effect.
  16957. */
  16958. setArray3(uniformName: string, array: number[]): Effect;
  16959. /**
  16960. * 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)
  16961. * @param uniformName Name of the variable.
  16962. * @param array array to be set.
  16963. * @returns this effect.
  16964. */
  16965. setArray4(uniformName: string, array: number[]): Effect;
  16966. /**
  16967. * Sets matrices on a uniform variable.
  16968. * @param uniformName Name of the variable.
  16969. * @param matrices matrices to be set.
  16970. * @returns this effect.
  16971. */
  16972. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  16973. /**
  16974. * Sets matrix on a uniform variable.
  16975. * @param uniformName Name of the variable.
  16976. * @param matrix matrix to be set.
  16977. * @returns this effect.
  16978. */
  16979. setMatrix(uniformName: string, matrix: Matrix): Effect;
  16980. /**
  16981. * 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)
  16982. * @param uniformName Name of the variable.
  16983. * @param matrix matrix to be set.
  16984. * @returns this effect.
  16985. */
  16986. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  16987. /**
  16988. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  16989. * @param uniformName Name of the variable.
  16990. * @param matrix matrix to be set.
  16991. * @returns this effect.
  16992. */
  16993. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  16994. /**
  16995. * Sets a float on a uniform variable.
  16996. * @param uniformName Name of the variable.
  16997. * @param value value to be set.
  16998. * @returns this effect.
  16999. */
  17000. setFloat(uniformName: string, value: number): Effect;
  17001. /**
  17002. * Sets a boolean on a uniform variable.
  17003. * @param uniformName Name of the variable.
  17004. * @param bool value to be set.
  17005. * @returns this effect.
  17006. */
  17007. setBool(uniformName: string, bool: boolean): Effect;
  17008. /**
  17009. * Sets a Vector2 on a uniform variable.
  17010. * @param uniformName Name of the variable.
  17011. * @param vector2 vector2 to be set.
  17012. * @returns this effect.
  17013. */
  17014. setVector2(uniformName: string, vector2: Vector2): Effect;
  17015. /**
  17016. * Sets a float2 on a uniform variable.
  17017. * @param uniformName Name of the variable.
  17018. * @param x First float in float2.
  17019. * @param y Second float in float2.
  17020. * @returns this effect.
  17021. */
  17022. setFloat2(uniformName: string, x: number, y: number): Effect;
  17023. /**
  17024. * Sets a Vector3 on a uniform variable.
  17025. * @param uniformName Name of the variable.
  17026. * @param vector3 Value to be set.
  17027. * @returns this effect.
  17028. */
  17029. setVector3(uniformName: string, vector3: Vector3): Effect;
  17030. /**
  17031. * Sets a float3 on a uniform variable.
  17032. * @param uniformName Name of the variable.
  17033. * @param x First float in float3.
  17034. * @param y Second float in float3.
  17035. * @param z Third float in float3.
  17036. * @returns this effect.
  17037. */
  17038. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17039. /**
  17040. * Sets a Vector4 on a uniform variable.
  17041. * @param uniformName Name of the variable.
  17042. * @param vector4 Value to be set.
  17043. * @returns this effect.
  17044. */
  17045. setVector4(uniformName: string, vector4: Vector4): Effect;
  17046. /**
  17047. * Sets a float4 on a uniform variable.
  17048. * @param uniformName Name of the variable.
  17049. * @param x First float in float4.
  17050. * @param y Second float in float4.
  17051. * @param z Third float in float4.
  17052. * @param w Fourth float in float4.
  17053. * @returns this effect.
  17054. */
  17055. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17056. /**
  17057. * Sets a Color3 on a uniform variable.
  17058. * @param uniformName Name of the variable.
  17059. * @param color3 Value to be set.
  17060. * @returns this effect.
  17061. */
  17062. setColor3(uniformName: string, color3: Color3): Effect;
  17063. /**
  17064. * Sets a Color4 on a uniform variable.
  17065. * @param uniformName Name of the variable.
  17066. * @param color3 Value to be set.
  17067. * @param alpha Alpha value to be set.
  17068. * @returns this effect.
  17069. */
  17070. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17071. /**
  17072. * Sets a Color4 on a uniform variable
  17073. * @param uniformName defines the name of the variable
  17074. * @param color4 defines the value to be set
  17075. * @returns this effect.
  17076. */
  17077. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17078. /**
  17079. * This function will add a new shader to the shader store
  17080. * @param name the name of the shader
  17081. * @param pixelShader optional pixel shader content
  17082. * @param vertexShader optional vertex shader content
  17083. */
  17084. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17085. /**
  17086. * Store of each shader (The can be looked up using effect.key)
  17087. */
  17088. static ShadersStore: {
  17089. [key: string]: string;
  17090. };
  17091. /**
  17092. * Store of each included file for a shader (The can be looked up using effect.key)
  17093. */
  17094. static IncludesShadersStore: {
  17095. [key: string]: string;
  17096. };
  17097. /**
  17098. * Resets the cache of effects.
  17099. */
  17100. static ResetCache(): void;
  17101. }
  17102. }
  17103. declare module BABYLON {
  17104. /**
  17105. * This represents all the required information to add a fresnel effect on a material:
  17106. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17107. */
  17108. class FresnelParameters {
  17109. private _isEnabled;
  17110. /**
  17111. * Define if the fresnel effect is enable or not.
  17112. */
  17113. isEnabled: boolean;
  17114. /**
  17115. * Define the color used on edges (grazing angle)
  17116. */
  17117. leftColor: Color3;
  17118. /**
  17119. * Define the color used on center
  17120. */
  17121. rightColor: Color3;
  17122. /**
  17123. * Define bias applied to computed fresnel term
  17124. */
  17125. bias: number;
  17126. /**
  17127. * Defined the power exponent applied to fresnel term
  17128. */
  17129. power: number;
  17130. /**
  17131. * Clones the current fresnel and its valuues
  17132. * @returns a clone fresnel configuration
  17133. */
  17134. clone(): FresnelParameters;
  17135. /**
  17136. * Serializes the current fresnel parameters to a JSON representation.
  17137. * @return the JSON serialization
  17138. */
  17139. serialize(): any;
  17140. /**
  17141. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17142. * @param parsedFresnelParameters Define the JSON representation
  17143. * @returns the parsed parameters
  17144. */
  17145. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17146. }
  17147. }
  17148. declare module BABYLON {
  17149. /**
  17150. * Interface to follow in your material defines to integrate easily the
  17151. * Image proccessing functions.
  17152. * @hidden
  17153. */
  17154. interface IImageProcessingConfigurationDefines {
  17155. IMAGEPROCESSING: boolean;
  17156. VIGNETTE: boolean;
  17157. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17158. VIGNETTEBLENDMODEOPAQUE: boolean;
  17159. TONEMAPPING: boolean;
  17160. TONEMAPPING_ACES: boolean;
  17161. CONTRAST: boolean;
  17162. EXPOSURE: boolean;
  17163. COLORCURVES: boolean;
  17164. COLORGRADING: boolean;
  17165. COLORGRADING3D: boolean;
  17166. SAMPLER3DGREENDEPTH: boolean;
  17167. SAMPLER3DBGRMAP: boolean;
  17168. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17169. }
  17170. /**
  17171. * @hidden
  17172. */
  17173. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17174. IMAGEPROCESSING: boolean;
  17175. VIGNETTE: boolean;
  17176. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17177. VIGNETTEBLENDMODEOPAQUE: boolean;
  17178. TONEMAPPING: boolean;
  17179. TONEMAPPING_ACES: boolean;
  17180. CONTRAST: boolean;
  17181. COLORCURVES: boolean;
  17182. COLORGRADING: boolean;
  17183. COLORGRADING3D: boolean;
  17184. SAMPLER3DGREENDEPTH: boolean;
  17185. SAMPLER3DBGRMAP: boolean;
  17186. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17187. EXPOSURE: boolean;
  17188. constructor();
  17189. }
  17190. /**
  17191. * This groups together the common properties used for image processing either in direct forward pass
  17192. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17193. * or not.
  17194. */
  17195. class ImageProcessingConfiguration {
  17196. /**
  17197. * Default tone mapping applied in BabylonJS.
  17198. */
  17199. static readonly TONEMAPPING_STANDARD: number;
  17200. /**
  17201. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17202. * to other engines rendering to increase portability.
  17203. */
  17204. static readonly TONEMAPPING_ACES: number;
  17205. /**
  17206. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17207. */
  17208. colorCurves: Nullable<ColorCurves>;
  17209. private _colorCurvesEnabled;
  17210. /**
  17211. * Gets wether the color curves effect is enabled.
  17212. */
  17213. /**
  17214. * Sets wether the color curves effect is enabled.
  17215. */
  17216. colorCurvesEnabled: boolean;
  17217. private _colorGradingTexture;
  17218. /**
  17219. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17220. */
  17221. /**
  17222. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17223. */
  17224. colorGradingTexture: Nullable<BaseTexture>;
  17225. private _colorGradingEnabled;
  17226. /**
  17227. * Gets wether the color grading effect is enabled.
  17228. */
  17229. /**
  17230. * Sets wether the color grading effect is enabled.
  17231. */
  17232. colorGradingEnabled: boolean;
  17233. private _colorGradingWithGreenDepth;
  17234. /**
  17235. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17236. */
  17237. /**
  17238. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17239. */
  17240. colorGradingWithGreenDepth: boolean;
  17241. private _colorGradingBGR;
  17242. /**
  17243. * Gets wether the color grading texture contains BGR values.
  17244. */
  17245. /**
  17246. * Sets wether the color grading texture contains BGR values.
  17247. */
  17248. colorGradingBGR: boolean;
  17249. /** @hidden */
  17250. _exposure: number;
  17251. /**
  17252. * Gets the Exposure used in the effect.
  17253. */
  17254. /**
  17255. * Sets the Exposure used in the effect.
  17256. */
  17257. exposure: number;
  17258. private _toneMappingEnabled;
  17259. /**
  17260. * Gets wether the tone mapping effect is enabled.
  17261. */
  17262. /**
  17263. * Sets wether the tone mapping effect is enabled.
  17264. */
  17265. toneMappingEnabled: boolean;
  17266. private _toneMappingType;
  17267. /**
  17268. * Gets the type of tone mapping effect.
  17269. */
  17270. /**
  17271. * Sets the type of tone mapping effect used in BabylonJS.
  17272. */
  17273. toneMappingType: number;
  17274. protected _contrast: number;
  17275. /**
  17276. * Gets the contrast used in the effect.
  17277. */
  17278. /**
  17279. * Sets the contrast used in the effect.
  17280. */
  17281. contrast: number;
  17282. /**
  17283. * Vignette stretch size.
  17284. */
  17285. vignetteStretch: number;
  17286. /**
  17287. * Vignette centre X Offset.
  17288. */
  17289. vignetteCentreX: number;
  17290. /**
  17291. * Vignette centre Y Offset.
  17292. */
  17293. vignetteCentreY: number;
  17294. /**
  17295. * Vignette weight or intensity of the vignette effect.
  17296. */
  17297. vignetteWeight: number;
  17298. /**
  17299. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17300. * if vignetteEnabled is set to true.
  17301. */
  17302. vignetteColor: Color4;
  17303. /**
  17304. * Camera field of view used by the Vignette effect.
  17305. */
  17306. vignetteCameraFov: number;
  17307. private _vignetteBlendMode;
  17308. /**
  17309. * Gets the vignette blend mode allowing different kind of effect.
  17310. */
  17311. /**
  17312. * Sets the vignette blend mode allowing different kind of effect.
  17313. */
  17314. vignetteBlendMode: number;
  17315. private _vignetteEnabled;
  17316. /**
  17317. * Gets wether the vignette effect is enabled.
  17318. */
  17319. /**
  17320. * Sets wether the vignette effect is enabled.
  17321. */
  17322. vignetteEnabled: boolean;
  17323. private _applyByPostProcess;
  17324. /**
  17325. * Gets wether the image processing is applied through a post process or not.
  17326. */
  17327. /**
  17328. * Sets wether the image processing is applied through a post process or not.
  17329. */
  17330. applyByPostProcess: boolean;
  17331. private _isEnabled;
  17332. /**
  17333. * Gets wether the image processing is enabled or not.
  17334. */
  17335. /**
  17336. * Sets wether the image processing is enabled or not.
  17337. */
  17338. isEnabled: boolean;
  17339. /**
  17340. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17341. */
  17342. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17343. /**
  17344. * Method called each time the image processing information changes requires to recompile the effect.
  17345. */
  17346. protected _updateParameters(): void;
  17347. /**
  17348. * Gets the current class name.
  17349. * @return "ImageProcessingConfiguration"
  17350. */
  17351. getClassName(): string;
  17352. /**
  17353. * Prepare the list of uniforms associated with the Image Processing effects.
  17354. * @param uniforms The list of uniforms used in the effect
  17355. * @param defines the list of defines currently in use
  17356. */
  17357. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17358. /**
  17359. * Prepare the list of samplers associated with the Image Processing effects.
  17360. * @param samplersList The list of uniforms used in the effect
  17361. * @param defines the list of defines currently in use
  17362. */
  17363. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17364. /**
  17365. * Prepare the list of defines associated to the shader.
  17366. * @param defines the list of defines to complete
  17367. * @param forPostProcess Define if we are currently in post process mode or not
  17368. */
  17369. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17370. /**
  17371. * Returns true if all the image processing information are ready.
  17372. * @returns True if ready, otherwise, false
  17373. */
  17374. isReady(): boolean;
  17375. /**
  17376. * Binds the image processing to the shader.
  17377. * @param effect The effect to bind to
  17378. * @param aspectRatio Define the current aspect ratio of the effect
  17379. */
  17380. bind(effect: Effect, aspectRatio?: number): void;
  17381. /**
  17382. * Clones the current image processing instance.
  17383. * @return The cloned image processing
  17384. */
  17385. clone(): ImageProcessingConfiguration;
  17386. /**
  17387. * Serializes the current image processing instance to a json representation.
  17388. * @return a JSON representation
  17389. */
  17390. serialize(): any;
  17391. /**
  17392. * Parses the image processing from a json representation.
  17393. * @param source the JSON source to parse
  17394. * @return The parsed image processing
  17395. */
  17396. static Parse(source: any): ImageProcessingConfiguration;
  17397. private static _VIGNETTEMODE_MULTIPLY;
  17398. private static _VIGNETTEMODE_OPAQUE;
  17399. /**
  17400. * Used to apply the vignette as a mix with the pixel color.
  17401. */
  17402. static readonly VIGNETTEMODE_MULTIPLY: number;
  17403. /**
  17404. * Used to apply the vignette as a replacement of the pixel color.
  17405. */
  17406. static readonly VIGNETTEMODE_OPAQUE: number;
  17407. }
  17408. }
  17409. declare module BABYLON {
  17410. /**
  17411. * Manages the defines for the Material
  17412. */
  17413. class MaterialDefines {
  17414. private _keys;
  17415. private _isDirty;
  17416. /** @hidden */
  17417. _renderId: number;
  17418. /** @hidden */
  17419. _areLightsDirty: boolean;
  17420. /** @hidden */
  17421. _areAttributesDirty: boolean;
  17422. /** @hidden */
  17423. _areTexturesDirty: boolean;
  17424. /** @hidden */
  17425. _areFresnelDirty: boolean;
  17426. /** @hidden */
  17427. _areMiscDirty: boolean;
  17428. /** @hidden */
  17429. _areImageProcessingDirty: boolean;
  17430. /** @hidden */
  17431. _normals: boolean;
  17432. /** @hidden */
  17433. _uvs: boolean;
  17434. /** @hidden */
  17435. _needNormals: boolean;
  17436. /** @hidden */
  17437. _needUVs: boolean;
  17438. /**
  17439. * Specifies if the material needs to be re-calculated
  17440. */
  17441. readonly isDirty: boolean;
  17442. /**
  17443. * Marks the material to indicate that it has been re-calculated
  17444. */
  17445. markAsProcessed(): void;
  17446. /**
  17447. * Marks the material to indicate that it needs to be re-calculated
  17448. */
  17449. markAsUnprocessed(): void;
  17450. /**
  17451. * Marks the material to indicate all of its defines need to be re-calculated
  17452. */
  17453. markAllAsDirty(): void;
  17454. /**
  17455. * Marks the material to indicate that image processing needs to be re-calculated
  17456. */
  17457. markAsImageProcessingDirty(): void;
  17458. /**
  17459. * Marks the material to indicate the lights need to be re-calculated
  17460. */
  17461. markAsLightDirty(): void;
  17462. /**
  17463. * Marks the attribute state as changed
  17464. */
  17465. markAsAttributesDirty(): void;
  17466. /**
  17467. * Marks the texture state as changed
  17468. */
  17469. markAsTexturesDirty(): void;
  17470. /**
  17471. * Marks the fresnel state as changed
  17472. */
  17473. markAsFresnelDirty(): void;
  17474. /**
  17475. * Marks the misc state as changed
  17476. */
  17477. markAsMiscDirty(): void;
  17478. /**
  17479. * Rebuilds the material defines
  17480. */
  17481. rebuild(): void;
  17482. /**
  17483. * Specifies if two material defines are equal
  17484. * @param other - A material define instance to compare to
  17485. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17486. */
  17487. isEqual(other: MaterialDefines): boolean;
  17488. /**
  17489. * Clones this instance's defines to another instance
  17490. * @param other - material defines to clone values to
  17491. */
  17492. cloneTo(other: MaterialDefines): void;
  17493. /**
  17494. * Resets the material define values
  17495. */
  17496. reset(): void;
  17497. /**
  17498. * Converts the material define values to a string
  17499. * @returns - String of material define information
  17500. */
  17501. toString(): string;
  17502. }
  17503. /**
  17504. * Base class for the main features of a material in Babylon.js
  17505. */
  17506. class Material implements IAnimatable {
  17507. private static _TriangleFillMode;
  17508. private static _WireFrameFillMode;
  17509. private static _PointFillMode;
  17510. private static _PointListDrawMode;
  17511. private static _LineListDrawMode;
  17512. private static _LineLoopDrawMode;
  17513. private static _LineStripDrawMode;
  17514. private static _TriangleStripDrawMode;
  17515. private static _TriangleFanDrawMode;
  17516. /**
  17517. * Returns the triangle fill mode
  17518. */
  17519. static readonly TriangleFillMode: number;
  17520. /**
  17521. * Returns the wireframe mode
  17522. */
  17523. static readonly WireFrameFillMode: number;
  17524. /**
  17525. * Returns the point fill mode
  17526. */
  17527. static readonly PointFillMode: number;
  17528. /**
  17529. * Returns the point list draw mode
  17530. */
  17531. static readonly PointListDrawMode: number;
  17532. /**
  17533. * Returns the line list draw mode
  17534. */
  17535. static readonly LineListDrawMode: number;
  17536. /**
  17537. * Returns the line loop draw mode
  17538. */
  17539. static readonly LineLoopDrawMode: number;
  17540. /**
  17541. * Returns the line strip draw mode
  17542. */
  17543. static readonly LineStripDrawMode: number;
  17544. /**
  17545. * Returns the triangle strip draw mode
  17546. */
  17547. static readonly TriangleStripDrawMode: number;
  17548. /**
  17549. * Returns the triangle fan draw mode
  17550. */
  17551. static readonly TriangleFanDrawMode: number;
  17552. /**
  17553. * Stores the clock-wise side orientation
  17554. */
  17555. private static _ClockWiseSideOrientation;
  17556. /**
  17557. * Stores the counter clock-wise side orientation
  17558. */
  17559. private static _CounterClockWiseSideOrientation;
  17560. /**
  17561. * Returns the clock-wise side orientation
  17562. */
  17563. static readonly ClockWiseSideOrientation: number;
  17564. /**
  17565. * Returns the counter clock-wise side orientation
  17566. */
  17567. static readonly CounterClockWiseSideOrientation: number;
  17568. /**
  17569. * The dirty texture flag value
  17570. */
  17571. static readonly TextureDirtyFlag: number;
  17572. /**
  17573. * The dirty light flag value
  17574. */
  17575. static readonly LightDirtyFlag: number;
  17576. /**
  17577. * The dirty fresnel flag value
  17578. */
  17579. static readonly FresnelDirtyFlag: number;
  17580. /**
  17581. * The dirty attribute flag value
  17582. */
  17583. static readonly AttributesDirtyFlag: number;
  17584. /**
  17585. * The dirty misc flag value
  17586. */
  17587. static readonly MiscDirtyFlag: number;
  17588. /**
  17589. * The all dirty flag value
  17590. */
  17591. static readonly AllDirtyFlag: number;
  17592. /**
  17593. * The ID of the material
  17594. */
  17595. id: string;
  17596. /**
  17597. * Gets or sets the unique id of the material
  17598. */
  17599. uniqueId: number;
  17600. /**
  17601. * The name of the material
  17602. */
  17603. name: string;
  17604. /**
  17605. * Specifies if the ready state should be checked on each call
  17606. */
  17607. checkReadyOnEveryCall: boolean;
  17608. /**
  17609. * Specifies if the ready state should be checked once
  17610. */
  17611. checkReadyOnlyOnce: boolean;
  17612. /**
  17613. * The state of the material
  17614. */
  17615. state: string;
  17616. /**
  17617. * The alpha value of the material
  17618. */
  17619. protected _alpha: number;
  17620. /**
  17621. * Sets the alpha value of the material
  17622. */
  17623. /**
  17624. * Gets the alpha value of the material
  17625. */
  17626. alpha: number;
  17627. /**
  17628. * Specifies if back face culling is enabled
  17629. */
  17630. protected _backFaceCulling: boolean;
  17631. /**
  17632. * Sets the back-face culling state
  17633. */
  17634. /**
  17635. * Gets the back-face culling state
  17636. */
  17637. backFaceCulling: boolean;
  17638. /**
  17639. * Stores the value for side orientation
  17640. */
  17641. sideOrientation: number;
  17642. /**
  17643. * Callback triggered when the material is compiled
  17644. */
  17645. onCompiled: (effect: Effect) => void;
  17646. /**
  17647. * Callback triggered when an error occurs
  17648. */
  17649. onError: (effect: Effect, errors: string) => void;
  17650. /**
  17651. * Callback triggered to get the render target textures
  17652. */
  17653. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17654. /**
  17655. * Gets a boolean indicating that current material needs to register RTT
  17656. */
  17657. readonly hasRenderTargetTextures: boolean;
  17658. /**
  17659. * Specifies if the material should be serialized
  17660. */
  17661. doNotSerialize: boolean;
  17662. /**
  17663. * Specifies if the effect should be stored on sub meshes
  17664. */
  17665. storeEffectOnSubMeshes: boolean;
  17666. /**
  17667. * Stores the animations for the material
  17668. */
  17669. animations: Array<Animation>;
  17670. /**
  17671. * An event triggered when the material is disposed
  17672. */
  17673. onDisposeObservable: Observable<Material>;
  17674. /**
  17675. * An observer which watches for dispose events
  17676. */
  17677. private _onDisposeObserver;
  17678. private _onUnBindObservable;
  17679. /**
  17680. * Called during a dispose event
  17681. */
  17682. onDispose: () => void;
  17683. private _onBindObservable;
  17684. /**
  17685. * An event triggered when the material is bound
  17686. */
  17687. readonly onBindObservable: Observable<AbstractMesh>;
  17688. /**
  17689. * An observer which watches for bind events
  17690. */
  17691. private _onBindObserver;
  17692. /**
  17693. * Called during a bind event
  17694. */
  17695. onBind: (Mesh: AbstractMesh) => void;
  17696. /**
  17697. * An event triggered when the material is unbound
  17698. */
  17699. readonly onUnBindObservable: Observable<Material>;
  17700. /**
  17701. * Stores the value of the alpha mode
  17702. */
  17703. private _alphaMode;
  17704. /**
  17705. * Sets the value of the alpha mode.
  17706. *
  17707. * | Value | Type | Description |
  17708. * | --- | --- | --- |
  17709. * | 0 | ALPHA_DISABLE | |
  17710. * | 1 | ALPHA_ADD | |
  17711. * | 2 | ALPHA_COMBINE | |
  17712. * | 3 | ALPHA_SUBTRACT | |
  17713. * | 4 | ALPHA_MULTIPLY | |
  17714. * | 5 | ALPHA_MAXIMIZED | |
  17715. * | 6 | ALPHA_ONEONE | |
  17716. * | 7 | ALPHA_PREMULTIPLIED | |
  17717. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17718. * | 9 | ALPHA_INTERPOLATE | |
  17719. * | 10 | ALPHA_SCREENMODE | |
  17720. *
  17721. */
  17722. /**
  17723. * Gets the value of the alpha mode
  17724. */
  17725. alphaMode: number;
  17726. /**
  17727. * Stores the state of the need depth pre-pass value
  17728. */
  17729. private _needDepthPrePass;
  17730. /**
  17731. * Sets the need depth pre-pass value
  17732. */
  17733. /**
  17734. * Gets the depth pre-pass value
  17735. */
  17736. needDepthPrePass: boolean;
  17737. /**
  17738. * Specifies if depth writing should be disabled
  17739. */
  17740. disableDepthWrite: boolean;
  17741. /**
  17742. * Specifies if depth writing should be forced
  17743. */
  17744. forceDepthWrite: boolean;
  17745. /**
  17746. * Specifies if there should be a separate pass for culling
  17747. */
  17748. separateCullingPass: boolean;
  17749. /**
  17750. * Stores the state specifing if fog should be enabled
  17751. */
  17752. private _fogEnabled;
  17753. /**
  17754. * Sets the state for enabling fog
  17755. */
  17756. /**
  17757. * Gets the value of the fog enabled state
  17758. */
  17759. fogEnabled: boolean;
  17760. /**
  17761. * Stores the size of points
  17762. */
  17763. pointSize: number;
  17764. /**
  17765. * Stores the z offset value
  17766. */
  17767. zOffset: number;
  17768. /**
  17769. * Gets a value specifying if wireframe mode is enabled
  17770. */
  17771. /**
  17772. * Sets the state of wireframe mode
  17773. */
  17774. wireframe: boolean;
  17775. /**
  17776. * Gets the value specifying if point clouds are enabled
  17777. */
  17778. /**
  17779. * Sets the state of point cloud mode
  17780. */
  17781. pointsCloud: boolean;
  17782. /**
  17783. * Gets the material fill mode
  17784. */
  17785. /**
  17786. * Sets the material fill mode
  17787. */
  17788. fillMode: number;
  17789. /**
  17790. * @hidden
  17791. * Stores the effects for the material
  17792. */
  17793. _effect: Nullable<Effect>;
  17794. /**
  17795. * @hidden
  17796. * Specifies if the material was previously ready
  17797. */
  17798. _wasPreviouslyReady: boolean;
  17799. /**
  17800. * Specifies if uniform buffers should be used
  17801. */
  17802. private _useUBO;
  17803. /**
  17804. * Stores a reference to the scene
  17805. */
  17806. private _scene;
  17807. /**
  17808. * Stores the fill mode state
  17809. */
  17810. private _fillMode;
  17811. /**
  17812. * Specifies if the depth write state should be cached
  17813. */
  17814. private _cachedDepthWriteState;
  17815. /**
  17816. * Stores the uniform buffer
  17817. */
  17818. protected _uniformBuffer: UniformBuffer;
  17819. /**
  17820. * Creates a material instance
  17821. * @param name defines the name of the material
  17822. * @param scene defines the scene to reference
  17823. * @param doNotAdd specifies if the material should be added to the scene
  17824. */
  17825. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17826. /**
  17827. * Returns a string representation of the current material
  17828. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17829. * @returns a string with material information
  17830. */
  17831. toString(fullDetails?: boolean): string;
  17832. /**
  17833. * Gets the class name of the material
  17834. * @returns a string with the class name of the material
  17835. */
  17836. getClassName(): string;
  17837. /**
  17838. * Specifies if updates for the material been locked
  17839. */
  17840. readonly isFrozen: boolean;
  17841. /**
  17842. * Locks updates for the material
  17843. */
  17844. freeze(): void;
  17845. /**
  17846. * Unlocks updates for the material
  17847. */
  17848. unfreeze(): void;
  17849. /**
  17850. * Specifies if the material is ready to be used
  17851. * @param mesh defines the mesh to check
  17852. * @param useInstances specifies if instances should be used
  17853. * @returns a boolean indicating if the material is ready to be used
  17854. */
  17855. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17856. /**
  17857. * Specifies that the submesh is ready to be used
  17858. * @param mesh defines the mesh to check
  17859. * @param subMesh defines which submesh to check
  17860. * @param useInstances specifies that instances should be used
  17861. * @returns a boolean indicating that the submesh is ready or not
  17862. */
  17863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17864. /**
  17865. * Returns the material effect
  17866. * @returns the effect associated with the material
  17867. */
  17868. getEffect(): Nullable<Effect>;
  17869. /**
  17870. * Returns the current scene
  17871. * @returns a Scene
  17872. */
  17873. getScene(): Scene;
  17874. /**
  17875. * Specifies if the material will require alpha blending
  17876. * @returns a boolean specifying if alpha blending is needed
  17877. */
  17878. needAlphaBlending(): boolean;
  17879. /**
  17880. * Specifies if the mesh will require alpha blending
  17881. * @param mesh defines the mesh to check
  17882. * @returns a boolean specifying if alpha blending is needed for the mesh
  17883. */
  17884. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  17885. /**
  17886. * Specifies if this material should be rendered in alpha test mode
  17887. * @returns a boolean specifying if an alpha test is needed.
  17888. */
  17889. needAlphaTesting(): boolean;
  17890. /**
  17891. * Gets the texture used for the alpha test
  17892. * @returns the texture to use for alpha testing
  17893. */
  17894. getAlphaTestTexture(): Nullable<BaseTexture>;
  17895. /**
  17896. * Marks the material to indicate that it needs to be re-calculated
  17897. */
  17898. markDirty(): void;
  17899. /** @hidden */
  17900. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  17901. /**
  17902. * Binds the material to the mesh
  17903. * @param world defines the world transformation matrix
  17904. * @param mesh defines the mesh to bind the material to
  17905. */
  17906. bind(world: Matrix, mesh?: Mesh): void;
  17907. /**
  17908. * Binds the submesh to the material
  17909. * @param world defines the world transformation matrix
  17910. * @param mesh defines the mesh containing the submesh
  17911. * @param subMesh defines the submesh to bind the material to
  17912. */
  17913. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17914. /**
  17915. * Binds the world matrix to the material
  17916. * @param world defines the world transformation matrix
  17917. */
  17918. bindOnlyWorldMatrix(world: Matrix): void;
  17919. /**
  17920. * Binds the scene's uniform buffer to the effect.
  17921. * @param effect defines the effect to bind to the scene uniform buffer
  17922. * @param sceneUbo defines the uniform buffer storing scene data
  17923. */
  17924. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17925. /**
  17926. * Binds the view matrix to the effect
  17927. * @param effect defines the effect to bind the view matrix to
  17928. */
  17929. bindView(effect: Effect): void;
  17930. /**
  17931. * Binds the view projection matrix to the effect
  17932. * @param effect defines the effect to bind the view projection matrix to
  17933. */
  17934. bindViewProjection(effect: Effect): void;
  17935. /**
  17936. * Specifies if material alpha testing should be turned on for the mesh
  17937. * @param mesh defines the mesh to check
  17938. */
  17939. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17940. /**
  17941. * Processes to execute after binding the material to a mesh
  17942. * @param mesh defines the rendered mesh
  17943. */
  17944. protected _afterBind(mesh?: Mesh): void;
  17945. /**
  17946. * Unbinds the material from the mesh
  17947. */
  17948. unbind(): void;
  17949. /**
  17950. * Gets the active textures from the material
  17951. * @returns an array of textures
  17952. */
  17953. getActiveTextures(): BaseTexture[];
  17954. /**
  17955. * Specifies if the material uses a texture
  17956. * @param texture defines the texture to check against the material
  17957. * @returns a boolean specifying if the material uses the texture
  17958. */
  17959. hasTexture(texture: BaseTexture): boolean;
  17960. /**
  17961. * Makes a duplicate of the material, and gives it a new name
  17962. * @param name defines the new name for the duplicated material
  17963. * @returns the cloned material
  17964. */
  17965. clone(name: string): Nullable<Material>;
  17966. /**
  17967. * Gets the meshes bound to the material
  17968. * @returns an array of meshes bound to the material
  17969. */
  17970. getBindedMeshes(): AbstractMesh[];
  17971. /**
  17972. * Force shader compilation
  17973. * @param mesh defines the mesh associated with this material
  17974. * @param onCompiled defines a function to execute once the material is compiled
  17975. * @param options defines the options to configure the compilation
  17976. */
  17977. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17978. clipPlane: boolean;
  17979. }>): void;
  17980. /**
  17981. * Force shader compilation
  17982. * @param mesh defines the mesh that will use this material
  17983. * @param options defines additional options for compiling the shaders
  17984. * @returns a promise that resolves when the compilation completes
  17985. */
  17986. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17987. clipPlane: boolean;
  17988. }>): Promise<void>;
  17989. /**
  17990. * Marks a define in the material to indicate that it needs to be re-computed
  17991. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17992. */
  17993. markAsDirty(flag: number): void;
  17994. /**
  17995. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17996. * @param func defines a function which checks material defines against the submeshes
  17997. */
  17998. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17999. /**
  18000. * Indicates that image processing needs to be re-calculated for all submeshes
  18001. */
  18002. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18003. /**
  18004. * Indicates that textures need to be re-calculated for all submeshes
  18005. */
  18006. protected _markAllSubMeshesAsTexturesDirty(): void;
  18007. /**
  18008. * Indicates that fresnel needs to be re-calculated for all submeshes
  18009. */
  18010. protected _markAllSubMeshesAsFresnelDirty(): void;
  18011. /**
  18012. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18013. */
  18014. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18015. /**
  18016. * Indicates that lights need to be re-calculated for all submeshes
  18017. */
  18018. protected _markAllSubMeshesAsLightsDirty(): void;
  18019. /**
  18020. * Indicates that attributes need to be re-calculated for all submeshes
  18021. */
  18022. protected _markAllSubMeshesAsAttributesDirty(): void;
  18023. /**
  18024. * Indicates that misc needs to be re-calculated for all submeshes
  18025. */
  18026. protected _markAllSubMeshesAsMiscDirty(): void;
  18027. /**
  18028. * Indicates that textures and misc need to be re-calculated for all submeshes
  18029. */
  18030. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18031. /**
  18032. * Disposes the material
  18033. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18034. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18035. */
  18036. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18037. /**
  18038. * Serializes this material
  18039. * @returns the serialized material object
  18040. */
  18041. serialize(): any;
  18042. /**
  18043. * Creates a MultiMaterial from parsed MultiMaterial data.
  18044. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18045. * @param scene defines the hosting scene
  18046. * @returns a new MultiMaterial
  18047. */
  18048. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18049. /**
  18050. * Creates a material from parsed material data
  18051. * @param parsedMaterial defines parsed material data
  18052. * @param scene defines the hosting scene
  18053. * @param rootUrl defines the root URL to use to load textures
  18054. * @returns a new material
  18055. */
  18056. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18057. }
  18058. }
  18059. declare module BABYLON {
  18060. /**
  18061. * "Static Class" containing the most commonly used helper while dealing with material for
  18062. * rendering purpose.
  18063. *
  18064. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18065. *
  18066. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18067. */
  18068. class MaterialHelper {
  18069. /**
  18070. * Bind the current view position to an effect.
  18071. * @param effect The effect to be bound
  18072. * @param scene The scene the eyes position is used from
  18073. */
  18074. static BindEyePosition(effect: Effect, scene: Scene): void;
  18075. /**
  18076. * Helps preparing the defines values about the UVs in used in the effect.
  18077. * UVs are shared as much as we can accross channels in the shaders.
  18078. * @param texture The texture we are preparing the UVs for
  18079. * @param defines The defines to update
  18080. * @param key The channel key "diffuse", "specular"... used in the shader
  18081. */
  18082. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18083. /**
  18084. * Binds a texture matrix value to its corrsponding uniform
  18085. * @param texture The texture to bind the matrix for
  18086. * @param uniformBuffer The uniform buffer receivin the data
  18087. * @param key The channel key "diffuse", "specular"... used in the shader
  18088. */
  18089. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18090. /**
  18091. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18092. * @param mesh defines the current mesh
  18093. * @param scene defines the current scene
  18094. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18095. * @param pointsCloud defines if point cloud rendering has to be turned on
  18096. * @param fogEnabled defines if fog has to be turned on
  18097. * @param alphaTest defines if alpha testing has to be turned on
  18098. * @param defines defines the current list of defines
  18099. */
  18100. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18101. /**
  18102. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18103. * @param scene defines the current scene
  18104. * @param engine defines the current engine
  18105. * @param defines specifies the list of active defines
  18106. * @param useInstances defines if instances have to be turned on
  18107. * @param useClipPlane defines if clip plane have to be turned on
  18108. */
  18109. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18110. /**
  18111. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18112. * @param mesh The mesh containing the geometry data we will draw
  18113. * @param defines The defines to update
  18114. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18115. * @param useBones Precise whether bones should be used or not (override mesh info)
  18116. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18117. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18118. * @returns false if defines are considered not dirty and have not been checked
  18119. */
  18120. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18121. /**
  18122. * Prepares the defines related to the light information passed in parameter
  18123. * @param scene The scene we are intending to draw
  18124. * @param mesh The mesh the effect is compiling for
  18125. * @param defines The defines to update
  18126. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18127. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18128. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18129. * @returns true if normals will be required for the rest of the effect
  18130. */
  18131. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18132. /**
  18133. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18134. * that won t be acctive due to defines being turned off.
  18135. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18136. * @param samplersList The samplers list
  18137. * @param defines The defines helping in the list generation
  18138. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18139. */
  18140. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18141. /**
  18142. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18143. * @param defines The defines to update while falling back
  18144. * @param fallbacks The authorized effect fallbacks
  18145. * @param maxSimultaneousLights The maximum number of lights allowed
  18146. * @param rank the current rank of the Effect
  18147. * @returns The newly affected rank
  18148. */
  18149. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18150. /**
  18151. * Prepares the list of attributes required for morph targets according to the effect defines.
  18152. * @param attribs The current list of supported attribs
  18153. * @param mesh The mesh to prepare the morph targets attributes for
  18154. * @param defines The current Defines of the effect
  18155. */
  18156. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18157. /**
  18158. * Prepares the list of attributes required for bones according to the effect defines.
  18159. * @param attribs The current list of supported attribs
  18160. * @param mesh The mesh to prepare the bones attributes for
  18161. * @param defines The current Defines of the effect
  18162. * @param fallbacks The current efffect fallback strategy
  18163. */
  18164. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18165. /**
  18166. * Prepares the list of attributes required for instances according to the effect defines.
  18167. * @param attribs The current list of supported attribs
  18168. * @param defines The current Defines of the effect
  18169. */
  18170. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18171. /**
  18172. * Binds the light shadow information to the effect for the given mesh.
  18173. * @param light The light containing the generator
  18174. * @param scene The scene the lights belongs to
  18175. * @param mesh The mesh we are binding the information to render
  18176. * @param lightIndex The light index in the effect used to render the mesh
  18177. * @param effect The effect we are binding the data to
  18178. */
  18179. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18180. /**
  18181. * Binds the light information to the effect.
  18182. * @param light The light containing the generator
  18183. * @param effect The effect we are binding the data to
  18184. * @param lightIndex The light index in the effect used to render
  18185. */
  18186. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18187. /**
  18188. * Binds the lights information from the scene to the effect for the given mesh.
  18189. * @param scene The scene the lights belongs to
  18190. * @param mesh The mesh we are binding the information to render
  18191. * @param effect The effect we are binding the data to
  18192. * @param defines The generated defines for the effect
  18193. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18194. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18195. */
  18196. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18197. private static _tempFogColor;
  18198. /**
  18199. * Binds the fog information from the scene to the effect for the given mesh.
  18200. * @param scene The scene the lights belongs to
  18201. * @param mesh The mesh we are binding the information to render
  18202. * @param effect The effect we are binding the data to
  18203. * @param linearSpace Defines if the fog effect is applied in linear space
  18204. */
  18205. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18206. /**
  18207. * Binds the bones information from the mesh to the effect.
  18208. * @param mesh The mesh we are binding the information to render
  18209. * @param effect The effect we are binding the data to
  18210. */
  18211. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18212. /**
  18213. * Binds the morph targets information from the mesh to the effect.
  18214. * @param abstractMesh The mesh we are binding the information to render
  18215. * @param effect The effect we are binding the data to
  18216. */
  18217. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18218. /**
  18219. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18220. * @param defines The generated defines used in the effect
  18221. * @param effect The effect we are binding the data to
  18222. * @param scene The scene we are willing to render with logarithmic scale for
  18223. */
  18224. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18225. /**
  18226. * Binds the clip plane information from the scene to the effect.
  18227. * @param scene The scene the clip plane information are extracted from
  18228. * @param effect The effect we are binding the data to
  18229. */
  18230. static BindClipPlane(effect: Effect, scene: Scene): void;
  18231. }
  18232. }
  18233. declare module BABYLON {
  18234. /**
  18235. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18236. * separate meshes. This can be use to improve performances.
  18237. * @see http://doc.babylonjs.com/how_to/multi_materials
  18238. */
  18239. class MultiMaterial extends Material {
  18240. private _subMaterials;
  18241. /**
  18242. * Gets or Sets the list of Materials used within the multi material.
  18243. * They need to be ordered according to the submeshes order in the associated mesh
  18244. */
  18245. subMaterials: Nullable<Material>[];
  18246. /**
  18247. * Instantiates a new Multi Material
  18248. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18249. * separate meshes. This can be use to improve performances.
  18250. * @see http://doc.babylonjs.com/how_to/multi_materials
  18251. * @param name Define the name in the scene
  18252. * @param scene Define the scene the material belongs to
  18253. */
  18254. constructor(name: string, scene: Scene);
  18255. private _hookArray;
  18256. /**
  18257. * Get one of the submaterial by its index in the submaterials array
  18258. * @param index The index to look the sub material at
  18259. * @returns The Material if the index has been defined
  18260. */
  18261. getSubMaterial(index: number): Nullable<Material>;
  18262. /**
  18263. * Get the list of active textures for the whole sub materials list.
  18264. * @returns All the textures that will be used during the rendering
  18265. */
  18266. getActiveTextures(): BaseTexture[];
  18267. /**
  18268. * Gets the current class name of the material e.g. "MultiMaterial"
  18269. * Mainly use in serialization.
  18270. * @returns the class name
  18271. */
  18272. getClassName(): string;
  18273. /**
  18274. * Checks if the material is ready to render the requested sub mesh
  18275. * @param mesh Define the mesh the submesh belongs to
  18276. * @param subMesh Define the sub mesh to look readyness for
  18277. * @param useInstances Define whether or not the material is used with instances
  18278. * @returns true if ready, otherwise false
  18279. */
  18280. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18281. /**
  18282. * Clones the current material and its related sub materials
  18283. * @param name Define the name of the newly cloned material
  18284. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18285. * @returns the cloned material
  18286. */
  18287. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18288. /**
  18289. * Serializes the materials into a JSON representation.
  18290. * @returns the JSON representation
  18291. */
  18292. serialize(): any;
  18293. /**
  18294. * Dispose the material and release its associated resources
  18295. * @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)
  18296. * @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)
  18297. */
  18298. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18299. }
  18300. }
  18301. declare module BABYLON {
  18302. /**
  18303. * Base class of materials working in push mode in babylon JS
  18304. * @hidden
  18305. */
  18306. class PushMaterial extends Material {
  18307. protected _activeEffect: Effect;
  18308. protected _normalMatrix: Matrix;
  18309. constructor(name: string, scene: Scene);
  18310. getEffect(): Effect;
  18311. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18312. /**
  18313. * Binds the given world matrix to the active effect
  18314. *
  18315. * @param world the matrix to bind
  18316. */
  18317. bindOnlyWorldMatrix(world: Matrix): void;
  18318. /**
  18319. * Binds the given normal matrix to the active effect
  18320. *
  18321. * @param normalMatrix the matrix to bind
  18322. */
  18323. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18324. bind(world: Matrix, mesh?: Mesh): void;
  18325. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18326. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18327. }
  18328. }
  18329. declare module BABYLON {
  18330. /**
  18331. * Defines the options associated with the creation of a shader material.
  18332. */
  18333. interface IShaderMaterialOptions {
  18334. /**
  18335. * Does the material work in alpha blend mode
  18336. */
  18337. needAlphaBlending: boolean;
  18338. /**
  18339. * Does the material work in alpha test mode
  18340. */
  18341. needAlphaTesting: boolean;
  18342. /**
  18343. * The list of attribute names used in the shader
  18344. */
  18345. attributes: string[];
  18346. /**
  18347. * The list of unifrom names used in the shader
  18348. */
  18349. uniforms: string[];
  18350. /**
  18351. * The list of UBO names used in the shader
  18352. */
  18353. uniformBuffers: string[];
  18354. /**
  18355. * The list of sampler names used in the shader
  18356. */
  18357. samplers: string[];
  18358. /**
  18359. * The list of defines used in the shader
  18360. */
  18361. defines: string[];
  18362. }
  18363. /**
  18364. * 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.
  18365. *
  18366. * This returned material effects how the mesh will look based on the code in the shaders.
  18367. *
  18368. * @see http://doc.babylonjs.com/how_to/shader_material
  18369. */
  18370. class ShaderMaterial extends Material {
  18371. private _shaderPath;
  18372. private _options;
  18373. private _textures;
  18374. private _textureArrays;
  18375. private _floats;
  18376. private _ints;
  18377. private _floatsArrays;
  18378. private _colors3;
  18379. private _colors3Arrays;
  18380. private _colors4;
  18381. private _vectors2;
  18382. private _vectors3;
  18383. private _vectors4;
  18384. private _matrices;
  18385. private _matrices3x3;
  18386. private _matrices2x2;
  18387. private _vectors2Arrays;
  18388. private _vectors3Arrays;
  18389. private _cachedWorldViewMatrix;
  18390. private _renderId;
  18391. /**
  18392. * Instantiate a new shader material.
  18393. * 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.
  18394. * This returned material effects how the mesh will look based on the code in the shaders.
  18395. * @see http://doc.babylonjs.com/how_to/shader_material
  18396. * @param name Define the name of the material in the scene
  18397. * @param scene Define the scene the material belongs to
  18398. * @param shaderPath Defines the route to the shader code in one of three ways:
  18399. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18400. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18401. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18402. * @param options Define the options used to create the shader
  18403. */
  18404. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18405. /**
  18406. * Gets the current class name of the material e.g. "ShaderMaterial"
  18407. * Mainly use in serialization.
  18408. * @returns the class name
  18409. */
  18410. getClassName(): string;
  18411. /**
  18412. * Specifies if the material will require alpha blending
  18413. * @returns a boolean specifying if alpha blending is needed
  18414. */
  18415. needAlphaBlending(): boolean;
  18416. /**
  18417. * Specifies if this material should be rendered in alpha test mode
  18418. * @returns a boolean specifying if an alpha test is needed.
  18419. */
  18420. needAlphaTesting(): boolean;
  18421. private _checkUniform;
  18422. /**
  18423. * Set a texture in the shader.
  18424. * @param name Define the name of the uniform samplers as defined in the shader
  18425. * @param texture Define the texture to bind to this sampler
  18426. * @return the material itself allowing "fluent" like uniform updates
  18427. */
  18428. setTexture(name: string, texture: Texture): ShaderMaterial;
  18429. /**
  18430. * Set a texture array in the shader.
  18431. * @param name Define the name of the uniform sampler array as defined in the shader
  18432. * @param textures Define the list of textures to bind to this sampler
  18433. * @return the material itself allowing "fluent" like uniform updates
  18434. */
  18435. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18436. /**
  18437. * Set a float in the shader.
  18438. * @param name Define the name of the uniform as defined in the shader
  18439. * @param value Define the value to give to the uniform
  18440. * @return the material itself allowing "fluent" like uniform updates
  18441. */
  18442. setFloat(name: string, value: number): ShaderMaterial;
  18443. /**
  18444. * Set a int in the shader.
  18445. * @param name Define the name of the uniform as defined in the shader
  18446. * @param value Define the value to give to the uniform
  18447. * @return the material itself allowing "fluent" like uniform updates
  18448. */
  18449. setInt(name: string, value: number): ShaderMaterial;
  18450. /**
  18451. * Set an array of floats in the shader.
  18452. * @param name Define the name of the uniform as defined in the shader
  18453. * @param value Define the value to give to the uniform
  18454. * @return the material itself allowing "fluent" like uniform updates
  18455. */
  18456. setFloats(name: string, value: number[]): ShaderMaterial;
  18457. /**
  18458. * Set a vec3 in the shader from a Color3.
  18459. * @param name Define the name of the uniform as defined in the shader
  18460. * @param value Define the value to give to the uniform
  18461. * @return the material itself allowing "fluent" like uniform updates
  18462. */
  18463. setColor3(name: string, value: Color3): ShaderMaterial;
  18464. /**
  18465. * Set a vec3 array in the shader from a Color3 array.
  18466. * @param name Define the name of the uniform as defined in the shader
  18467. * @param value Define the value to give to the uniform
  18468. * @return the material itself allowing "fluent" like uniform updates
  18469. */
  18470. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18471. /**
  18472. * Set a vec4 in the shader from a Color4.
  18473. * @param name Define the name of the uniform as defined in the shader
  18474. * @param value Define the value to give to the uniform
  18475. * @return the material itself allowing "fluent" like uniform updates
  18476. */
  18477. setColor4(name: string, value: Color4): ShaderMaterial;
  18478. /**
  18479. * Set a vec2 in the shader from a Vector2.
  18480. * @param name Define the name of the uniform as defined in the shader
  18481. * @param value Define the value to give to the uniform
  18482. * @return the material itself allowing "fluent" like uniform updates
  18483. */
  18484. setVector2(name: string, value: Vector2): ShaderMaterial;
  18485. /**
  18486. * Set a vec3 in the shader from a Vector3.
  18487. * @param name Define the name of the uniform as defined in the shader
  18488. * @param value Define the value to give to the uniform
  18489. * @return the material itself allowing "fluent" like uniform updates
  18490. */
  18491. setVector3(name: string, value: Vector3): ShaderMaterial;
  18492. /**
  18493. * Set a vec4 in the shader from a Vector4.
  18494. * @param name Define the name of the uniform as defined in the shader
  18495. * @param value Define the value to give to the uniform
  18496. * @return the material itself allowing "fluent" like uniform updates
  18497. */
  18498. setVector4(name: string, value: Vector4): ShaderMaterial;
  18499. /**
  18500. * Set a mat4 in the shader from a Matrix.
  18501. * @param name Define the name of the uniform as defined in the shader
  18502. * @param value Define the value to give to the uniform
  18503. * @return the material itself allowing "fluent" like uniform updates
  18504. */
  18505. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18506. /**
  18507. * Set a mat3 in the shader from a Float32Array.
  18508. * @param name Define the name of the uniform as defined in the shader
  18509. * @param value Define the value to give to the uniform
  18510. * @return the material itself allowing "fluent" like uniform updates
  18511. */
  18512. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18513. /**
  18514. * Set a mat2 in the shader from a Float32Array.
  18515. * @param name Define the name of the uniform as defined in the shader
  18516. * @param value Define the value to give to the uniform
  18517. * @return the material itself allowing "fluent" like uniform updates
  18518. */
  18519. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18520. /**
  18521. * Set a vec2 array in the shader from a number array.
  18522. * @param name Define the name of the uniform as defined in the shader
  18523. * @param value Define the value to give to the uniform
  18524. * @return the material itself allowing "fluent" like uniform updates
  18525. */
  18526. setArray2(name: string, value: number[]): ShaderMaterial;
  18527. /**
  18528. * Set a vec3 array in the shader from a number array.
  18529. * @param name Define the name of the uniform as defined in the shader
  18530. * @param value Define the value to give to the uniform
  18531. * @return the material itself allowing "fluent" like uniform updates
  18532. */
  18533. setArray3(name: string, value: number[]): ShaderMaterial;
  18534. private _checkCache;
  18535. /**
  18536. * Checks if the material is ready to render the requested mesh
  18537. * @param mesh Define the mesh to render
  18538. * @param useInstances Define whether or not the material is used with instances
  18539. * @returns true if ready, otherwise false
  18540. */
  18541. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18542. /**
  18543. * Binds the world matrix to the material
  18544. * @param world defines the world transformation matrix
  18545. */
  18546. bindOnlyWorldMatrix(world: Matrix): void;
  18547. /**
  18548. * Binds the material to the mesh
  18549. * @param world defines the world transformation matrix
  18550. * @param mesh defines the mesh to bind the material to
  18551. */
  18552. bind(world: Matrix, mesh?: Mesh): void;
  18553. /**
  18554. * Gets the active textures from the material
  18555. * @returns an array of textures
  18556. */
  18557. getActiveTextures(): BaseTexture[];
  18558. /**
  18559. * Specifies if the material uses a texture
  18560. * @param texture defines the texture to check against the material
  18561. * @returns a boolean specifying if the material uses the texture
  18562. */
  18563. hasTexture(texture: BaseTexture): boolean;
  18564. /**
  18565. * Makes a duplicate of the material, and gives it a new name
  18566. * @param name defines the new name for the duplicated material
  18567. * @returns the cloned material
  18568. */
  18569. clone(name: string): ShaderMaterial;
  18570. /**
  18571. * Disposes the material
  18572. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18573. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18574. */
  18575. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18576. /**
  18577. * Serializes this material in a JSON representation
  18578. * @returns the serialized material object
  18579. */
  18580. serialize(): any;
  18581. /**
  18582. * Creates a shader material from parsed shader material data
  18583. * @param source defines the JSON represnetation of the material
  18584. * @param scene defines the hosting scene
  18585. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18586. * @returns a new material
  18587. */
  18588. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18589. }
  18590. }
  18591. declare module BABYLON {
  18592. /** @hidden */
  18593. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18594. MAINUV1: boolean;
  18595. MAINUV2: boolean;
  18596. DIFFUSE: boolean;
  18597. DIFFUSEDIRECTUV: number;
  18598. AMBIENT: boolean;
  18599. AMBIENTDIRECTUV: number;
  18600. OPACITY: boolean;
  18601. OPACITYDIRECTUV: number;
  18602. OPACITYRGB: boolean;
  18603. REFLECTION: boolean;
  18604. EMISSIVE: boolean;
  18605. EMISSIVEDIRECTUV: number;
  18606. SPECULAR: boolean;
  18607. SPECULARDIRECTUV: number;
  18608. BUMP: boolean;
  18609. BUMPDIRECTUV: number;
  18610. PARALLAX: boolean;
  18611. PARALLAXOCCLUSION: boolean;
  18612. SPECULAROVERALPHA: boolean;
  18613. CLIPPLANE: boolean;
  18614. CLIPPLANE2: boolean;
  18615. CLIPPLANE3: boolean;
  18616. CLIPPLANE4: boolean;
  18617. ALPHATEST: boolean;
  18618. DEPTHPREPASS: boolean;
  18619. ALPHAFROMDIFFUSE: boolean;
  18620. POINTSIZE: boolean;
  18621. FOG: boolean;
  18622. SPECULARTERM: boolean;
  18623. DIFFUSEFRESNEL: boolean;
  18624. OPACITYFRESNEL: boolean;
  18625. REFLECTIONFRESNEL: boolean;
  18626. REFRACTIONFRESNEL: boolean;
  18627. EMISSIVEFRESNEL: boolean;
  18628. FRESNEL: boolean;
  18629. NORMAL: boolean;
  18630. UV1: boolean;
  18631. UV2: boolean;
  18632. VERTEXCOLOR: boolean;
  18633. VERTEXALPHA: boolean;
  18634. NUM_BONE_INFLUENCERS: number;
  18635. BonesPerMesh: number;
  18636. INSTANCES: boolean;
  18637. GLOSSINESS: boolean;
  18638. ROUGHNESS: boolean;
  18639. EMISSIVEASILLUMINATION: boolean;
  18640. LINKEMISSIVEWITHDIFFUSE: boolean;
  18641. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18642. LIGHTMAP: boolean;
  18643. LIGHTMAPDIRECTUV: number;
  18644. OBJECTSPACE_NORMALMAP: boolean;
  18645. USELIGHTMAPASSHADOWMAP: boolean;
  18646. REFLECTIONMAP_3D: boolean;
  18647. REFLECTIONMAP_SPHERICAL: boolean;
  18648. REFLECTIONMAP_PLANAR: boolean;
  18649. REFLECTIONMAP_CUBIC: boolean;
  18650. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18651. REFLECTIONMAP_PROJECTION: boolean;
  18652. REFLECTIONMAP_SKYBOX: boolean;
  18653. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  18654. REFLECTIONMAP_EXPLICIT: boolean;
  18655. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18656. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18657. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18658. INVERTCUBICMAP: boolean;
  18659. LOGARITHMICDEPTH: boolean;
  18660. REFRACTION: boolean;
  18661. REFRACTIONMAP_3D: boolean;
  18662. REFLECTIONOVERALPHA: boolean;
  18663. TWOSIDEDLIGHTING: boolean;
  18664. SHADOWFLOAT: boolean;
  18665. MORPHTARGETS: boolean;
  18666. MORPHTARGETS_NORMAL: boolean;
  18667. MORPHTARGETS_TANGENT: boolean;
  18668. NUM_MORPH_INFLUENCERS: number;
  18669. NONUNIFORMSCALING: boolean;
  18670. PREMULTIPLYALPHA: boolean;
  18671. IMAGEPROCESSING: boolean;
  18672. VIGNETTE: boolean;
  18673. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18674. VIGNETTEBLENDMODEOPAQUE: boolean;
  18675. TONEMAPPING: boolean;
  18676. TONEMAPPING_ACES: boolean;
  18677. CONTRAST: boolean;
  18678. COLORCURVES: boolean;
  18679. COLORGRADING: boolean;
  18680. COLORGRADING3D: boolean;
  18681. SAMPLER3DGREENDEPTH: boolean;
  18682. SAMPLER3DBGRMAP: boolean;
  18683. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18684. /**
  18685. * If the reflection texture on this material is in linear color space
  18686. * @hidden
  18687. */
  18688. IS_REFLECTION_LINEAR: boolean;
  18689. /**
  18690. * If the refraction texture on this material is in linear color space
  18691. * @hidden
  18692. */
  18693. IS_REFRACTION_LINEAR: boolean;
  18694. EXPOSURE: boolean;
  18695. constructor();
  18696. setReflectionMode(modeToEnable: string): void;
  18697. }
  18698. /**
  18699. * This is the default material used in Babylon. It is the best trade off between quality
  18700. * and performances.
  18701. * @see http://doc.babylonjs.com/babylon101/materials
  18702. */
  18703. class StandardMaterial extends PushMaterial {
  18704. private _diffuseTexture;
  18705. /**
  18706. * The basic texture of the material as viewed under a light.
  18707. */
  18708. diffuseTexture: Nullable<BaseTexture>;
  18709. private _ambientTexture;
  18710. /**
  18711. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18712. */
  18713. ambientTexture: Nullable<BaseTexture>;
  18714. private _opacityTexture;
  18715. /**
  18716. * Define the transparency of the material from a texture.
  18717. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18718. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18719. */
  18720. opacityTexture: Nullable<BaseTexture>;
  18721. private _reflectionTexture;
  18722. /**
  18723. * Define the texture used to display the reflection.
  18724. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18725. */
  18726. reflectionTexture: Nullable<BaseTexture>;
  18727. private _emissiveTexture;
  18728. /**
  18729. * Define texture of the material as if self lit.
  18730. * This will be mixed in the final result even in the absence of light.
  18731. */
  18732. emissiveTexture: Nullable<BaseTexture>;
  18733. private _specularTexture;
  18734. /**
  18735. * Define how the color and intensity of the highlight given by the light in the material.
  18736. */
  18737. specularTexture: Nullable<BaseTexture>;
  18738. private _bumpTexture;
  18739. /**
  18740. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18741. * 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.
  18742. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  18743. */
  18744. bumpTexture: Nullable<BaseTexture>;
  18745. private _lightmapTexture;
  18746. /**
  18747. * Complex lighting can be computationally expensive to compute at runtime.
  18748. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18749. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  18750. */
  18751. lightmapTexture: Nullable<BaseTexture>;
  18752. private _refractionTexture;
  18753. /**
  18754. * Define the texture used to display the refraction.
  18755. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18756. */
  18757. refractionTexture: Nullable<BaseTexture>;
  18758. /**
  18759. * The color of the material lit by the environmental background lighting.
  18760. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18761. */
  18762. ambientColor: Color3;
  18763. /**
  18764. * The basic color of the material as viewed under a light.
  18765. */
  18766. diffuseColor: Color3;
  18767. /**
  18768. * Define how the color and intensity of the highlight given by the light in the material.
  18769. */
  18770. specularColor: Color3;
  18771. /**
  18772. * Define the color of the material as if self lit.
  18773. * This will be mixed in the final result even in the absence of light.
  18774. */
  18775. emissiveColor: Color3;
  18776. /**
  18777. * Defines how sharp are the highlights in the material.
  18778. * The bigger the value the sharper giving a more glossy feeling to the result.
  18779. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18780. */
  18781. specularPower: number;
  18782. private _useAlphaFromDiffuseTexture;
  18783. /**
  18784. * Does the transparency come from the diffuse texture alpha channel.
  18785. */
  18786. useAlphaFromDiffuseTexture: boolean;
  18787. private _useEmissiveAsIllumination;
  18788. /**
  18789. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18790. */
  18791. useEmissiveAsIllumination: boolean;
  18792. private _linkEmissiveWithDiffuse;
  18793. /**
  18794. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18795. * the emissive level when the final color is close to one.
  18796. */
  18797. linkEmissiveWithDiffuse: boolean;
  18798. private _useSpecularOverAlpha;
  18799. /**
  18800. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18801. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18802. */
  18803. useSpecularOverAlpha: boolean;
  18804. private _useReflectionOverAlpha;
  18805. /**
  18806. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18807. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18808. */
  18809. useReflectionOverAlpha: boolean;
  18810. private _disableLighting;
  18811. /**
  18812. * Does lights from the scene impacts this material.
  18813. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18814. */
  18815. disableLighting: boolean;
  18816. private _useObjectSpaceNormalMap;
  18817. /**
  18818. * Allows using an object space normal map (instead of tangent space).
  18819. */
  18820. useObjectSpaceNormalMap: boolean;
  18821. private _useParallax;
  18822. /**
  18823. * Is parallax enabled or not.
  18824. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  18825. */
  18826. useParallax: boolean;
  18827. private _useParallaxOcclusion;
  18828. /**
  18829. * Is parallax occlusion enabled or not.
  18830. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18831. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  18832. */
  18833. useParallaxOcclusion: boolean;
  18834. /**
  18835. * 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.
  18836. */
  18837. parallaxScaleBias: number;
  18838. private _roughness;
  18839. /**
  18840. * Helps to define how blurry the reflections should appears in the material.
  18841. */
  18842. roughness: number;
  18843. /**
  18844. * In case of refraction, define the value of the indice of refraction.
  18845. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18846. */
  18847. indexOfRefraction: number;
  18848. /**
  18849. * Invert the refraction texture alongside the y axis.
  18850. * It can be usefull with procedural textures or probe for instance.
  18851. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18852. */
  18853. invertRefractionY: boolean;
  18854. /**
  18855. * Defines the alpha limits in alpha test mode.
  18856. */
  18857. alphaCutOff: number;
  18858. private _useLightmapAsShadowmap;
  18859. /**
  18860. * In case of light mapping, define whether the map contains light or shadow informations.
  18861. */
  18862. useLightmapAsShadowmap: boolean;
  18863. private _diffuseFresnelParameters;
  18864. /**
  18865. * Define the diffuse fresnel parameters of the material.
  18866. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18867. */
  18868. diffuseFresnelParameters: FresnelParameters;
  18869. private _opacityFresnelParameters;
  18870. /**
  18871. * Define the opacity fresnel parameters of the material.
  18872. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18873. */
  18874. opacityFresnelParameters: FresnelParameters;
  18875. private _reflectionFresnelParameters;
  18876. /**
  18877. * Define the reflection fresnel parameters of the material.
  18878. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18879. */
  18880. reflectionFresnelParameters: FresnelParameters;
  18881. private _refractionFresnelParameters;
  18882. /**
  18883. * Define the refraction fresnel parameters of the material.
  18884. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18885. */
  18886. refractionFresnelParameters: FresnelParameters;
  18887. private _emissiveFresnelParameters;
  18888. /**
  18889. * Define the emissive fresnel parameters of the material.
  18890. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18891. */
  18892. emissiveFresnelParameters: FresnelParameters;
  18893. private _useReflectionFresnelFromSpecular;
  18894. /**
  18895. * If true automatically deducts the fresnels values from the material specularity.
  18896. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18897. */
  18898. useReflectionFresnelFromSpecular: boolean;
  18899. private _useGlossinessFromSpecularMapAlpha;
  18900. /**
  18901. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18902. */
  18903. useGlossinessFromSpecularMapAlpha: boolean;
  18904. private _maxSimultaneousLights;
  18905. /**
  18906. * Defines the maximum number of lights that can be used in the material
  18907. */
  18908. maxSimultaneousLights: number;
  18909. private _invertNormalMapX;
  18910. /**
  18911. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18912. */
  18913. invertNormalMapX: boolean;
  18914. private _invertNormalMapY;
  18915. /**
  18916. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  18917. */
  18918. invertNormalMapY: boolean;
  18919. private _twoSidedLighting;
  18920. /**
  18921. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  18922. */
  18923. twoSidedLighting: boolean;
  18924. /**
  18925. * Default configuration related to image processing available in the standard Material.
  18926. */
  18927. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18928. /**
  18929. * Gets the image processing configuration used either in this material.
  18930. */
  18931. /**
  18932. * Sets the Default image processing configuration used either in the this material.
  18933. *
  18934. * If sets to null, the scene one is in use.
  18935. */
  18936. imageProcessingConfiguration: ImageProcessingConfiguration;
  18937. /**
  18938. * Keep track of the image processing observer to allow dispose and replace.
  18939. */
  18940. private _imageProcessingObserver;
  18941. /**
  18942. * Attaches a new image processing configuration to the Standard Material.
  18943. * @param configuration
  18944. */
  18945. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18946. /**
  18947. * Gets wether the color curves effect is enabled.
  18948. */
  18949. /**
  18950. * Sets wether the color curves effect is enabled.
  18951. */
  18952. cameraColorCurvesEnabled: boolean;
  18953. /**
  18954. * Gets wether the color grading effect is enabled.
  18955. */
  18956. /**
  18957. * Gets wether the color grading effect is enabled.
  18958. */
  18959. cameraColorGradingEnabled: boolean;
  18960. /**
  18961. * Gets wether tonemapping is enabled or not.
  18962. */
  18963. /**
  18964. * Sets wether tonemapping is enabled or not
  18965. */
  18966. cameraToneMappingEnabled: boolean;
  18967. /**
  18968. * The camera exposure used on this material.
  18969. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  18970. * This corresponds to a photographic exposure.
  18971. */
  18972. /**
  18973. * The camera exposure used on this material.
  18974. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  18975. * This corresponds to a photographic exposure.
  18976. */
  18977. cameraExposure: number;
  18978. /**
  18979. * Gets The camera contrast used on this material.
  18980. */
  18981. /**
  18982. * Sets The camera contrast used on this material.
  18983. */
  18984. cameraContrast: number;
  18985. /**
  18986. * Gets the Color Grading 2D Lookup Texture.
  18987. */
  18988. /**
  18989. * Sets the Color Grading 2D Lookup Texture.
  18990. */
  18991. cameraColorGradingTexture: Nullable<BaseTexture>;
  18992. /**
  18993. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  18994. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  18995. * 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;
  18996. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  18997. */
  18998. /**
  18999. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19000. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19001. * 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;
  19002. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19003. */
  19004. cameraColorCurves: Nullable<ColorCurves>;
  19005. /**
  19006. * Custom callback helping to override the default shader used in the material.
  19007. */
  19008. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19009. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19010. protected _worldViewProjectionMatrix: Matrix;
  19011. protected _globalAmbientColor: Color3;
  19012. protected _useLogarithmicDepth: boolean;
  19013. /**
  19014. * Instantiates a new standard material.
  19015. * This is the default material used in Babylon. It is the best trade off between quality
  19016. * and performances.
  19017. * @see http://doc.babylonjs.com/babylon101/materials
  19018. * @param name Define the name of the material in the scene
  19019. * @param scene Define the scene the material belong to
  19020. */
  19021. constructor(name: string, scene: Scene);
  19022. /**
  19023. * Gets a boolean indicating that current material needs to register RTT
  19024. */
  19025. readonly hasRenderTargetTextures: boolean;
  19026. /**
  19027. * Gets the current class name of the material e.g. "StandardMaterial"
  19028. * Mainly use in serialization.
  19029. * @returns the class name
  19030. */
  19031. getClassName(): string;
  19032. /**
  19033. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19034. * You can try switching to logarithmic depth.
  19035. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19036. */
  19037. useLogarithmicDepth: boolean;
  19038. /**
  19039. * Specifies if the material will require alpha blending
  19040. * @returns a boolean specifying if alpha blending is needed
  19041. */
  19042. needAlphaBlending(): boolean;
  19043. /**
  19044. * Specifies if this material should be rendered in alpha test mode
  19045. * @returns a boolean specifying if an alpha test is needed.
  19046. */
  19047. needAlphaTesting(): boolean;
  19048. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19049. /**
  19050. * Get the texture used for alpha test purpose.
  19051. * @returns the diffuse texture in case of the standard material.
  19052. */
  19053. getAlphaTestTexture(): Nullable<BaseTexture>;
  19054. /**
  19055. * Get if the submesh is ready to be used and all its information available.
  19056. * Child classes can use it to update shaders
  19057. * @param mesh defines the mesh to check
  19058. * @param subMesh defines which submesh to check
  19059. * @param useInstances specifies that instances should be used
  19060. * @returns a boolean indicating that the submesh is ready or not
  19061. */
  19062. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19063. /**
  19064. * Builds the material UBO layouts.
  19065. * Used internally during the effect preparation.
  19066. */
  19067. buildUniformLayout(): void;
  19068. /**
  19069. * Unbinds the material from the mesh
  19070. */
  19071. unbind(): void;
  19072. /**
  19073. * Binds the submesh to this material by preparing the effect and shader to draw
  19074. * @param world defines the world transformation matrix
  19075. * @param mesh defines the mesh containing the submesh
  19076. * @param subMesh defines the submesh to bind the material to
  19077. */
  19078. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19079. /**
  19080. * Get the list of animatables in the material.
  19081. * @returns the list of animatables object used in the material
  19082. */
  19083. getAnimatables(): IAnimatable[];
  19084. /**
  19085. * Gets the active textures from the material
  19086. * @returns an array of textures
  19087. */
  19088. getActiveTextures(): BaseTexture[];
  19089. /**
  19090. * Specifies if the material uses a texture
  19091. * @param texture defines the texture to check against the material
  19092. * @returns a boolean specifying if the material uses the texture
  19093. */
  19094. hasTexture(texture: BaseTexture): boolean;
  19095. /**
  19096. * Disposes the material
  19097. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19098. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19099. */
  19100. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19101. /**
  19102. * Makes a duplicate of the material, and gives it a new name
  19103. * @param name defines the new name for the duplicated material
  19104. * @returns the cloned material
  19105. */
  19106. clone(name: string): StandardMaterial;
  19107. /**
  19108. * Serializes this material in a JSON representation
  19109. * @returns the serialized material object
  19110. */
  19111. serialize(): any;
  19112. /**
  19113. * Creates a standard material from parsed material data
  19114. * @param source defines the JSON represnetation of the material
  19115. * @param scene defines the hosting scene
  19116. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19117. * @returns a new material
  19118. */
  19119. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19120. private static _DiffuseTextureEnabled;
  19121. /**
  19122. * Are diffuse textures enabled in the application.
  19123. */
  19124. static DiffuseTextureEnabled: boolean;
  19125. private static _AmbientTextureEnabled;
  19126. /**
  19127. * Are ambient textures enabled in the application.
  19128. */
  19129. static AmbientTextureEnabled: boolean;
  19130. private static _OpacityTextureEnabled;
  19131. /**
  19132. * Are opacity textures enabled in the application.
  19133. */
  19134. static OpacityTextureEnabled: boolean;
  19135. private static _ReflectionTextureEnabled;
  19136. /**
  19137. * Are reflection textures enabled in the application.
  19138. */
  19139. static ReflectionTextureEnabled: boolean;
  19140. private static _EmissiveTextureEnabled;
  19141. /**
  19142. * Are emissive textures enabled in the application.
  19143. */
  19144. static EmissiveTextureEnabled: boolean;
  19145. private static _SpecularTextureEnabled;
  19146. /**
  19147. * Are specular textures enabled in the application.
  19148. */
  19149. static SpecularTextureEnabled: boolean;
  19150. private static _BumpTextureEnabled;
  19151. /**
  19152. * Are bump textures enabled in the application.
  19153. */
  19154. static BumpTextureEnabled: boolean;
  19155. private static _LightmapTextureEnabled;
  19156. /**
  19157. * Are lightmap textures enabled in the application.
  19158. */
  19159. static LightmapTextureEnabled: boolean;
  19160. private static _RefractionTextureEnabled;
  19161. /**
  19162. * Are refraction textures enabled in the application.
  19163. */
  19164. static RefractionTextureEnabled: boolean;
  19165. private static _ColorGradingTextureEnabled;
  19166. /**
  19167. * Are color grading textures enabled in the application.
  19168. */
  19169. static ColorGradingTextureEnabled: boolean;
  19170. private static _FresnelEnabled;
  19171. /**
  19172. * Are fresnels enabled in the application.
  19173. */
  19174. static FresnelEnabled: boolean;
  19175. }
  19176. }
  19177. declare module BABYLON {
  19178. /**
  19179. * Uniform buffer objects.
  19180. *
  19181. * Handles blocks of uniform on the GPU.
  19182. *
  19183. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19184. *
  19185. * For more information, please refer to :
  19186. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19187. */
  19188. class UniformBuffer {
  19189. private _engine;
  19190. private _buffer;
  19191. private _data;
  19192. private _bufferData;
  19193. private _dynamic?;
  19194. private _uniformLocations;
  19195. private _uniformSizes;
  19196. private _uniformLocationPointer;
  19197. private _needSync;
  19198. private _noUBO;
  19199. private _currentEffect;
  19200. private static _MAX_UNIFORM_SIZE;
  19201. private static _tempBuffer;
  19202. /**
  19203. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19204. * This is dynamic to allow compat with webgl 1 and 2.
  19205. * You will need to pass the name of the uniform as well as the value.
  19206. */
  19207. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19208. /**
  19209. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19210. * This is dynamic to allow compat with webgl 1 and 2.
  19211. * You will need to pass the name of the uniform as well as the value.
  19212. */
  19213. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19214. /**
  19215. * Lambda to Update a single float in a uniform buffer.
  19216. * This is dynamic to allow compat with webgl 1 and 2.
  19217. * You will need to pass the name of the uniform as well as the value.
  19218. */
  19219. updateFloat: (name: string, x: number) => void;
  19220. /**
  19221. * Lambda to Update a vec2 of float in a uniform buffer.
  19222. * This is dynamic to allow compat with webgl 1 and 2.
  19223. * You will need to pass the name of the uniform as well as the value.
  19224. */
  19225. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19226. /**
  19227. * Lambda to Update a vec3 of float in a uniform buffer.
  19228. * This is dynamic to allow compat with webgl 1 and 2.
  19229. * You will need to pass the name of the uniform as well as the value.
  19230. */
  19231. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19232. /**
  19233. * Lambda to Update a vec4 of float in a uniform buffer.
  19234. * This is dynamic to allow compat with webgl 1 and 2.
  19235. * You will need to pass the name of the uniform as well as the value.
  19236. */
  19237. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19238. /**
  19239. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19240. * This is dynamic to allow compat with webgl 1 and 2.
  19241. * You will need to pass the name of the uniform as well as the value.
  19242. */
  19243. updateMatrix: (name: string, mat: Matrix) => void;
  19244. /**
  19245. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19246. * This is dynamic to allow compat with webgl 1 and 2.
  19247. * You will need to pass the name of the uniform as well as the value.
  19248. */
  19249. updateVector3: (name: string, vector: Vector3) => void;
  19250. /**
  19251. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19252. * This is dynamic to allow compat with webgl 1 and 2.
  19253. * You will need to pass the name of the uniform as well as the value.
  19254. */
  19255. updateVector4: (name: string, vector: Vector4) => void;
  19256. /**
  19257. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19258. * This is dynamic to allow compat with webgl 1 and 2.
  19259. * You will need to pass the name of the uniform as well as the value.
  19260. */
  19261. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19262. /**
  19263. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19264. * This is dynamic to allow compat with webgl 1 and 2.
  19265. * You will need to pass the name of the uniform as well as the value.
  19266. */
  19267. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19268. /**
  19269. * Instantiates a new Uniform buffer objects.
  19270. *
  19271. * Handles blocks of uniform on the GPU.
  19272. *
  19273. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19274. *
  19275. * For more information, please refer to :
  19276. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19277. * @param engine Define the engine the buffer is associated with
  19278. * @param data Define the data contained in the buffer
  19279. * @param dynamic Define if the buffer is updatable
  19280. */
  19281. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19282. /**
  19283. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19284. * or just falling back on setUniformXXX calls.
  19285. */
  19286. readonly useUbo: boolean;
  19287. /**
  19288. * Indicates if the WebGL underlying uniform buffer is in sync
  19289. * with the javascript cache data.
  19290. */
  19291. readonly isSync: boolean;
  19292. /**
  19293. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19294. * Also, a dynamic UniformBuffer will disable cache verification and always
  19295. * update the underlying WebGL uniform buffer to the GPU.
  19296. * @returns if Dynamic, otherwise false
  19297. */
  19298. isDynamic(): boolean;
  19299. /**
  19300. * The data cache on JS side.
  19301. * @returns the underlying data as a float array
  19302. */
  19303. getData(): Float32Array;
  19304. /**
  19305. * The underlying WebGL Uniform buffer.
  19306. * @returns the webgl buffer
  19307. */
  19308. getBuffer(): Nullable<WebGLBuffer>;
  19309. /**
  19310. * std140 layout specifies how to align data within an UBO structure.
  19311. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19312. * for specs.
  19313. */
  19314. private _fillAlignment;
  19315. /**
  19316. * Adds an uniform in the buffer.
  19317. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19318. * for the layout to be correct !
  19319. * @param name Name of the uniform, as used in the uniform block in the shader.
  19320. * @param size Data size, or data directly.
  19321. */
  19322. addUniform(name: string, size: number | number[]): void;
  19323. /**
  19324. * Adds a Matrix 4x4 to the uniform buffer.
  19325. * @param name Name of the uniform, as used in the uniform block in the shader.
  19326. * @param mat A 4x4 matrix.
  19327. */
  19328. addMatrix(name: string, mat: Matrix): void;
  19329. /**
  19330. * Adds a vec2 to the uniform buffer.
  19331. * @param name Name of the uniform, as used in the uniform block in the shader.
  19332. * @param x Define the x component value of the vec2
  19333. * @param y Define the y component value of the vec2
  19334. */
  19335. addFloat2(name: string, x: number, y: number): void;
  19336. /**
  19337. * Adds a vec3 to the uniform buffer.
  19338. * @param name Name of the uniform, as used in the uniform block in the shader.
  19339. * @param x Define the x component value of the vec3
  19340. * @param y Define the y component value of the vec3
  19341. * @param z Define the z component value of the vec3
  19342. */
  19343. addFloat3(name: string, x: number, y: number, z: number): void;
  19344. /**
  19345. * Adds a vec3 to the uniform buffer.
  19346. * @param name Name of the uniform, as used in the uniform block in the shader.
  19347. * @param color Define the vec3 from a Color
  19348. */
  19349. addColor3(name: string, color: Color3): void;
  19350. /**
  19351. * Adds a vec4 to the uniform buffer.
  19352. * @param name Name of the uniform, as used in the uniform block in the shader.
  19353. * @param color Define the rgb components from a Color
  19354. * @param alpha Define the a component of the vec4
  19355. */
  19356. addColor4(name: string, color: Color3, alpha: number): void;
  19357. /**
  19358. * Adds a vec3 to the uniform buffer.
  19359. * @param name Name of the uniform, as used in the uniform block in the shader.
  19360. * @param vector Define the vec3 components from a Vector
  19361. */
  19362. addVector3(name: string, vector: Vector3): void;
  19363. /**
  19364. * Adds a Matrix 3x3 to the uniform buffer.
  19365. * @param name Name of the uniform, as used in the uniform block in the shader.
  19366. */
  19367. addMatrix3x3(name: string): void;
  19368. /**
  19369. * Adds a Matrix 2x2 to the uniform buffer.
  19370. * @param name Name of the uniform, as used in the uniform block in the shader.
  19371. */
  19372. addMatrix2x2(name: string): void;
  19373. /**
  19374. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19375. */
  19376. create(): void;
  19377. /** @hidden */
  19378. _rebuild(): void;
  19379. /**
  19380. * Updates the WebGL Uniform Buffer on the GPU.
  19381. * If the `dynamic` flag is set to true, no cache comparison is done.
  19382. * Otherwise, the buffer will be updated only if the cache differs.
  19383. */
  19384. update(): void;
  19385. /**
  19386. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19387. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19388. * @param data Define the flattened data
  19389. * @param size Define the size of the data.
  19390. */
  19391. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19392. private _updateMatrix3x3ForUniform;
  19393. private _updateMatrix3x3ForEffect;
  19394. private _updateMatrix2x2ForEffect;
  19395. private _updateMatrix2x2ForUniform;
  19396. private _updateFloatForEffect;
  19397. private _updateFloatForUniform;
  19398. private _updateFloat2ForEffect;
  19399. private _updateFloat2ForUniform;
  19400. private _updateFloat3ForEffect;
  19401. private _updateFloat3ForUniform;
  19402. private _updateFloat4ForEffect;
  19403. private _updateFloat4ForUniform;
  19404. private _updateMatrixForEffect;
  19405. private _updateMatrixForUniform;
  19406. private _updateVector3ForEffect;
  19407. private _updateVector3ForUniform;
  19408. private _updateVector4ForEffect;
  19409. private _updateVector4ForUniform;
  19410. private _updateColor3ForEffect;
  19411. private _updateColor3ForUniform;
  19412. private _updateColor4ForEffect;
  19413. private _updateColor4ForUniform;
  19414. /**
  19415. * Sets a sampler uniform on the effect.
  19416. * @param name Define the name of the sampler.
  19417. * @param texture Define the texture to set in the sampler
  19418. */
  19419. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19420. /**
  19421. * Directly updates the value of the uniform in the cache AND on the GPU.
  19422. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19423. * @param data Define the flattened data
  19424. */
  19425. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19426. /**
  19427. * Binds this uniform buffer to an effect.
  19428. * @param effect Define the effect to bind the buffer to
  19429. * @param name Name of the uniform block in the shader.
  19430. */
  19431. bindToEffect(effect: Effect, name: string): void;
  19432. /**
  19433. * Disposes the uniform buffer.
  19434. */
  19435. dispose(): void;
  19436. }
  19437. }
  19438. declare module BABYLON {
  19439. /**
  19440. * Scalar computation library
  19441. */
  19442. class Scalar {
  19443. /**
  19444. * Two pi constants convenient for computation.
  19445. */
  19446. static TwoPi: number;
  19447. /**
  19448. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19449. * @param a number
  19450. * @param b number
  19451. * @param epsilon (default = 1.401298E-45)
  19452. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19453. */
  19454. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  19455. /**
  19456. * Returns a string : the upper case translation of the number i to hexadecimal.
  19457. * @param i number
  19458. * @returns the upper case translation of the number i to hexadecimal.
  19459. */
  19460. static ToHex(i: number): string;
  19461. /**
  19462. * Returns -1 if value is negative and +1 is value is positive.
  19463. * @param value the value
  19464. * @returns the value itself if it's equal to zero.
  19465. */
  19466. static Sign(value: number): number;
  19467. /**
  19468. * Returns the value itself if it's between min and max.
  19469. * Returns min if the value is lower than min.
  19470. * Returns max if the value is greater than max.
  19471. * @param value the value to clmap
  19472. * @param min the min value to clamp to (default: 0)
  19473. * @param max the max value to clamp to (default: 1)
  19474. * @returns the clamped value
  19475. */
  19476. static Clamp(value: number, min?: number, max?: number): number;
  19477. /**
  19478. * the log2 of value.
  19479. * @param value the value to compute log2 of
  19480. * @returns the log2 of value.
  19481. */
  19482. static Log2(value: number): number;
  19483. /**
  19484. * Loops the value, so that it is never larger than length and never smaller than 0.
  19485. *
  19486. * This is similar to the modulo operator but it works with floating point numbers.
  19487. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  19488. * With t = 5 and length = 2.5, the result would be 0.0.
  19489. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  19490. * @param value the value
  19491. * @param length the length
  19492. * @returns the looped value
  19493. */
  19494. static Repeat(value: number, length: number): number;
  19495. /**
  19496. * Normalize the value between 0.0 and 1.0 using min and max values
  19497. * @param value value to normalize
  19498. * @param min max to normalize between
  19499. * @param max min to normalize between
  19500. * @returns the normalized value
  19501. */
  19502. static Normalize(value: number, min: number, max: number): number;
  19503. /**
  19504. * Denormalize the value from 0.0 and 1.0 using min and max values
  19505. * @param normalized value to denormalize
  19506. * @param min max to denormalize between
  19507. * @param max min to denormalize between
  19508. * @returns the denormalized value
  19509. */
  19510. static Denormalize(normalized: number, min: number, max: number): number;
  19511. /**
  19512. * Calculates the shortest difference between two given angles given in degrees.
  19513. * @param current current angle in degrees
  19514. * @param target target angle in degrees
  19515. * @returns the delta
  19516. */
  19517. static DeltaAngle(current: number, target: number): number;
  19518. /**
  19519. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  19520. * @param tx value
  19521. * @param length length
  19522. * @returns The returned value will move back and forth between 0 and length
  19523. */
  19524. static PingPong(tx: number, length: number): number;
  19525. /**
  19526. * Interpolates between min and max with smoothing at the limits.
  19527. *
  19528. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  19529. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  19530. * @param from from
  19531. * @param to to
  19532. * @param tx value
  19533. * @returns the smooth stepped value
  19534. */
  19535. static SmoothStep(from: number, to: number, tx: number): number;
  19536. /**
  19537. * Moves a value current towards target.
  19538. *
  19539. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  19540. * Negative values of maxDelta pushes the value away from target.
  19541. * @param current current value
  19542. * @param target target value
  19543. * @param maxDelta max distance to move
  19544. * @returns resulting value
  19545. */
  19546. static MoveTowards(current: number, target: number, maxDelta: number): number;
  19547. /**
  19548. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19549. *
  19550. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  19551. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  19552. * @param current current value
  19553. * @param target target value
  19554. * @param maxDelta max distance to move
  19555. * @returns resulting angle
  19556. */
  19557. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  19558. /**
  19559. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  19560. * @param start start value
  19561. * @param end target value
  19562. * @param amount amount to lerp between
  19563. * @returns the lerped value
  19564. */
  19565. static Lerp(start: number, end: number, amount: number): number;
  19566. /**
  19567. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19568. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  19569. * @param start start value
  19570. * @param end target value
  19571. * @param amount amount to lerp between
  19572. * @returns the lerped value
  19573. */
  19574. static LerpAngle(start: number, end: number, amount: number): number;
  19575. /**
  19576. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  19577. * @param a start value
  19578. * @param b target value
  19579. * @param value value between a and b
  19580. * @returns the inverseLerp value
  19581. */
  19582. static InverseLerp(a: number, b: number, value: number): number;
  19583. /**
  19584. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  19585. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  19586. * @param value1 spline value
  19587. * @param tangent1 spline value
  19588. * @param value2 spline value
  19589. * @param tangent2 spline value
  19590. * @param amount input value
  19591. * @returns hermite result
  19592. */
  19593. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  19594. /**
  19595. * Returns a random float number between and min and max values
  19596. * @param min min value of random
  19597. * @param max max value of random
  19598. * @returns random value
  19599. */
  19600. static RandomRange(min: number, max: number): number;
  19601. /**
  19602. * This function returns percentage of a number in a given range.
  19603. *
  19604. * RangeToPercent(40,20,60) will return 0.5 (50%)
  19605. * RangeToPercent(34,0,100) will return 0.34 (34%)
  19606. * @param number to convert to percentage
  19607. * @param min min range
  19608. * @param max max range
  19609. * @returns the percentage
  19610. */
  19611. static RangeToPercent(number: number, min: number, max: number): number;
  19612. /**
  19613. * This function returns number that corresponds to the percentage in a given range.
  19614. *
  19615. * PercentToRange(0.34,0,100) will return 34.
  19616. * @param percent to convert to number
  19617. * @param min min range
  19618. * @param max max range
  19619. * @returns the number
  19620. */
  19621. static PercentToRange(percent: number, min: number, max: number): number;
  19622. /**
  19623. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  19624. * @param angle The angle to normalize in radian.
  19625. * @return The converted angle.
  19626. */
  19627. static NormalizeRadians(angle: number): number;
  19628. }
  19629. }
  19630. declare module BABYLON {
  19631. /**
  19632. * Constant used to convert a value to gamma space
  19633. * @ignorenaming
  19634. */
  19635. const ToGammaSpace: number;
  19636. /**
  19637. * Constant used to convert a value to linear space
  19638. * @ignorenaming
  19639. */
  19640. const ToLinearSpace = 2.2;
  19641. /**
  19642. * Constant used to define the minimal number value in Babylon.js
  19643. * @ignorenaming
  19644. */
  19645. const Epsilon = 0.001;
  19646. /**
  19647. * Class used to hold a RBG color
  19648. */
  19649. class Color3 {
  19650. /**
  19651. * Defines the red component (between 0 and 1, default is 0)
  19652. */
  19653. r: number;
  19654. /**
  19655. * Defines the green component (between 0 and 1, default is 0)
  19656. */
  19657. g: number;
  19658. /**
  19659. * Defines the blue component (between 0 and 1, default is 0)
  19660. */
  19661. b: number;
  19662. /**
  19663. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  19664. * @param r defines the red component (between 0 and 1, default is 0)
  19665. * @param g defines the green component (between 0 and 1, default is 0)
  19666. * @param b defines the blue component (between 0 and 1, default is 0)
  19667. */
  19668. constructor(
  19669. /**
  19670. * Defines the red component (between 0 and 1, default is 0)
  19671. */
  19672. r?: number,
  19673. /**
  19674. * Defines the green component (between 0 and 1, default is 0)
  19675. */
  19676. g?: number,
  19677. /**
  19678. * Defines the blue component (between 0 and 1, default is 0)
  19679. */
  19680. b?: number);
  19681. /**
  19682. * Creates a string with the Color3 current values
  19683. * @returns the string representation of the Color3 object
  19684. */
  19685. toString(): string;
  19686. /**
  19687. * Returns the string "Color3"
  19688. * @returns "Color3"
  19689. */
  19690. getClassName(): string;
  19691. /**
  19692. * Compute the Color3 hash code
  19693. * @returns an unique number that can be used to hash Color3 objects
  19694. */
  19695. getHashCode(): number;
  19696. /**
  19697. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  19698. * @param array defines the array where to store the r,g,b components
  19699. * @param index defines an optional index in the target array to define where to start storing values
  19700. * @returns the current Color3 object
  19701. */
  19702. toArray(array: FloatArray, index?: number): Color3;
  19703. /**
  19704. * Returns a new Color4 object from the current Color3 and the given alpha
  19705. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  19706. * @returns a new Color4 object
  19707. */
  19708. toColor4(alpha?: number): Color4;
  19709. /**
  19710. * Returns a new array populated with 3 numeric elements : red, green and blue values
  19711. * @returns the new array
  19712. */
  19713. asArray(): number[];
  19714. /**
  19715. * Returns the luminance value
  19716. * @returns a float value
  19717. */
  19718. toLuminance(): number;
  19719. /**
  19720. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  19721. * @param otherColor defines the second operand
  19722. * @returns the new Color3 object
  19723. */
  19724. multiply(otherColor: Color3): Color3;
  19725. /**
  19726. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  19727. * @param otherColor defines the second operand
  19728. * @param result defines the Color3 object where to store the result
  19729. * @returns the current Color3
  19730. */
  19731. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  19732. /**
  19733. * Determines equality between Color3 objects
  19734. * @param otherColor defines the second operand
  19735. * @returns true if the rgb values are equal to the given ones
  19736. */
  19737. equals(otherColor: Color3): boolean;
  19738. /**
  19739. * Determines equality between the current Color3 object and a set of r,b,g values
  19740. * @param r defines the red component to check
  19741. * @param g defines the green component to check
  19742. * @param b defines the blue component to check
  19743. * @returns true if the rgb values are equal to the given ones
  19744. */
  19745. equalsFloats(r: number, g: number, b: number): boolean;
  19746. /**
  19747. * Multiplies in place each rgb value by scale
  19748. * @param scale defines the scaling factor
  19749. * @returns the updated Color3
  19750. */
  19751. scale(scale: number): Color3;
  19752. /**
  19753. * Multiplies the rgb values by scale and stores the result into "result"
  19754. * @param scale defines the scaling factor
  19755. * @param result defines the Color3 object where to store the result
  19756. * @returns the unmodified current Color3
  19757. */
  19758. scaleToRef(scale: number, result: Color3): Color3;
  19759. /**
  19760. * Scale the current Color3 values by a factor and add the result to a given Color3
  19761. * @param scale defines the scale factor
  19762. * @param result defines color to store the result into
  19763. * @returns the unmodified current Color3
  19764. */
  19765. scaleAndAddToRef(scale: number, result: Color3): Color3;
  19766. /**
  19767. * Clamps the rgb values by the min and max values and stores the result into "result"
  19768. * @param min defines minimum clamping value (default is 0)
  19769. * @param max defines maximum clamping value (default is 1)
  19770. * @param result defines color to store the result into
  19771. * @returns the original Color3
  19772. */
  19773. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  19774. /**
  19775. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  19776. * @param otherColor defines the second operand
  19777. * @returns the new Color3
  19778. */
  19779. add(otherColor: Color3): Color3;
  19780. /**
  19781. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  19782. * @param otherColor defines the second operand
  19783. * @param result defines Color3 object to store the result into
  19784. * @returns the unmodified current Color3
  19785. */
  19786. addToRef(otherColor: Color3, result: Color3): Color3;
  19787. /**
  19788. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  19789. * @param otherColor defines the second operand
  19790. * @returns the new Color3
  19791. */
  19792. subtract(otherColor: Color3): Color3;
  19793. /**
  19794. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  19795. * @param otherColor defines the second operand
  19796. * @param result defines Color3 object to store the result into
  19797. * @returns the unmodified current Color3
  19798. */
  19799. subtractToRef(otherColor: Color3, result: Color3): Color3;
  19800. /**
  19801. * Copy the current object
  19802. * @returns a new Color3 copied the current one
  19803. */
  19804. clone(): Color3;
  19805. /**
  19806. * Copies the rgb values from the source in the current Color3
  19807. * @param source defines the source Color3 object
  19808. * @returns the updated Color3 object
  19809. */
  19810. copyFrom(source: Color3): Color3;
  19811. /**
  19812. * Updates the Color3 rgb values from the given floats
  19813. * @param r defines the red component to read from
  19814. * @param g defines the green component to read from
  19815. * @param b defines the blue component to read from
  19816. * @returns the current Color3 object
  19817. */
  19818. copyFromFloats(r: number, g: number, b: number): Color3;
  19819. /**
  19820. * Updates the Color3 rgb values from the given floats
  19821. * @param r defines the red component to read from
  19822. * @param g defines the green component to read from
  19823. * @param b defines the blue component to read from
  19824. * @returns the current Color3 object
  19825. */
  19826. set(r: number, g: number, b: number): Color3;
  19827. /**
  19828. * Compute the Color3 hexadecimal code as a string
  19829. * @returns a string containing the hexadecimal representation of the Color3 object
  19830. */
  19831. toHexString(): string;
  19832. /**
  19833. * Computes a new Color3 converted from the current one to linear space
  19834. * @returns a new Color3 object
  19835. */
  19836. toLinearSpace(): Color3;
  19837. /**
  19838. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  19839. * @param convertedColor defines the Color3 object where to store the linear space version
  19840. * @returns the unmodified Color3
  19841. */
  19842. toLinearSpaceToRef(convertedColor: Color3): Color3;
  19843. /**
  19844. * Computes a new Color3 converted from the current one to gamma space
  19845. * @returns a new Color3 object
  19846. */
  19847. toGammaSpace(): Color3;
  19848. /**
  19849. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  19850. * @param convertedColor defines the Color3 object where to store the gamma space version
  19851. * @returns the unmodified Color3
  19852. */
  19853. toGammaSpaceToRef(convertedColor: Color3): Color3;
  19854. /**
  19855. * Creates a new Color3 from the string containing valid hexadecimal values
  19856. * @param hex defines a string containing valid hexadecimal values
  19857. * @returns a new Color3 object
  19858. */
  19859. static FromHexString(hex: string): Color3;
  19860. /**
  19861. * Creates a new Vector3 from the starting index of the given array
  19862. * @param array defines the source array
  19863. * @param offset defines an offset in the source array
  19864. * @returns a new Color3 object
  19865. */
  19866. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  19867. /**
  19868. * Creates a new Color3 from integer values (< 256)
  19869. * @param r defines the red component to read from (value between 0 and 255)
  19870. * @param g defines the green component to read from (value between 0 and 255)
  19871. * @param b defines the blue component to read from (value between 0 and 255)
  19872. * @returns a new Color3 object
  19873. */
  19874. static FromInts(r: number, g: number, b: number): Color3;
  19875. /**
  19876. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  19877. * @param start defines the start Color3 value
  19878. * @param end defines the end Color3 value
  19879. * @param amount defines the gradient value between start and end
  19880. * @returns a new Color3 object
  19881. */
  19882. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  19883. /**
  19884. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  19885. * @param left defines the start value
  19886. * @param right defines the end value
  19887. * @param amount defines the gradient factor
  19888. * @param result defines the Color3 object where to store the result
  19889. */
  19890. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  19891. /**
  19892. * Returns a Color3 value containing a red color
  19893. * @returns a new Color3 object
  19894. */
  19895. static Red(): Color3;
  19896. /**
  19897. * Returns a Color3 value containing a green color
  19898. * @returns a new Color3 object
  19899. */
  19900. static Green(): Color3;
  19901. /**
  19902. * Returns a Color3 value containing a blue color
  19903. * @returns a new Color3 object
  19904. */
  19905. static Blue(): Color3;
  19906. /**
  19907. * Returns a Color3 value containing a black color
  19908. * @returns a new Color3 object
  19909. */
  19910. static Black(): Color3;
  19911. /**
  19912. * Returns a Color3 value containing a white color
  19913. * @returns a new Color3 object
  19914. */
  19915. static White(): Color3;
  19916. /**
  19917. * Returns a Color3 value containing a purple color
  19918. * @returns a new Color3 object
  19919. */
  19920. static Purple(): Color3;
  19921. /**
  19922. * Returns a Color3 value containing a magenta color
  19923. * @returns a new Color3 object
  19924. */
  19925. static Magenta(): Color3;
  19926. /**
  19927. * Returns a Color3 value containing a yellow color
  19928. * @returns a new Color3 object
  19929. */
  19930. static Yellow(): Color3;
  19931. /**
  19932. * Returns a Color3 value containing a gray color
  19933. * @returns a new Color3 object
  19934. */
  19935. static Gray(): Color3;
  19936. /**
  19937. * Returns a Color3 value containing a teal color
  19938. * @returns a new Color3 object
  19939. */
  19940. static Teal(): Color3;
  19941. /**
  19942. * Returns a Color3 value containing a random color
  19943. * @returns a new Color3 object
  19944. */
  19945. static Random(): Color3;
  19946. }
  19947. /**
  19948. * Class used to hold a RBGA color
  19949. */
  19950. class Color4 {
  19951. /**
  19952. * Defines the red component (between 0 and 1, default is 0)
  19953. */
  19954. r: number;
  19955. /**
  19956. * Defines the green component (between 0 and 1, default is 0)
  19957. */
  19958. g: number;
  19959. /**
  19960. * Defines the blue component (between 0 and 1, default is 0)
  19961. */
  19962. b: number;
  19963. /**
  19964. * Defines the alpha component (between 0 and 1, default is 1)
  19965. */
  19966. a: number;
  19967. /**
  19968. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  19969. * @param r defines the red component (between 0 and 1, default is 0)
  19970. * @param g defines the green component (between 0 and 1, default is 0)
  19971. * @param b defines the blue component (between 0 and 1, default is 0)
  19972. * @param a defines the alpha component (between 0 and 1, default is 1)
  19973. */
  19974. constructor(
  19975. /**
  19976. * Defines the red component (between 0 and 1, default is 0)
  19977. */
  19978. r?: number,
  19979. /**
  19980. * Defines the green component (between 0 and 1, default is 0)
  19981. */
  19982. g?: number,
  19983. /**
  19984. * Defines the blue component (between 0 and 1, default is 0)
  19985. */
  19986. b?: number,
  19987. /**
  19988. * Defines the alpha component (between 0 and 1, default is 1)
  19989. */
  19990. a?: number);
  19991. /**
  19992. * Adds in place the given Color4 values to the current Color4 object
  19993. * @param right defines the second operand
  19994. * @returns the current updated Color4 object
  19995. */
  19996. addInPlace(right: Color4): Color4;
  19997. /**
  19998. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  19999. * @returns the new array
  20000. */
  20001. asArray(): number[];
  20002. /**
  20003. * Stores from the starting index in the given array the Color4 successive values
  20004. * @param array defines the array where to store the r,g,b components
  20005. * @param index defines an optional index in the target array to define where to start storing values
  20006. * @returns the current Color4 object
  20007. */
  20008. toArray(array: number[], index?: number): Color4;
  20009. /**
  20010. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20011. * @param right defines the second operand
  20012. * @returns a new Color4 object
  20013. */
  20014. add(right: Color4): Color4;
  20015. /**
  20016. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20017. * @param right defines the second operand
  20018. * @returns a new Color4 object
  20019. */
  20020. subtract(right: Color4): Color4;
  20021. /**
  20022. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20023. * @param right defines the second operand
  20024. * @param result defines the Color4 object where to store the result
  20025. * @returns the current Color4 object
  20026. */
  20027. subtractToRef(right: Color4, result: Color4): Color4;
  20028. /**
  20029. * Creates a new Color4 with the current Color4 values multiplied by scale
  20030. * @param scale defines the scaling factor to apply
  20031. * @returns a new Color4 object
  20032. */
  20033. scale(scale: number): Color4;
  20034. /**
  20035. * Multiplies the current Color4 values by scale and stores the result in "result"
  20036. * @param scale defines the scaling factor to apply
  20037. * @param result defines the Color4 object where to store the result
  20038. * @returns the current unmodified Color4
  20039. */
  20040. scaleToRef(scale: number, result: Color4): Color4;
  20041. /**
  20042. * Scale the current Color4 values by a factor and add the result to a given Color4
  20043. * @param scale defines the scale factor
  20044. * @param result defines the Color4 object where to store the result
  20045. * @returns the unmodified current Color4
  20046. */
  20047. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20048. /**
  20049. * Clamps the rgb values by the min and max values and stores the result into "result"
  20050. * @param min defines minimum clamping value (default is 0)
  20051. * @param max defines maximum clamping value (default is 1)
  20052. * @param result defines color to store the result into.
  20053. * @returns the cuurent Color4
  20054. */
  20055. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20056. /**
  20057. * Multipy an Color4 value by another and return a new Color4 object
  20058. * @param color defines the Color4 value to multiply by
  20059. * @returns a new Color4 object
  20060. */
  20061. multiply(color: Color4): Color4;
  20062. /**
  20063. * Multipy a Color4 value by another and push the result in a reference value
  20064. * @param color defines the Color4 value to multiply by
  20065. * @param result defines the Color4 to fill the result in
  20066. * @returns the result Color4
  20067. */
  20068. multiplyToRef(color: Color4, result: Color4): Color4;
  20069. /**
  20070. * Creates a string with the Color4 current values
  20071. * @returns the string representation of the Color4 object
  20072. */
  20073. toString(): string;
  20074. /**
  20075. * Returns the string "Color4"
  20076. * @returns "Color4"
  20077. */
  20078. getClassName(): string;
  20079. /**
  20080. * Compute the Color4 hash code
  20081. * @returns an unique number that can be used to hash Color4 objects
  20082. */
  20083. getHashCode(): number;
  20084. /**
  20085. * Creates a new Color4 copied from the current one
  20086. * @returns a new Color4 object
  20087. */
  20088. clone(): Color4;
  20089. /**
  20090. * Copies the given Color4 values into the current one
  20091. * @param source defines the source Color4 object
  20092. * @returns the current updated Color4 object
  20093. */
  20094. copyFrom(source: Color4): Color4;
  20095. /**
  20096. * Copies the given float values into the current one
  20097. * @param r defines the red component to read from
  20098. * @param g defines the green component to read from
  20099. * @param b defines the blue component to read from
  20100. * @param a defines the alpha component to read from
  20101. * @returns the current updated Color4 object
  20102. */
  20103. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20104. /**
  20105. * Copies the given float values into the current one
  20106. * @param r defines the red component to read from
  20107. * @param g defines the green component to read from
  20108. * @param b defines the blue component to read from
  20109. * @param a defines the alpha component to read from
  20110. * @returns the current updated Color4 object
  20111. */
  20112. set(r: number, g: number, b: number, a: number): Color4;
  20113. /**
  20114. * Compute the Color4 hexadecimal code as a string
  20115. * @returns a string containing the hexadecimal representation of the Color4 object
  20116. */
  20117. toHexString(): string;
  20118. /**
  20119. * Computes a new Color4 converted from the current one to linear space
  20120. * @returns a new Color4 object
  20121. */
  20122. toLinearSpace(): Color4;
  20123. /**
  20124. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20125. * @param convertedColor defines the Color4 object where to store the linear space version
  20126. * @returns the unmodified Color4
  20127. */
  20128. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20129. /**
  20130. * Computes a new Color4 converted from the current one to gamma space
  20131. * @returns a new Color4 object
  20132. */
  20133. toGammaSpace(): Color4;
  20134. /**
  20135. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20136. * @param convertedColor defines the Color4 object where to store the gamma space version
  20137. * @returns the unmodified Color4
  20138. */
  20139. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20140. /**
  20141. * Creates a new Color4 from the string containing valid hexadecimal values
  20142. * @param hex defines a string containing valid hexadecimal values
  20143. * @returns a new Color4 object
  20144. */
  20145. static FromHexString(hex: string): Color4;
  20146. /**
  20147. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20148. * @param left defines the start value
  20149. * @param right defines the end value
  20150. * @param amount defines the gradient factor
  20151. * @returns a new Color4 object
  20152. */
  20153. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  20154. /**
  20155. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20156. * @param left defines the start value
  20157. * @param right defines the end value
  20158. * @param amount defines the gradient factor
  20159. * @param result defines the Color4 object where to store data
  20160. */
  20161. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  20162. /**
  20163. * Creates a new Color4 from a Color3 and an alpha value
  20164. * @param color3 defines the source Color3 to read from
  20165. * @param alpha defines the alpha component (1.0 by default)
  20166. * @returns a new Color4 object
  20167. */
  20168. static FromColor3(color3: Color3, alpha?: number): Color4;
  20169. /**
  20170. * Creates a new Color4 from the starting index element of the given array
  20171. * @param array defines the source array to read from
  20172. * @param offset defines the offset in the source array
  20173. * @returns a new Color4 object
  20174. */
  20175. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  20176. /**
  20177. * Creates a new Color3 from integer values (< 256)
  20178. * @param r defines the red component to read from (value between 0 and 255)
  20179. * @param g defines the green component to read from (value between 0 and 255)
  20180. * @param b defines the blue component to read from (value between 0 and 255)
  20181. * @param a defines the alpha component to read from (value between 0 and 255)
  20182. * @returns a new Color3 object
  20183. */
  20184. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20185. /**
  20186. * Check the content of a given array and convert it to an array containing RGBA data
  20187. * If the original array was already containing count * 4 values then it is returned directly
  20188. * @param colors defines the array to check
  20189. * @param count defines the number of RGBA data to expect
  20190. * @returns an array containing count * 4 values (RGBA)
  20191. */
  20192. static CheckColors4(colors: number[], count: number): number[];
  20193. }
  20194. /**
  20195. * Class representing a vector containing 2 coordinates
  20196. */
  20197. class Vector2 {
  20198. /** defines the first coordinate */
  20199. x: number;
  20200. /** defines the second coordinate */
  20201. y: number;
  20202. /**
  20203. * Creates a new Vector2 from the given x and y coordinates
  20204. * @param x defines the first coordinate
  20205. * @param y defines the second coordinate
  20206. */
  20207. constructor(
  20208. /** defines the first coordinate */
  20209. x?: number,
  20210. /** defines the second coordinate */
  20211. y?: number);
  20212. /**
  20213. * Gets a string with the Vector2 coordinates
  20214. * @returns a string with the Vector2 coordinates
  20215. */
  20216. toString(): string;
  20217. /**
  20218. * Gets class name
  20219. * @returns the string "Vector2"
  20220. */
  20221. getClassName(): string;
  20222. /**
  20223. * Gets current vector hash code
  20224. * @returns the Vector2 hash code as a number
  20225. */
  20226. getHashCode(): number;
  20227. /**
  20228. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20229. * @param array defines the source array
  20230. * @param index defines the offset in source array
  20231. * @returns the current Vector2
  20232. */
  20233. toArray(array: FloatArray, index?: number): Vector2;
  20234. /**
  20235. * Copy the current vector to an array
  20236. * @returns a new array with 2 elements: the Vector2 coordinates.
  20237. */
  20238. asArray(): number[];
  20239. /**
  20240. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20241. * @param source defines the source Vector2
  20242. * @returns the current updated Vector2
  20243. */
  20244. copyFrom(source: Vector2): Vector2;
  20245. /**
  20246. * Sets the Vector2 coordinates with the given floats
  20247. * @param x defines the first coordinate
  20248. * @param y defines the second coordinate
  20249. * @returns the current updated Vector2
  20250. */
  20251. copyFromFloats(x: number, y: number): Vector2;
  20252. /**
  20253. * Sets the Vector2 coordinates with the given floats
  20254. * @param x defines the first coordinate
  20255. * @param y defines the second coordinate
  20256. * @returns the current updated Vector2
  20257. */
  20258. set(x: number, y: number): Vector2;
  20259. /**
  20260. * Add another vector with the current one
  20261. * @param otherVector defines the other vector
  20262. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20263. */
  20264. add(otherVector: Vector2): Vector2;
  20265. /**
  20266. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20267. * @param otherVector defines the other vector
  20268. * @param result defines the target vector
  20269. * @returns the unmodified current Vector2
  20270. */
  20271. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  20272. /**
  20273. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20274. * @param otherVector defines the other vector
  20275. * @returns the current updated Vector2
  20276. */
  20277. addInPlace(otherVector: Vector2): Vector2;
  20278. /**
  20279. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20280. * @param otherVector defines the other vector
  20281. * @returns a new Vector2
  20282. */
  20283. addVector3(otherVector: Vector3): Vector2;
  20284. /**
  20285. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20286. * @param otherVector defines the other vector
  20287. * @returns a new Vector2
  20288. */
  20289. subtract(otherVector: Vector2): Vector2;
  20290. /**
  20291. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20292. * @param otherVector defines the other vector
  20293. * @param result defines the target vector
  20294. * @returns the unmodified current Vector2
  20295. */
  20296. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  20297. /**
  20298. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20299. * @param otherVector defines the other vector
  20300. * @returns the current updated Vector2
  20301. */
  20302. subtractInPlace(otherVector: Vector2): Vector2;
  20303. /**
  20304. * Multiplies in place the current Vector2 coordinates by the given ones
  20305. * @param otherVector defines the other vector
  20306. * @returns the current updated Vector2
  20307. */
  20308. multiplyInPlace(otherVector: Vector2): Vector2;
  20309. /**
  20310. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20311. * @param otherVector defines the other vector
  20312. * @returns a new Vector2
  20313. */
  20314. multiply(otherVector: Vector2): Vector2;
  20315. /**
  20316. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20317. * @param otherVector defines the other vector
  20318. * @param result defines the target vector
  20319. * @returns the unmodified current Vector2
  20320. */
  20321. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  20322. /**
  20323. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20324. * @param x defines the first coordinate
  20325. * @param y defines the second coordinate
  20326. * @returns a new Vector2
  20327. */
  20328. multiplyByFloats(x: number, y: number): Vector2;
  20329. /**
  20330. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20331. * @param otherVector defines the other vector
  20332. * @returns a new Vector2
  20333. */
  20334. divide(otherVector: Vector2): Vector2;
  20335. /**
  20336. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20337. * @param otherVector defines the other vector
  20338. * @param result defines the target vector
  20339. * @returns the unmodified current Vector2
  20340. */
  20341. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  20342. /**
  20343. * Divides the current Vector2 coordinates by the given ones
  20344. * @param otherVector defines the other vector
  20345. * @returns the current updated Vector2
  20346. */
  20347. divideInPlace(otherVector: Vector2): Vector2;
  20348. /**
  20349. * Gets a new Vector2 with current Vector2 negated coordinates
  20350. * @returns a new Vector2
  20351. */
  20352. negate(): Vector2;
  20353. /**
  20354. * Multiply the Vector2 coordinates by scale
  20355. * @param scale defines the scaling factor
  20356. * @returns the current updated Vector2
  20357. */
  20358. scaleInPlace(scale: number): Vector2;
  20359. /**
  20360. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20361. * @param scale defines the scaling factor
  20362. * @returns a new Vector2
  20363. */
  20364. scale(scale: number): Vector2;
  20365. /**
  20366. * Scale the current Vector2 values by a factor to a given Vector2
  20367. * @param scale defines the scale factor
  20368. * @param result defines the Vector2 object where to store the result
  20369. * @returns the unmodified current Vector2
  20370. */
  20371. scaleToRef(scale: number, result: Vector2): Vector2;
  20372. /**
  20373. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20374. * @param scale defines the scale factor
  20375. * @param result defines the Vector2 object where to store the result
  20376. * @returns the unmodified current Vector2
  20377. */
  20378. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20379. /**
  20380. * Gets a boolean if two vectors are equals
  20381. * @param otherVector defines the other vector
  20382. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20383. */
  20384. equals(otherVector: Vector2): boolean;
  20385. /**
  20386. * Gets a boolean if two vectors are equals (using an epsilon value)
  20387. * @param otherVector defines the other vector
  20388. * @param epsilon defines the minimal distance to consider equality
  20389. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20390. */
  20391. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  20392. /**
  20393. * Gets a new Vector2 from current Vector2 floored values
  20394. * @returns a new Vector2
  20395. */
  20396. floor(): Vector2;
  20397. /**
  20398. * Gets a new Vector2 from current Vector2 floored values
  20399. * @returns a new Vector2
  20400. */
  20401. fract(): Vector2;
  20402. /**
  20403. * Gets the length of the vector
  20404. * @returns the vector length (float)
  20405. */
  20406. length(): number;
  20407. /**
  20408. * Gets the vector squared length
  20409. * @returns the vector squared length (float)
  20410. */
  20411. lengthSquared(): number;
  20412. /**
  20413. * Normalize the vector
  20414. * @returns the current updated Vector2
  20415. */
  20416. normalize(): Vector2;
  20417. /**
  20418. * Gets a new Vector2 copied from the Vector2
  20419. * @returns a new Vector2
  20420. */
  20421. clone(): Vector2;
  20422. /**
  20423. * Gets a new Vector2(0, 0)
  20424. * @returns a new Vector2
  20425. */
  20426. static Zero(): Vector2;
  20427. /**
  20428. * Gets a new Vector2(1, 1)
  20429. * @returns a new Vector2
  20430. */
  20431. static One(): Vector2;
  20432. /**
  20433. * Gets a new Vector2 set from the given index element of the given array
  20434. * @param array defines the data source
  20435. * @param offset defines the offset in the data source
  20436. * @returns a new Vector2
  20437. */
  20438. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  20439. /**
  20440. * Sets "result" from the given index element of the given array
  20441. * @param array defines the data source
  20442. * @param offset defines the offset in the data source
  20443. * @param result defines the target vector
  20444. */
  20445. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  20446. /**
  20447. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  20448. * @param value1 defines 1st point of control
  20449. * @param value2 defines 2nd point of control
  20450. * @param value3 defines 3rd point of control
  20451. * @param value4 defines 4th point of control
  20452. * @param amount defines the interpolation factor
  20453. * @returns a new Vector2
  20454. */
  20455. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  20456. /**
  20457. * 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".
  20458. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  20459. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  20460. * @param value defines the value to clamp
  20461. * @param min defines the lower limit
  20462. * @param max defines the upper limit
  20463. * @returns a new Vector2
  20464. */
  20465. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  20466. /**
  20467. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  20468. * @param value1 defines the 1st control point
  20469. * @param tangent1 defines the outgoing tangent
  20470. * @param value2 defines the 2nd control point
  20471. * @param tangent2 defines the incoming tangent
  20472. * @param amount defines the interpolation factor
  20473. * @returns a new Vector2
  20474. */
  20475. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  20476. /**
  20477. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  20478. * @param start defines the start vector
  20479. * @param end defines the end vector
  20480. * @param amount defines the interpolation factor
  20481. * @returns a new Vector2
  20482. */
  20483. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  20484. /**
  20485. * Gets the dot product of the vector "left" and the vector "right"
  20486. * @param left defines first vector
  20487. * @param right defines second vector
  20488. * @returns the dot product (float)
  20489. */
  20490. static Dot(left: Vector2, right: Vector2): number;
  20491. /**
  20492. * Returns a new Vector2 equal to the normalized given vector
  20493. * @param vector defines the vector to normalize
  20494. * @returns a new Vector2
  20495. */
  20496. static Normalize(vector: Vector2): Vector2;
  20497. /**
  20498. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  20499. * @param left defines 1st vector
  20500. * @param right defines 2nd vector
  20501. * @returns a new Vector2
  20502. */
  20503. static Minimize(left: Vector2, right: Vector2): Vector2;
  20504. /**
  20505. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  20506. * @param left defines 1st vector
  20507. * @param right defines 2nd vector
  20508. * @returns a new Vector2
  20509. */
  20510. static Maximize(left: Vector2, right: Vector2): Vector2;
  20511. /**
  20512. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  20513. * @param vector defines the vector to transform
  20514. * @param transformation defines the matrix to apply
  20515. * @returns a new Vector2
  20516. */
  20517. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  20518. /**
  20519. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  20520. * @param vector defines the vector to transform
  20521. * @param transformation defines the matrix to apply
  20522. * @param result defines the target vector
  20523. */
  20524. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  20525. /**
  20526. * Determines if a given vector is included in a triangle
  20527. * @param p defines the vector to test
  20528. * @param p0 defines 1st triangle point
  20529. * @param p1 defines 2nd triangle point
  20530. * @param p2 defines 3rd triangle point
  20531. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  20532. */
  20533. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  20534. /**
  20535. * Gets the distance between the vectors "value1" and "value2"
  20536. * @param value1 defines first vector
  20537. * @param value2 defines second vector
  20538. * @returns the distance between vectors
  20539. */
  20540. static Distance(value1: Vector2, value2: Vector2): number;
  20541. /**
  20542. * Returns the squared distance between the vectors "value1" and "value2"
  20543. * @param value1 defines first vector
  20544. * @param value2 defines second vector
  20545. * @returns the squared distance between vectors
  20546. */
  20547. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  20548. /**
  20549. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  20550. * @param value1 defines first vector
  20551. * @param value2 defines second vector
  20552. * @returns a new Vector2
  20553. */
  20554. static Center(value1: Vector2, value2: Vector2): Vector2;
  20555. /**
  20556. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  20557. * @param p defines the middle point
  20558. * @param segA defines one point of the segment
  20559. * @param segB defines the other point of the segment
  20560. * @returns the shortest distance
  20561. */
  20562. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  20563. }
  20564. /**
  20565. * Classed used to store (x,y,z) vector representation
  20566. * A Vector3 is the main object used in 3D geometry
  20567. * It can represent etiher the coordinates of a point the space, either a direction
  20568. * Reminder: Babylon.js uses a left handed forward facing system
  20569. */
  20570. class Vector3 {
  20571. /**
  20572. * Defines the first coordinates (on X axis)
  20573. */
  20574. x: number;
  20575. /**
  20576. * Defines the second coordinates (on Y axis)
  20577. */
  20578. y: number;
  20579. /**
  20580. * Defines the third coordinates (on Z axis)
  20581. */
  20582. z: number;
  20583. /**
  20584. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  20585. * @param x defines the first coordinates (on X axis)
  20586. * @param y defines the second coordinates (on Y axis)
  20587. * @param z defines the third coordinates (on Z axis)
  20588. */
  20589. constructor(
  20590. /**
  20591. * Defines the first coordinates (on X axis)
  20592. */
  20593. x?: number,
  20594. /**
  20595. * Defines the second coordinates (on Y axis)
  20596. */
  20597. y?: number,
  20598. /**
  20599. * Defines the third coordinates (on Z axis)
  20600. */
  20601. z?: number);
  20602. /**
  20603. * Creates a string representation of the Vector3
  20604. * @returns a string with the Vector3 coordinates.
  20605. */
  20606. toString(): string;
  20607. /**
  20608. * Gets the class name
  20609. * @returns the string "Vector3"
  20610. */
  20611. getClassName(): string;
  20612. /**
  20613. * Creates the Vector3 hash code
  20614. * @returns a number which tends to be unique between Vector3 instances
  20615. */
  20616. getHashCode(): number;
  20617. /**
  20618. * Creates an array containing three elements : the coordinates of the Vector3
  20619. * @returns a new array of numbers
  20620. */
  20621. asArray(): number[];
  20622. /**
  20623. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  20624. * @param array defines the destination array
  20625. * @param index defines the offset in the destination array
  20626. * @returns the current Vector3
  20627. */
  20628. toArray(array: FloatArray, index?: number): Vector3;
  20629. /**
  20630. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  20631. * @returns a new Quaternion object, computed from the Vector3 coordinates
  20632. */
  20633. toQuaternion(): Quaternion;
  20634. /**
  20635. * Adds the given vector to the current Vector3
  20636. * @param otherVector defines the second operand
  20637. * @returns the current updated Vector3
  20638. */
  20639. addInPlace(otherVector: Vector3): Vector3;
  20640. /**
  20641. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  20642. * @param otherVector defines the second operand
  20643. * @returns the resulting Vector3
  20644. */
  20645. add(otherVector: Vector3): Vector3;
  20646. /**
  20647. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  20648. * @param otherVector defines the second operand
  20649. * @param result defines the Vector3 object where to store the result
  20650. * @returns the current Vector3
  20651. */
  20652. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  20653. /**
  20654. * Subtract the given vector from the current Vector3
  20655. * @param otherVector defines the second operand
  20656. * @returns the current updated Vector3
  20657. */
  20658. subtractInPlace(otherVector: Vector3): Vector3;
  20659. /**
  20660. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  20661. * @param otherVector defines the second operand
  20662. * @returns the resulting Vector3
  20663. */
  20664. subtract(otherVector: Vector3): Vector3;
  20665. /**
  20666. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  20667. * @param otherVector defines the second operand
  20668. * @param result defines the Vector3 object where to store the result
  20669. * @returns the current Vector3
  20670. */
  20671. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  20672. /**
  20673. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  20674. * @param x defines the x coordinate of the operand
  20675. * @param y defines the y coordinate of the operand
  20676. * @param z defines the z coordinate of the operand
  20677. * @returns the resulting Vector3
  20678. */
  20679. subtractFromFloats(x: number, y: number, z: number): Vector3;
  20680. /**
  20681. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  20682. * @param x defines the x coordinate of the operand
  20683. * @param y defines the y coordinate of the operand
  20684. * @param z defines the z coordinate of the operand
  20685. * @param result defines the Vector3 object where to store the result
  20686. * @returns the current Vector3
  20687. */
  20688. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  20689. /**
  20690. * Gets a new Vector3 set with the current Vector3 negated coordinates
  20691. * @returns a new Vector3
  20692. */
  20693. negate(): Vector3;
  20694. /**
  20695. * Multiplies the Vector3 coordinates by the float "scale"
  20696. * @param scale defines the multiplier factor
  20697. * @returns the current updated Vector3
  20698. */
  20699. scaleInPlace(scale: number): Vector3;
  20700. /**
  20701. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  20702. * @param scale defines the multiplier factor
  20703. * @returns a new Vector3
  20704. */
  20705. scale(scale: number): Vector3;
  20706. /**
  20707. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  20708. * @param scale defines the multiplier factor
  20709. * @param result defines the Vector3 object where to store the result
  20710. * @returns the current Vector3
  20711. */
  20712. scaleToRef(scale: number, result: Vector3): Vector3;
  20713. /**
  20714. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  20715. * @param scale defines the scale factor
  20716. * @param result defines the Vector3 object where to store the result
  20717. * @returns the unmodified current Vector3
  20718. */
  20719. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  20720. /**
  20721. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  20722. * @param otherVector defines the second operand
  20723. * @returns true if both vectors are equals
  20724. */
  20725. equals(otherVector: Vector3): boolean;
  20726. /**
  20727. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  20728. * @param otherVector defines the second operand
  20729. * @param epsilon defines the minimal distance to define values as equals
  20730. * @returns true if both vectors are distant less than epsilon
  20731. */
  20732. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  20733. /**
  20734. * Returns true if the current Vector3 coordinates equals the given floats
  20735. * @param x defines the x coordinate of the operand
  20736. * @param y defines the y coordinate of the operand
  20737. * @param z defines the z coordinate of the operand
  20738. * @returns true if both vectors are equals
  20739. */
  20740. equalsToFloats(x: number, y: number, z: number): boolean;
  20741. /**
  20742. * Multiplies the current Vector3 coordinates by the given ones
  20743. * @param otherVector defines the second operand
  20744. * @returns the current updated Vector3
  20745. */
  20746. multiplyInPlace(otherVector: Vector3): Vector3;
  20747. /**
  20748. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  20749. * @param otherVector defines the second operand
  20750. * @returns the new Vector3
  20751. */
  20752. multiply(otherVector: Vector3): Vector3;
  20753. /**
  20754. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  20755. * @param otherVector defines the second operand
  20756. * @param result defines the Vector3 object where to store the result
  20757. * @returns the current Vector3
  20758. */
  20759. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  20760. /**
  20761. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  20762. * @param x defines the x coordinate of the operand
  20763. * @param y defines the y coordinate of the operand
  20764. * @param z defines the z coordinate of the operand
  20765. * @returns the new Vector3
  20766. */
  20767. multiplyByFloats(x: number, y: number, z: number): Vector3;
  20768. /**
  20769. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  20770. * @param otherVector defines the second operand
  20771. * @returns the new Vector3
  20772. */
  20773. divide(otherVector: Vector3): Vector3;
  20774. /**
  20775. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  20776. * @param otherVector defines the second operand
  20777. * @param result defines the Vector3 object where to store the result
  20778. * @returns the current Vector3
  20779. */
  20780. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  20781. /**
  20782. * Divides the current Vector3 coordinates by the given ones.
  20783. * @param otherVector defines the second operand
  20784. * @returns the current updated Vector3
  20785. */
  20786. divideInPlace(otherVector: Vector3): Vector3;
  20787. /**
  20788. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  20789. * @param other defines the second operand
  20790. * @returns the current updated Vector3
  20791. */
  20792. minimizeInPlace(other: Vector3): Vector3;
  20793. /**
  20794. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  20795. * @param other defines the second operand
  20796. * @returns the current updated Vector3
  20797. */
  20798. maximizeInPlace(other: Vector3): Vector3;
  20799. /**
  20800. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  20801. * @param x defines the x coordinate of the operand
  20802. * @param y defines the y coordinate of the operand
  20803. * @param z defines the z coordinate of the operand
  20804. * @returns the current updated Vector3
  20805. */
  20806. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20807. /**
  20808. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  20809. * @param x defines the x coordinate of the operand
  20810. * @param y defines the y coordinate of the operand
  20811. * @param z defines the z coordinate of the operand
  20812. * @returns the current updated Vector3
  20813. */
  20814. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20815. /**
  20816. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  20817. */
  20818. readonly isNonUniform: boolean;
  20819. /**
  20820. * Gets a new Vector3 from current Vector3 floored values
  20821. * @returns a new Vector3
  20822. */
  20823. floor(): Vector3;
  20824. /**
  20825. * Gets a new Vector3 from current Vector3 floored values
  20826. * @returns a new Vector3
  20827. */
  20828. fract(): Vector3;
  20829. /**
  20830. * Gets the length of the Vector3
  20831. * @returns the length of the Vecto3
  20832. */
  20833. length(): number;
  20834. /**
  20835. * Gets the squared length of the Vector3
  20836. * @returns squared length of the Vector3
  20837. */
  20838. lengthSquared(): number;
  20839. /**
  20840. * Normalize the current Vector3.
  20841. * Please note that this is an in place operation.
  20842. * @returns the current updated Vector3
  20843. */
  20844. normalize(): Vector3;
  20845. /**
  20846. * Normalize the current Vector3 to a new vector
  20847. * @returns the new Vector3
  20848. */
  20849. normalizeToNew(): Vector3;
  20850. /**
  20851. * Normalize the current Vector3 to the reference
  20852. * @param reference define the Vector3 to update
  20853. * @returns the updated Vector3
  20854. */
  20855. normalizeToRef(reference: Vector3): Vector3;
  20856. /**
  20857. * Creates a new Vector3 copied from the current Vector3
  20858. * @returns the new Vector3
  20859. */
  20860. clone(): Vector3;
  20861. /**
  20862. * Copies the given vector coordinates to the current Vector3 ones
  20863. * @param source defines the source Vector3
  20864. * @returns the current updated Vector3
  20865. */
  20866. copyFrom(source: Vector3): Vector3;
  20867. /**
  20868. * Copies the given floats to the current Vector3 coordinates
  20869. * @param x defines the x coordinate of the operand
  20870. * @param y defines the y coordinate of the operand
  20871. * @param z defines the z coordinate of the operand
  20872. * @returns the current updated Vector3
  20873. */
  20874. copyFromFloats(x: number, y: number, z: number): Vector3;
  20875. /**
  20876. * Copies the given floats to the current Vector3 coordinates
  20877. * @param x defines the x coordinate of the operand
  20878. * @param y defines the y coordinate of the operand
  20879. * @param z defines the z coordinate of the operand
  20880. * @returns the current updated Vector3
  20881. */
  20882. set(x: number, y: number, z: number): Vector3;
  20883. /**
  20884. * Get the clip factor between two vectors
  20885. * @param vector0 defines the first operand
  20886. * @param vector1 defines the second operand
  20887. * @param axis defines the axis to use
  20888. * @param size defines the size along the axis
  20889. * @returns the clip factor
  20890. */
  20891. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  20892. /**
  20893. * Get angle between two vectors
  20894. * @param vector0 angle between vector0 and vector1
  20895. * @param vector1 angle between vector0 and vector1
  20896. * @param normal direction of the normal
  20897. * @return the angle between vector0 and vector1
  20898. */
  20899. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  20900. /**
  20901. * Returns a new Vector3 set from the index "offset" of the given array
  20902. * @param array defines the source array
  20903. * @param offset defines the offset in the source array
  20904. * @returns the new Vector3
  20905. */
  20906. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  20907. /**
  20908. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  20909. * This function is deprecated. Use FromArray instead
  20910. * @param array defines the source array
  20911. * @param offset defines the offset in the source array
  20912. * @returns the new Vector3
  20913. */
  20914. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  20915. /**
  20916. * Sets the given vector "result" with the element values from the index "offset" of the given array
  20917. * @param array defines the source array
  20918. * @param offset defines the offset in the source array
  20919. * @param result defines the Vector3 where to store the result
  20920. */
  20921. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  20922. /**
  20923. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  20924. * This function is deprecated. Use FromArrayToRef instead.
  20925. * @param array defines the source array
  20926. * @param offset defines the offset in the source array
  20927. * @param result defines the Vector3 where to store the result
  20928. */
  20929. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  20930. /**
  20931. * Sets the given vector "result" with the given floats.
  20932. * @param x defines the x coordinate of the source
  20933. * @param y defines the y coordinate of the source
  20934. * @param z defines the z coordinate of the source
  20935. * @param result defines the Vector3 where to store the result
  20936. */
  20937. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  20938. /**
  20939. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  20940. * @returns a new empty Vector3
  20941. */
  20942. static Zero(): Vector3;
  20943. /**
  20944. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  20945. * @returns a new unit Vector3
  20946. */
  20947. static One(): Vector3;
  20948. /**
  20949. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  20950. * @returns a new up Vector3
  20951. */
  20952. static Up(): Vector3;
  20953. /**
  20954. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  20955. * @returns a new down Vector3
  20956. */
  20957. static Down(): Vector3;
  20958. /**
  20959. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  20960. * @returns a new forward Vector3
  20961. */
  20962. static Forward(): Vector3;
  20963. /**
  20964. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  20965. * @returns a new forward Vector3
  20966. */
  20967. static Backward(): Vector3;
  20968. /**
  20969. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  20970. * @returns a new right Vector3
  20971. */
  20972. static Right(): Vector3;
  20973. /**
  20974. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  20975. * @returns a new left Vector3
  20976. */
  20977. static Left(): Vector3;
  20978. /**
  20979. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  20980. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  20981. * @param vector defines the Vector3 to transform
  20982. * @param transformation defines the transformation matrix
  20983. * @returns the transformed Vector3
  20984. */
  20985. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  20986. /**
  20987. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  20988. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  20989. * @param vector defines the Vector3 to transform
  20990. * @param transformation defines the transformation matrix
  20991. * @param result defines the Vector3 where to store the result
  20992. */
  20993. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  20994. /**
  20995. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  20996. * This method computes tranformed coordinates only, not transformed direction vectors
  20997. * @param x define the x coordinate of the source vector
  20998. * @param y define the y coordinate of the source vector
  20999. * @param z define the z coordinate of the source vector
  21000. * @param transformation defines the transformation matrix
  21001. * @param result defines the Vector3 where to store the result
  21002. */
  21003. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  21004. /**
  21005. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21006. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21007. * @param vector defines the Vector3 to transform
  21008. * @param transformation defines the transformation matrix
  21009. * @returns the new Vector3
  21010. */
  21011. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  21012. /**
  21013. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21014. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21015. * @param vector defines the Vector3 to transform
  21016. * @param transformation defines the transformation matrix
  21017. * @param result defines the Vector3 where to store the result
  21018. */
  21019. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  21020. /**
  21021. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21022. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21023. * @param x define the x coordinate of the source vector
  21024. * @param y define the y coordinate of the source vector
  21025. * @param z define the z coordinate of the source vector
  21026. * @param transformation defines the transformation matrix
  21027. * @param result defines the Vector3 where to store the result
  21028. */
  21029. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  21030. /**
  21031. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21032. * @param value1 defines the first control point
  21033. * @param value2 defines the second control point
  21034. * @param value3 defines the third control point
  21035. * @param value4 defines the fourth control point
  21036. * @param amount defines the amount on the spline to use
  21037. * @returns the new Vector3
  21038. */
  21039. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  21040. /**
  21041. * 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"
  21042. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21043. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21044. * @param value defines the current value
  21045. * @param min defines the lower range value
  21046. * @param max defines the upper range value
  21047. * @returns the new Vector3
  21048. */
  21049. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  21050. /**
  21051. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21052. * @param value1 defines the first control point
  21053. * @param tangent1 defines the first tangent vector
  21054. * @param value2 defines the second control point
  21055. * @param tangent2 defines the second tangent vector
  21056. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21057. * @returns the new Vector3
  21058. */
  21059. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  21060. /**
  21061. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21062. * @param start defines the start value
  21063. * @param end defines the end value
  21064. * @param amount max defines amount between both (between 0 and 1)
  21065. * @returns the new Vector3
  21066. */
  21067. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  21068. /**
  21069. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21070. * @param start defines the start value
  21071. * @param end defines the end value
  21072. * @param amount max defines amount between both (between 0 and 1)
  21073. * @param result defines the Vector3 where to store the result
  21074. */
  21075. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  21076. /**
  21077. * Returns the dot product (float) between the vectors "left" and "right"
  21078. * @param left defines the left operand
  21079. * @param right defines the right operand
  21080. * @returns the dot product
  21081. */
  21082. static Dot(left: Vector3, right: Vector3): number;
  21083. /**
  21084. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21085. * The cross product is then orthogonal to both "left" and "right"
  21086. * @param left defines the left operand
  21087. * @param right defines the right operand
  21088. * @returns the cross product
  21089. */
  21090. static Cross(left: Vector3, right: Vector3): Vector3;
  21091. /**
  21092. * Sets the given vector "result" with the cross product of "left" and "right"
  21093. * The cross product is then orthogonal to both "left" and "right"
  21094. * @param left defines the left operand
  21095. * @param right defines the right operand
  21096. * @param result defines the Vector3 where to store the result
  21097. */
  21098. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21099. /**
  21100. * Returns a new Vector3 as the normalization of the given vector
  21101. * @param vector defines the Vector3 to normalize
  21102. * @returns the new Vector3
  21103. */
  21104. static Normalize(vector: Vector3): Vector3;
  21105. /**
  21106. * Sets the given vector "result" with the normalization of the given first vector
  21107. * @param vector defines the Vector3 to normalize
  21108. * @param result defines the Vector3 where to store the result
  21109. */
  21110. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  21111. private static _viewportMatrixCache;
  21112. /**
  21113. * Project a Vector3 onto screen space
  21114. * @param vector defines the Vector3 to project
  21115. * @param world defines the world matrix to use
  21116. * @param transform defines the transform (view x projection) matrix to use
  21117. * @param viewport defines the screen viewport to use
  21118. * @returns the new Vector3
  21119. */
  21120. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  21121. /**
  21122. * Unproject from screen space to object space
  21123. * @param source defines the screen space Vector3 to use
  21124. * @param viewportWidth defines the current width of the viewport
  21125. * @param viewportHeight defines the current height of the viewport
  21126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21127. * @param transform defines the transform (view x projection) matrix to use
  21128. * @returns the new Vector3
  21129. */
  21130. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  21131. /**
  21132. * Unproject from screen space to object space
  21133. * @param source defines the screen space Vector3 to use
  21134. * @param viewportWidth defines the current width of the viewport
  21135. * @param viewportHeight defines the current height of the viewport
  21136. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21137. * @param view defines the view matrix to use
  21138. * @param projection defines the projection matrix to use
  21139. * @returns the new Vector3
  21140. */
  21141. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  21142. /**
  21143. * Unproject from screen space to object space
  21144. * @param source defines the screen space Vector3 to use
  21145. * @param viewportWidth defines the current width of the viewport
  21146. * @param viewportHeight defines the current height of the viewport
  21147. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21148. * @param view defines the view matrix to use
  21149. * @param projection defines the projection matrix to use
  21150. * @param result defines the Vector3 where to store the result
  21151. */
  21152. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21153. /**
  21154. * Unproject from screen space to object space
  21155. * @param sourceX defines the screen space x coordinate to use
  21156. * @param sourceY defines the screen space y coordinate to use
  21157. * @param sourceZ defines the screen space z coordinate to use
  21158. * @param viewportWidth defines the current width of the viewport
  21159. * @param viewportHeight defines the current height of the viewport
  21160. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21161. * @param view defines the view matrix to use
  21162. * @param projection defines the projection matrix to use
  21163. * @param result defines the Vector3 where to store the result
  21164. */
  21165. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21166. /**
  21167. * Gets the minimal coordinate values between two Vector3
  21168. * @param left defines the first operand
  21169. * @param right defines the second operand
  21170. * @returns the new Vector3
  21171. */
  21172. static Minimize(left: Vector3, right: Vector3): Vector3;
  21173. /**
  21174. * Gets the maximal coordinate values between two Vector3
  21175. * @param left defines the first operand
  21176. * @param right defines the second operand
  21177. * @returns the new Vector3
  21178. */
  21179. static Maximize(left: Vector3, right: Vector3): Vector3;
  21180. /**
  21181. * Returns the distance between the vectors "value1" and "value2"
  21182. * @param value1 defines the first operand
  21183. * @param value2 defines the second operand
  21184. * @returns the distance
  21185. */
  21186. static Distance(value1: Vector3, value2: Vector3): number;
  21187. /**
  21188. * Returns the squared distance between the vectors "value1" and "value2"
  21189. * @param value1 defines the first operand
  21190. * @param value2 defines the second operand
  21191. * @returns the squared distance
  21192. */
  21193. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  21194. /**
  21195. * Returns a new Vector3 located at the center between "value1" and "value2"
  21196. * @param value1 defines the first operand
  21197. * @param value2 defines the second operand
  21198. * @returns the new Vector3
  21199. */
  21200. static Center(value1: Vector3, value2: Vector3): Vector3;
  21201. /**
  21202. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21203. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21204. * to something in order to rotate it from its local system to the given target system
  21205. * Note: axis1, axis2 and axis3 are normalized during this operation
  21206. * @param axis1 defines the first axis
  21207. * @param axis2 defines the second axis
  21208. * @param axis3 defines the third axis
  21209. * @returns a new Vector3
  21210. */
  21211. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  21212. /**
  21213. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21214. * @param axis1 defines the first axis
  21215. * @param axis2 defines the second axis
  21216. * @param axis3 defines the third axis
  21217. * @param ref defines the Vector3 where to store the result
  21218. */
  21219. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  21220. }
  21221. /**
  21222. * Vector4 class created for EulerAngle class conversion to Quaternion
  21223. */
  21224. class Vector4 {
  21225. /** x value of the vector */
  21226. x: number;
  21227. /** y value of the vector */
  21228. y: number;
  21229. /** z value of the vector */
  21230. z: number;
  21231. /** w value of the vector */
  21232. w: number;
  21233. /**
  21234. * Creates a Vector4 object from the given floats.
  21235. * @param x x value of the vector
  21236. * @param y y value of the vector
  21237. * @param z z value of the vector
  21238. * @param w w value of the vector
  21239. */
  21240. constructor(
  21241. /** x value of the vector */
  21242. x: number,
  21243. /** y value of the vector */
  21244. y: number,
  21245. /** z value of the vector */
  21246. z: number,
  21247. /** w value of the vector */
  21248. w: number);
  21249. /**
  21250. * Returns the string with the Vector4 coordinates.
  21251. * @returns a string containing all the vector values
  21252. */
  21253. toString(): string;
  21254. /**
  21255. * Returns the string "Vector4".
  21256. * @returns "Vector4"
  21257. */
  21258. getClassName(): string;
  21259. /**
  21260. * Returns the Vector4 hash code.
  21261. * @returns a unique hash code
  21262. */
  21263. getHashCode(): number;
  21264. /**
  21265. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21266. * @returns the resulting array
  21267. */
  21268. asArray(): number[];
  21269. /**
  21270. * Populates the given array from the given index with the Vector4 coordinates.
  21271. * @param array array to populate
  21272. * @param index index of the array to start at (default: 0)
  21273. * @returns the Vector4.
  21274. */
  21275. toArray(array: FloatArray, index?: number): Vector4;
  21276. /**
  21277. * Adds the given vector to the current Vector4.
  21278. * @param otherVector the vector to add
  21279. * @returns the updated Vector4.
  21280. */
  21281. addInPlace(otherVector: Vector4): Vector4;
  21282. /**
  21283. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21284. * @param otherVector the vector to add
  21285. * @returns the resulting vector
  21286. */
  21287. add(otherVector: Vector4): Vector4;
  21288. /**
  21289. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21290. * @param otherVector the vector to add
  21291. * @param result the vector to store the result
  21292. * @returns the current Vector4.
  21293. */
  21294. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  21295. /**
  21296. * Subtract in place the given vector from the current Vector4.
  21297. * @param otherVector the vector to subtract
  21298. * @returns the updated Vector4.
  21299. */
  21300. subtractInPlace(otherVector: Vector4): Vector4;
  21301. /**
  21302. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21303. * @param otherVector the vector to add
  21304. * @returns the new vector with the result
  21305. */
  21306. subtract(otherVector: Vector4): Vector4;
  21307. /**
  21308. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21309. * @param otherVector the vector to subtract
  21310. * @param result the vector to store the result
  21311. * @returns the current Vector4.
  21312. */
  21313. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  21314. /**
  21315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21316. */
  21317. /**
  21318. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21319. * @param x value to subtract
  21320. * @param y value to subtract
  21321. * @param z value to subtract
  21322. * @param w value to subtract
  21323. * @returns new vector containing the result
  21324. */
  21325. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21326. /**
  21327. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21328. * @param x value to subtract
  21329. * @param y value to subtract
  21330. * @param z value to subtract
  21331. * @param w value to subtract
  21332. * @param result the vector to store the result in
  21333. * @returns the current Vector4.
  21334. */
  21335. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21336. /**
  21337. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21338. * @returns a new vector with the negated values
  21339. */
  21340. negate(): Vector4;
  21341. /**
  21342. * Multiplies the current Vector4 coordinates by scale (float).
  21343. * @param scale the number to scale with
  21344. * @returns the updated Vector4.
  21345. */
  21346. scaleInPlace(scale: number): Vector4;
  21347. /**
  21348. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  21349. * @param scale the number to scale with
  21350. * @returns a new vector with the result
  21351. */
  21352. scale(scale: number): Vector4;
  21353. /**
  21354. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21355. * @param scale the number to scale with
  21356. * @param result a vector to store the result in
  21357. * @returns the current Vector4.
  21358. */
  21359. scaleToRef(scale: number, result: Vector4): Vector4;
  21360. /**
  21361. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21362. * @param scale defines the scale factor
  21363. * @param result defines the Vector4 object where to store the result
  21364. * @returns the unmodified current Vector4
  21365. */
  21366. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21367. /**
  21368. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21369. * @param otherVector the vector to compare against
  21370. * @returns true if they are equal
  21371. */
  21372. equals(otherVector: Vector4): boolean;
  21373. /**
  21374. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21375. * @param otherVector vector to compare against
  21376. * @param epsilon (Default: very small number)
  21377. * @returns true if they are equal
  21378. */
  21379. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  21380. /**
  21381. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  21382. * @param x x value to compare against
  21383. * @param y y value to compare against
  21384. * @param z z value to compare against
  21385. * @param w w value to compare against
  21386. * @returns true if equal
  21387. */
  21388. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  21389. /**
  21390. * Multiplies in place the current Vector4 by the given one.
  21391. * @param otherVector vector to multiple with
  21392. * @returns the updated Vector4.
  21393. */
  21394. multiplyInPlace(otherVector: Vector4): Vector4;
  21395. /**
  21396. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  21397. * @param otherVector vector to multiple with
  21398. * @returns resulting new vector
  21399. */
  21400. multiply(otherVector: Vector4): Vector4;
  21401. /**
  21402. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  21403. * @param otherVector vector to multiple with
  21404. * @param result vector to store the result
  21405. * @returns the current Vector4.
  21406. */
  21407. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  21408. /**
  21409. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  21410. * @param x x value multiply with
  21411. * @param y y value multiply with
  21412. * @param z z value multiply with
  21413. * @param w w value multiply with
  21414. * @returns resulting new vector
  21415. */
  21416. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  21417. /**
  21418. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  21419. * @param otherVector vector to devide with
  21420. * @returns resulting new vector
  21421. */
  21422. divide(otherVector: Vector4): Vector4;
  21423. /**
  21424. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  21425. * @param otherVector vector to devide with
  21426. * @param result vector to store the result
  21427. * @returns the current Vector4.
  21428. */
  21429. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  21430. /**
  21431. * Divides the current Vector3 coordinates by the given ones.
  21432. * @param otherVector vector to devide with
  21433. * @returns the updated Vector3.
  21434. */
  21435. divideInPlace(otherVector: Vector4): Vector4;
  21436. /**
  21437. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  21438. * @param other defines the second operand
  21439. * @returns the current updated Vector4
  21440. */
  21441. minimizeInPlace(other: Vector4): Vector4;
  21442. /**
  21443. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  21444. * @param other defines the second operand
  21445. * @returns the current updated Vector4
  21446. */
  21447. maximizeInPlace(other: Vector4): Vector4;
  21448. /**
  21449. * Gets a new Vector4 from current Vector4 floored values
  21450. * @returns a new Vector4
  21451. */
  21452. floor(): Vector4;
  21453. /**
  21454. * Gets a new Vector4 from current Vector3 floored values
  21455. * @returns a new Vector4
  21456. */
  21457. fract(): Vector4;
  21458. /**
  21459. * Returns the Vector4 length (float).
  21460. * @returns the length
  21461. */
  21462. length(): number;
  21463. /**
  21464. * Returns the Vector4 squared length (float).
  21465. * @returns the length squared
  21466. */
  21467. lengthSquared(): number;
  21468. /**
  21469. * Normalizes in place the Vector4.
  21470. * @returns the updated Vector4.
  21471. */
  21472. normalize(): Vector4;
  21473. /**
  21474. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  21475. * @returns this converted to a new vector3
  21476. */
  21477. toVector3(): Vector3;
  21478. /**
  21479. * Returns a new Vector4 copied from the current one.
  21480. * @returns the new cloned vector
  21481. */
  21482. clone(): Vector4;
  21483. /**
  21484. * Updates the current Vector4 with the given one coordinates.
  21485. * @param source the source vector to copy from
  21486. * @returns the updated Vector4.
  21487. */
  21488. copyFrom(source: Vector4): Vector4;
  21489. /**
  21490. * Updates the current Vector4 coordinates with the given floats.
  21491. * @param x float to copy from
  21492. * @param y float to copy from
  21493. * @param z float to copy from
  21494. * @param w float to copy from
  21495. * @returns the updated Vector4.
  21496. */
  21497. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21498. /**
  21499. * Updates the current Vector4 coordinates with the given floats.
  21500. * @param x float to set from
  21501. * @param y float to set from
  21502. * @param z float to set from
  21503. * @param w float to set from
  21504. * @returns the updated Vector4.
  21505. */
  21506. set(x: number, y: number, z: number, w: number): Vector4;
  21507. /**
  21508. * Returns a new Vector4 set from the starting index of the given array.
  21509. * @param array the array to pull values from
  21510. * @param offset the offset into the array to start at
  21511. * @returns the new vector
  21512. */
  21513. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  21514. /**
  21515. * Updates the given vector "result" from the starting index of the given array.
  21516. * @param array the array to pull values from
  21517. * @param offset the offset into the array to start at
  21518. * @param result the vector to store the result in
  21519. */
  21520. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  21521. /**
  21522. * Updates the given vector "result" from the starting index of the given Float32Array.
  21523. * @param array the array to pull values from
  21524. * @param offset the offset into the array to start at
  21525. * @param result the vector to store the result in
  21526. */
  21527. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  21528. /**
  21529. * Updates the given vector "result" coordinates from the given floats.
  21530. * @param x float to set from
  21531. * @param y float to set from
  21532. * @param z float to set from
  21533. * @param w float to set from
  21534. * @param result the vector to the floats in
  21535. */
  21536. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  21537. /**
  21538. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  21539. * @returns the new vector
  21540. */
  21541. static Zero(): Vector4;
  21542. /**
  21543. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  21544. * @returns the new vector
  21545. */
  21546. static One(): Vector4;
  21547. /**
  21548. * Returns a new normalized Vector4 from the given one.
  21549. * @param vector the vector to normalize
  21550. * @returns the vector
  21551. */
  21552. static Normalize(vector: Vector4): Vector4;
  21553. /**
  21554. * Updates the given vector "result" from the normalization of the given one.
  21555. * @param vector the vector to normalize
  21556. * @param result the vector to store the result in
  21557. */
  21558. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  21559. /**
  21560. * Returns a vector with the minimum values from the left and right vectors
  21561. * @param left left vector to minimize
  21562. * @param right right vector to minimize
  21563. * @returns a new vector with the minimum of the left and right vector values
  21564. */
  21565. static Minimize(left: Vector4, right: Vector4): Vector4;
  21566. /**
  21567. * Returns a vector with the maximum values from the left and right vectors
  21568. * @param left left vector to maximize
  21569. * @param right right vector to maximize
  21570. * @returns a new vector with the maximum of the left and right vector values
  21571. */
  21572. static Maximize(left: Vector4, right: Vector4): Vector4;
  21573. /**
  21574. * Returns the distance (float) between the vectors "value1" and "value2".
  21575. * @param value1 value to calulate the distance between
  21576. * @param value2 value to calulate the distance between
  21577. * @return the distance between the two vectors
  21578. */
  21579. static Distance(value1: Vector4, value2: Vector4): number;
  21580. /**
  21581. * Returns the squared distance (float) between the vectors "value1" and "value2".
  21582. * @param value1 value to calulate the distance between
  21583. * @param value2 value to calulate the distance between
  21584. * @return the distance between the two vectors squared
  21585. */
  21586. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  21587. /**
  21588. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  21589. * @param value1 value to calulate the center between
  21590. * @param value2 value to calulate the center between
  21591. * @return the center between the two vectors
  21592. */
  21593. static Center(value1: Vector4, value2: Vector4): Vector4;
  21594. /**
  21595. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  21596. * This methods computes transformed normalized direction vectors only.
  21597. * @param vector the vector to transform
  21598. * @param transformation the transformation matrix to apply
  21599. * @returns the new vector
  21600. */
  21601. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  21602. /**
  21603. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  21604. * This methods computes transformed normalized direction vectors only.
  21605. * @param vector the vector to transform
  21606. * @param transformation the transformation matrix to apply
  21607. * @param result the vector to store the result in
  21608. */
  21609. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  21610. /**
  21611. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  21612. * This methods computes transformed normalized direction vectors only.
  21613. * @param x value to transform
  21614. * @param y value to transform
  21615. * @param z value to transform
  21616. * @param w value to transform
  21617. * @param transformation the transformation matrix to apply
  21618. * @param result the vector to store the results in
  21619. */
  21620. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  21621. }
  21622. /**
  21623. * Interface for the size containing width and height
  21624. */
  21625. interface ISize {
  21626. /**
  21627. * Width
  21628. */
  21629. width: number;
  21630. /**
  21631. * Heighht
  21632. */
  21633. height: number;
  21634. }
  21635. /**
  21636. * Size containing widht and height
  21637. */
  21638. class Size implements ISize {
  21639. /**
  21640. * Width
  21641. */
  21642. width: number;
  21643. /**
  21644. * Height
  21645. */
  21646. height: number;
  21647. /**
  21648. * Creates a Size object from the given width and height (floats).
  21649. * @param width width of the new size
  21650. * @param height height of the new size
  21651. */
  21652. constructor(width: number, height: number);
  21653. /**
  21654. * Returns a string with the Size width and height
  21655. * @returns a string with the Size width and height
  21656. */
  21657. toString(): string;
  21658. /**
  21659. * "Size"
  21660. * @returns the string "Size"
  21661. */
  21662. getClassName(): string;
  21663. /**
  21664. * Returns the Size hash code.
  21665. * @returns a hash code for a unique width and height
  21666. */
  21667. getHashCode(): number;
  21668. /**
  21669. * Updates the current size from the given one.
  21670. * @param src the given size
  21671. */
  21672. copyFrom(src: Size): void;
  21673. /**
  21674. * Updates in place the current Size from the given floats.
  21675. * @param width width of the new size
  21676. * @param height height of the new size
  21677. * @returns the updated Size.
  21678. */
  21679. copyFromFloats(width: number, height: number): Size;
  21680. /**
  21681. * Updates in place the current Size from the given floats.
  21682. * @param width width to set
  21683. * @param height height to set
  21684. * @returns the updated Size.
  21685. */
  21686. set(width: number, height: number): Size;
  21687. /**
  21688. * Multiplies the width and height by numbers
  21689. * @param w factor to multiple the width by
  21690. * @param h factor to multiple the height by
  21691. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  21692. */
  21693. multiplyByFloats(w: number, h: number): Size;
  21694. /**
  21695. * Clones the size
  21696. * @returns a new Size copied from the given one.
  21697. */
  21698. clone(): Size;
  21699. /**
  21700. * True if the current Size and the given one width and height are strictly equal.
  21701. * @param other the other size to compare against
  21702. * @returns True if the current Size and the given one width and height are strictly equal.
  21703. */
  21704. equals(other: Size): boolean;
  21705. /**
  21706. * The surface of the Size : width * height (float).
  21707. */
  21708. readonly surface: number;
  21709. /**
  21710. * Create a new size of zero
  21711. * @returns a new Size set to (0.0, 0.0)
  21712. */
  21713. static Zero(): Size;
  21714. /**
  21715. * Sums the width and height of two sizes
  21716. * @param otherSize size to add to this size
  21717. * @returns a new Size set as the addition result of the current Size and the given one.
  21718. */
  21719. add(otherSize: Size): Size;
  21720. /**
  21721. * Subtracts the width and height of two
  21722. * @param otherSize size to subtract to this size
  21723. * @returns a new Size set as the subtraction result of the given one from the current Size.
  21724. */
  21725. subtract(otherSize: Size): Size;
  21726. /**
  21727. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  21728. * @param start starting size to lerp between
  21729. * @param end end size to lerp between
  21730. * @param amount amount to lerp between the start and end values
  21731. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  21732. */
  21733. static Lerp(start: Size, end: Size, amount: number): Size;
  21734. }
  21735. /**
  21736. * Class used to store quaternion data
  21737. * @see https://en.wikipedia.org/wiki/Quaternion
  21738. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  21739. */
  21740. class Quaternion {
  21741. /** defines the first component (0 by default) */
  21742. x: number;
  21743. /** defines the second component (0 by default) */
  21744. y: number;
  21745. /** defines the third component (0 by default) */
  21746. z: number;
  21747. /** defines the fourth component (1.0 by default) */
  21748. w: number;
  21749. /**
  21750. * Creates a new Quaternion from the given floats
  21751. * @param x defines the first component (0 by default)
  21752. * @param y defines the second component (0 by default)
  21753. * @param z defines the third component (0 by default)
  21754. * @param w defines the fourth component (1.0 by default)
  21755. */
  21756. constructor(
  21757. /** defines the first component (0 by default) */
  21758. x?: number,
  21759. /** defines the second component (0 by default) */
  21760. y?: number,
  21761. /** defines the third component (0 by default) */
  21762. z?: number,
  21763. /** defines the fourth component (1.0 by default) */
  21764. w?: number);
  21765. /**
  21766. * Gets a string representation for the current quaternion
  21767. * @returns a string with the Quaternion coordinates
  21768. */
  21769. toString(): string;
  21770. /**
  21771. * Gets the class name of the quaternion
  21772. * @returns the string "Quaternion"
  21773. */
  21774. getClassName(): string;
  21775. /**
  21776. * Gets a hash code for this quaternion
  21777. * @returns the quaternion hash code
  21778. */
  21779. getHashCode(): number;
  21780. /**
  21781. * Copy the quaternion to an array
  21782. * @returns a new array populated with 4 elements from the quaternion coordinates
  21783. */
  21784. asArray(): number[];
  21785. /**
  21786. * Check if two quaternions are equals
  21787. * @param otherQuaternion defines the second operand
  21788. * @return true if the current quaternion and the given one coordinates are strictly equals
  21789. */
  21790. equals(otherQuaternion: Quaternion): boolean;
  21791. /**
  21792. * Clone the current quaternion
  21793. * @returns a new quaternion copied from the current one
  21794. */
  21795. clone(): Quaternion;
  21796. /**
  21797. * Copy a quaternion to the current one
  21798. * @param other defines the other quaternion
  21799. * @returns the updated current quaternion
  21800. */
  21801. copyFrom(other: Quaternion): Quaternion;
  21802. /**
  21803. * Updates the current quaternion with the given float coordinates
  21804. * @param x defines the x coordinate
  21805. * @param y defines the y coordinate
  21806. * @param z defines the z coordinate
  21807. * @param w defines the w coordinate
  21808. * @returns the updated current quaternion
  21809. */
  21810. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  21811. /**
  21812. * Updates the current quaternion from the given float coordinates
  21813. * @param x defines the x coordinate
  21814. * @param y defines the y coordinate
  21815. * @param z defines the z coordinate
  21816. * @param w defines the w coordinate
  21817. * @returns the updated current quaternion
  21818. */
  21819. set(x: number, y: number, z: number, w: number): Quaternion;
  21820. /**
  21821. * Adds two quaternions
  21822. * @param other defines the second operand
  21823. * @returns a new quaternion as the addition result of the given one and the current quaternion
  21824. */
  21825. add(other: Quaternion): Quaternion;
  21826. /**
  21827. * Add a quaternion to the current one
  21828. * @param other defines the quaternion to add
  21829. * @returns the current quaternion
  21830. */
  21831. addInPlace(other: Quaternion): Quaternion;
  21832. /**
  21833. * Subtract two quaternions
  21834. * @param other defines the second operand
  21835. * @returns a new quaternion as the subtraction result of the given one from the current one
  21836. */
  21837. subtract(other: Quaternion): Quaternion;
  21838. /**
  21839. * Multiplies the current quaternion by a scale factor
  21840. * @param value defines the scale factor
  21841. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  21842. */
  21843. scale(value: number): Quaternion;
  21844. /**
  21845. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  21846. * @param scale defines the scale factor
  21847. * @param result defines the Quaternion object where to store the result
  21848. * @returns the unmodified current quaternion
  21849. */
  21850. scaleToRef(scale: number, result: Quaternion): Quaternion;
  21851. /**
  21852. * Multiplies in place the current quaternion by a scale factor
  21853. * @param value defines the scale factor
  21854. * @returns the current modified quaternion
  21855. */
  21856. scaleInPlace(value: number): Quaternion;
  21857. /**
  21858. * Scale the current quaternion values by a factor and add the result to a given quaternion
  21859. * @param scale defines the scale factor
  21860. * @param result defines the Quaternion object where to store the result
  21861. * @returns the unmodified current quaternion
  21862. */
  21863. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  21864. /**
  21865. * Multiplies two quaternions
  21866. * @param q1 defines the second operand
  21867. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  21868. */
  21869. multiply(q1: Quaternion): Quaternion;
  21870. /**
  21871. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  21872. * @param q1 defines the second operand
  21873. * @param result defines the target quaternion
  21874. * @returns the current quaternion
  21875. */
  21876. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  21877. /**
  21878. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  21879. * @param q1 defines the second operand
  21880. * @returns the currentupdated quaternion
  21881. */
  21882. multiplyInPlace(q1: Quaternion): Quaternion;
  21883. /**
  21884. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  21885. * @param ref defines the target quaternion
  21886. * @returns the current quaternion
  21887. */
  21888. conjugateToRef(ref: Quaternion): Quaternion;
  21889. /**
  21890. * Conjugates in place (1-q) the current quaternion
  21891. * @returns the current updated quaternion
  21892. */
  21893. conjugateInPlace(): Quaternion;
  21894. /**
  21895. * Conjugates in place (1-q) the current quaternion
  21896. * @returns a new quaternion
  21897. */
  21898. conjugate(): Quaternion;
  21899. /**
  21900. * Gets length of current quaternion
  21901. * @returns the quaternion length (float)
  21902. */
  21903. length(): number;
  21904. /**
  21905. * Normalize in place the current quaternion
  21906. * @returns the current updated quaternion
  21907. */
  21908. normalize(): Quaternion;
  21909. /**
  21910. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  21911. * @param order is a reserved parameter and is ignore for now
  21912. * @returns a new Vector3 containing the Euler angles
  21913. */
  21914. toEulerAngles(order?: string): Vector3;
  21915. /**
  21916. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  21917. * @param result defines the vector which will be filled with the Euler angles
  21918. * @param order is a reserved parameter and is ignore for now
  21919. * @returns the current unchanged quaternion
  21920. */
  21921. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  21922. /**
  21923. * Updates the given rotation matrix with the current quaternion values
  21924. * @param result defines the target matrix
  21925. * @returns the current unchanged quaternion
  21926. */
  21927. toRotationMatrix(result: Matrix): Quaternion;
  21928. /**
  21929. * Updates the current quaternion from the given rotation matrix values
  21930. * @param matrix defines the source matrix
  21931. * @returns the current updated quaternion
  21932. */
  21933. fromRotationMatrix(matrix: Matrix): Quaternion;
  21934. /**
  21935. * Creates a new quaternion from a rotation matrix
  21936. * @param matrix defines the source matrix
  21937. * @returns a new quaternion created from the given rotation matrix values
  21938. */
  21939. static FromRotationMatrix(matrix: Matrix): Quaternion;
  21940. /**
  21941. * Updates the given quaternion with the given rotation matrix values
  21942. * @param matrix defines the source matrix
  21943. * @param result defines the target quaternion
  21944. */
  21945. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  21946. /**
  21947. * Returns the dot product (float) between the quaternions "left" and "right"
  21948. * @param left defines the left operand
  21949. * @param right defines the right operand
  21950. * @returns the dot product
  21951. */
  21952. static Dot(left: Quaternion, right: Quaternion): number;
  21953. /**
  21954. * Checks if the two quaternions are close to each other
  21955. * @param quat0 defines the first quaternion to check
  21956. * @param quat1 defines the second quaternion to check
  21957. * @returns true if the two quaternions are close to each other
  21958. */
  21959. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  21960. /**
  21961. * Creates an empty quaternion
  21962. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  21963. */
  21964. static Zero(): Quaternion;
  21965. /**
  21966. * Inverse a given quaternion
  21967. * @param q defines the source quaternion
  21968. * @returns a new quaternion as the inverted current quaternion
  21969. */
  21970. static Inverse(q: Quaternion): Quaternion;
  21971. /**
  21972. * Creates an identity quaternion
  21973. * @returns the identity quaternion
  21974. */
  21975. static Identity(): Quaternion;
  21976. /**
  21977. * Gets a boolean indicating if the given quaternion is identity
  21978. * @param quaternion defines the quaternion to check
  21979. * @returns true if the quaternion is identity
  21980. */
  21981. static IsIdentity(quaternion: Quaternion): boolean;
  21982. /**
  21983. * Creates a quaternion from a rotation around an axis
  21984. * @param axis defines the axis to use
  21985. * @param angle defines the angle to use
  21986. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  21987. */
  21988. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  21989. /**
  21990. * Creates a rotation around an axis and stores it into the given quaternion
  21991. * @param axis defines the axis to use
  21992. * @param angle defines the angle to use
  21993. * @param result defines the target quaternion
  21994. * @returns the target quaternion
  21995. */
  21996. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  21997. /**
  21998. * Creates a new quaternion from data stored into an array
  21999. * @param array defines the data source
  22000. * @param offset defines the offset in the source array where the data starts
  22001. * @returns a new quaternion
  22002. */
  22003. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  22004. /**
  22005. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22006. * @param yaw defines the rotation around Y axis
  22007. * @param pitch defines the rotation around X axis
  22008. * @param roll defines the rotation around Z axis
  22009. * @returns the new quaternion
  22010. */
  22011. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22012. /**
  22013. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22014. * @param yaw defines the rotation around Y axis
  22015. * @param pitch defines the rotation around X axis
  22016. * @param roll defines the rotation around Z axis
  22017. * @param result defines the target quaternion
  22018. */
  22019. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22020. /**
  22021. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22022. * @param alpha defines the rotation around first axis
  22023. * @param beta defines the rotation around second axis
  22024. * @param gamma defines the rotation around third axis
  22025. * @returns the new quaternion
  22026. */
  22027. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22028. /**
  22029. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22030. * @param alpha defines the rotation around first axis
  22031. * @param beta defines the rotation around second axis
  22032. * @param gamma defines the rotation around third axis
  22033. * @param result defines the target quaternion
  22034. */
  22035. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22036. /**
  22037. * 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)
  22038. * @param axis1 defines the first axis
  22039. * @param axis2 defines the second axis
  22040. * @param axis3 defines the third axis
  22041. * @returns the new quaternion
  22042. */
  22043. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  22044. /**
  22045. * 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
  22046. * @param axis1 defines the first axis
  22047. * @param axis2 defines the second axis
  22048. * @param axis3 defines the third axis
  22049. * @param ref defines the target quaternion
  22050. */
  22051. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  22052. /**
  22053. * Interpolates between two quaternions
  22054. * @param left defines first quaternion
  22055. * @param right defines second quaternion
  22056. * @param amount defines the gradient to use
  22057. * @returns the new interpolated quaternion
  22058. */
  22059. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  22060. /**
  22061. * Interpolates between two quaternions and stores it into a target quaternion
  22062. * @param left defines first quaternion
  22063. * @param right defines second quaternion
  22064. * @param amount defines the gradient to use
  22065. * @param result defines the target quaternion
  22066. */
  22067. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  22068. /**
  22069. * Interpolate between two quaternions using Hermite interpolation
  22070. * @param value1 defines first quaternion
  22071. * @param tangent1 defines the incoming tangent
  22072. * @param value2 defines second quaternion
  22073. * @param tangent2 defines the outgoing tangent
  22074. * @param amount defines the target quaternion
  22075. * @returns the new interpolated quaternion
  22076. */
  22077. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  22078. }
  22079. /**
  22080. * Class used to store matrix data (4x4)
  22081. */
  22082. class Matrix {
  22083. private static _tempQuaternion;
  22084. private static _xAxis;
  22085. private static _yAxis;
  22086. private static _zAxis;
  22087. private static _updateFlagSeed;
  22088. private static _identityReadOnly;
  22089. private _isIdentity;
  22090. private _isIdentityDirty;
  22091. /**
  22092. * Gets the update flag of the matrix which is an unique number for the matrix.
  22093. * It will be incremented every time the matrix data change.
  22094. * You can use it to speed the comparison between two versions of the same matrix.
  22095. */
  22096. updateFlag: number;
  22097. /**
  22098. * Gets or sets the internal data of the matrix
  22099. */
  22100. m: Float32Array;
  22101. /** @hidden */
  22102. _markAsUpdated(): void;
  22103. /**
  22104. * Creates an empty matrix (filled with zeros)
  22105. */
  22106. constructor();
  22107. /**
  22108. * Check if the current matrix is indentity
  22109. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  22110. * @returns true is the matrix is the identity matrix
  22111. */
  22112. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  22113. /**
  22114. * Gets the determinant of the matrix
  22115. * @returns the matrix determinant
  22116. */
  22117. determinant(): number;
  22118. /**
  22119. * Returns the matrix as a Float32Array
  22120. * @returns the matrix underlying array
  22121. */
  22122. toArray(): Float32Array;
  22123. /**
  22124. * Returns the matrix as a Float32Array
  22125. * @returns the matrix underlying array.
  22126. */
  22127. asArray(): Float32Array;
  22128. /**
  22129. * Inverts the current matrix in place
  22130. * @returns the current inverted matrix
  22131. */
  22132. invert(): Matrix;
  22133. /**
  22134. * Sets all the matrix elements to zero
  22135. * @returns the current matrix
  22136. */
  22137. reset(): Matrix;
  22138. /**
  22139. * Adds the current matrix with a second one
  22140. * @param other defines the matrix to add
  22141. * @returns a new matrix as the addition of the current matrix and the given one
  22142. */
  22143. add(other: Matrix): Matrix;
  22144. /**
  22145. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22146. * @param other defines the matrix to add
  22147. * @param result defines the target matrix
  22148. * @returns the current matrix
  22149. */
  22150. addToRef(other: Matrix, result: Matrix): Matrix;
  22151. /**
  22152. * Adds in place the given matrix to the current matrix
  22153. * @param other defines the second operand
  22154. * @returns the current updated matrix
  22155. */
  22156. addToSelf(other: Matrix): Matrix;
  22157. /**
  22158. * Sets the given matrix to the current inverted Matrix
  22159. * @param other defines the target matrix
  22160. * @returns the unmodified current matrix
  22161. */
  22162. invertToRef(other: Matrix): Matrix;
  22163. /**
  22164. * Inserts the translation vector (using 3 floats) in the current matrix
  22165. * @param x defines the 1st component of the translation
  22166. * @param y defines the 2nd component of the translation
  22167. * @param z defines the 3rd component of the translation
  22168. * @returns the current updated matrix
  22169. */
  22170. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22171. /**
  22172. * Inserts the translation vector in the current matrix
  22173. * @param vector3 defines the translation to insert
  22174. * @returns the current updated matrix
  22175. */
  22176. setTranslation(vector3: Vector3): Matrix;
  22177. /**
  22178. * Gets the translation value of the current matrix
  22179. * @returns a new Vector3 as the extracted translation from the matrix
  22180. */
  22181. getTranslation(): Vector3;
  22182. /**
  22183. * Fill a Vector3 with the extracted translation from the matrix
  22184. * @param result defines the Vector3 where to store the translation
  22185. * @returns the current matrix
  22186. */
  22187. getTranslationToRef(result: Vector3): Matrix;
  22188. /**
  22189. * Remove rotation and scaling part from the matrix
  22190. * @returns the updated matrix
  22191. */
  22192. removeRotationAndScaling(): Matrix;
  22193. /**
  22194. * Multiply two matrices
  22195. * @param other defines the second operand
  22196. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22197. */
  22198. multiply(other: Matrix): Matrix;
  22199. /**
  22200. * Copy the current matrix from the given one
  22201. * @param other defines the source matrix
  22202. * @returns the current updated matrix
  22203. */
  22204. copyFrom(other: Matrix): Matrix;
  22205. /**
  22206. * Populates the given array from the starting index with the current matrix values
  22207. * @param array defines the target array
  22208. * @param offset defines the offset in the target array where to start storing values
  22209. * @returns the current matrix
  22210. */
  22211. copyToArray(array: Float32Array, offset?: number): Matrix;
  22212. /**
  22213. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22214. * @param other defines the second operand
  22215. * @param result defines the matrix where to store the multiplication
  22216. * @returns the current matrix
  22217. */
  22218. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  22219. /**
  22220. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22221. * @param other defines the second operand
  22222. * @param result defines the array where to store the multiplication
  22223. * @param offset defines the offset in the target array where to start storing values
  22224. * @returns the current matrix
  22225. */
  22226. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  22227. /**
  22228. * Check equality between this matrix and a second one
  22229. * @param value defines the second matrix to compare
  22230. * @returns true is the current matrix and the given one values are strictly equal
  22231. */
  22232. equals(value: Matrix): boolean;
  22233. /**
  22234. * Clone the current matrix
  22235. * @returns a new matrix from the current matrix
  22236. */
  22237. clone(): Matrix;
  22238. /**
  22239. * Returns the name of the current matrix class
  22240. * @returns the string "Matrix"
  22241. */
  22242. getClassName(): string;
  22243. /**
  22244. * Gets the hash code of the current matrix
  22245. * @returns the hash code
  22246. */
  22247. getHashCode(): number;
  22248. /**
  22249. * Decomposes the current Matrix into a translation, rotation and scaling components
  22250. * @param scale defines the scale vector3 given as a reference to update
  22251. * @param rotation defines the rotation quaternion given as a reference to update
  22252. * @param translation defines the translation vector3 given as a reference to update
  22253. * @returns true if operation was successful
  22254. */
  22255. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22256. /**
  22257. * Gets specific row of the matrix
  22258. * @param index defines the number of the row to get
  22259. * @returns the index-th row of the current matrix as a new Vector4
  22260. */
  22261. getRow(index: number): Nullable<Vector4>;
  22262. /**
  22263. * Sets the index-th row of the current matrix to the vector4 values
  22264. * @param index defines the number of the row to set
  22265. * @param row defines the target vector4
  22266. * @returns the updated current matrix
  22267. */
  22268. setRow(index: number, row: Vector4): Matrix;
  22269. /**
  22270. * Compute the transpose of the matrix
  22271. * @returns the new transposed matrix
  22272. */
  22273. transpose(): Matrix;
  22274. /**
  22275. * Compute the transpose of the matrix and store it in a given matrix
  22276. * @param result defines the target matrix
  22277. * @returns the current matrix
  22278. */
  22279. transposeToRef(result: Matrix): Matrix;
  22280. /**
  22281. * Sets the index-th row of the current matrix with the given 4 x float values
  22282. * @param index defines the row index
  22283. * @param x defines the x component to set
  22284. * @param y defines the y component to set
  22285. * @param z defines the z component to set
  22286. * @param w defines the w component to set
  22287. * @returns the updated current matrix
  22288. */
  22289. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  22290. /**
  22291. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  22292. * @param scale defines the scale factor
  22293. * @returns a new matrix
  22294. */
  22295. scale(scale: number): Matrix;
  22296. /**
  22297. * Scale the current matrix values by a factor to a given result matrix
  22298. * @param scale defines the scale factor
  22299. * @param result defines the matrix to store the result
  22300. * @returns the current matrix
  22301. */
  22302. scaleToRef(scale: number, result: Matrix): Matrix;
  22303. /**
  22304. * Scale the current matrix values by a factor and add the result to a given matrix
  22305. * @param scale defines the scale factor
  22306. * @param result defines the Matrix to store the result
  22307. * @returns the current matrix
  22308. */
  22309. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  22310. /**
  22311. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  22312. * @param ref matrix to store the result
  22313. */
  22314. toNormalMatrix(ref: Matrix): void;
  22315. /**
  22316. * Gets only rotation part of the current matrix
  22317. * @returns a new matrix sets to the extracted rotation matrix from the current one
  22318. */
  22319. getRotationMatrix(): Matrix;
  22320. /**
  22321. * Extracts the rotation matrix from the current one and sets it as the given "result"
  22322. * @param result defines the target matrix to store data to
  22323. * @returns the current matrix
  22324. */
  22325. getRotationMatrixToRef(result: Matrix): Matrix;
  22326. /**
  22327. * Creates a matrix from an array
  22328. * @param array defines the source array
  22329. * @param offset defines an offset in the source array
  22330. * @returns a new Matrix set from the starting index of the given array
  22331. */
  22332. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  22333. /**
  22334. * Copy the content of an array into a given matrix
  22335. * @param array defines the source array
  22336. * @param offset defines an offset in the source array
  22337. * @param result defines the target matrix
  22338. */
  22339. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  22340. /**
  22341. * Stores an array into a matrix after having multiplied each component by a given factor
  22342. * @param array defines the source array
  22343. * @param offset defines the offset in the source array
  22344. * @param scale defines the scaling factor
  22345. * @param result defines the target matrix
  22346. */
  22347. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  22348. /**
  22349. * Stores a list of values (16) inside a given matrix
  22350. * @param initialM11 defines 1st value of 1st row
  22351. * @param initialM12 defines 2nd value of 1st row
  22352. * @param initialM13 defines 3rd value of 1st row
  22353. * @param initialM14 defines 4th value of 1st row
  22354. * @param initialM21 defines 1st value of 2nd row
  22355. * @param initialM22 defines 2nd value of 2nd row
  22356. * @param initialM23 defines 3rd value of 2nd row
  22357. * @param initialM24 defines 4th value of 2nd row
  22358. * @param initialM31 defines 1st value of 3rd row
  22359. * @param initialM32 defines 2nd value of 3rd row
  22360. * @param initialM33 defines 3rd value of 3rd row
  22361. * @param initialM34 defines 4th value of 3rd row
  22362. * @param initialM41 defines 1st value of 4th row
  22363. * @param initialM42 defines 2nd value of 4th row
  22364. * @param initialM43 defines 3rd value of 4th row
  22365. * @param initialM44 defines 4th value of 4th row
  22366. * @param result defines the target matrix
  22367. */
  22368. 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;
  22369. /**
  22370. * Gets an identity matrix that must not be updated
  22371. */
  22372. static readonly IdentityReadOnly: Matrix;
  22373. /**
  22374. * Creates new matrix from a list of values (16)
  22375. * @param initialM11 defines 1st value of 1st row
  22376. * @param initialM12 defines 2nd value of 1st row
  22377. * @param initialM13 defines 3rd value of 1st row
  22378. * @param initialM14 defines 4th value of 1st row
  22379. * @param initialM21 defines 1st value of 2nd row
  22380. * @param initialM22 defines 2nd value of 2nd row
  22381. * @param initialM23 defines 3rd value of 2nd row
  22382. * @param initialM24 defines 4th value of 2nd row
  22383. * @param initialM31 defines 1st value of 3rd row
  22384. * @param initialM32 defines 2nd value of 3rd row
  22385. * @param initialM33 defines 3rd value of 3rd row
  22386. * @param initialM34 defines 4th value of 3rd row
  22387. * @param initialM41 defines 1st value of 4th row
  22388. * @param initialM42 defines 2nd value of 4th row
  22389. * @param initialM43 defines 3rd value of 4th row
  22390. * @param initialM44 defines 4th value of 4th row
  22391. * @returns the new matrix
  22392. */
  22393. 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;
  22394. /**
  22395. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22396. * @param scale defines the scale vector3
  22397. * @param rotation defines the rotation quaternion
  22398. * @param translation defines the translation vector3
  22399. * @returns a new matrix
  22400. */
  22401. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  22402. /**
  22403. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22404. * @param scale defines the scale vector3
  22405. * @param rotation defines the rotation quaternion
  22406. * @param translation defines the translation vector3
  22407. * @param result defines the target matrix
  22408. */
  22409. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  22410. /**
  22411. * Creates a new identity matrix
  22412. * @returns a new identity matrix
  22413. */
  22414. static Identity(): Matrix;
  22415. /**
  22416. * Creates a new identity matrix and stores the result in a given matrix
  22417. * @param result defines the target matrix
  22418. */
  22419. static IdentityToRef(result: Matrix): void;
  22420. /**
  22421. * Creates a new zero matrix
  22422. * @returns a new zero matrix
  22423. */
  22424. static Zero(): Matrix;
  22425. /**
  22426. * Creates a new rotation matrix for "angle" radians around the X axis
  22427. * @param angle defines the angle (in radians) to use
  22428. * @return the new matrix
  22429. */
  22430. static RotationX(angle: number): Matrix;
  22431. /**
  22432. * Creates a new matrix as the invert of a given matrix
  22433. * @param source defines the source matrix
  22434. * @returns the new matrix
  22435. */
  22436. static Invert(source: Matrix): Matrix;
  22437. /**
  22438. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  22439. * @param angle defines the angle (in radians) to use
  22440. * @param result defines the target matrix
  22441. */
  22442. static RotationXToRef(angle: number, result: Matrix): void;
  22443. /**
  22444. * Creates a new rotation matrix for "angle" radians around the Y axis
  22445. * @param angle defines the angle (in radians) to use
  22446. * @return the new matrix
  22447. */
  22448. static RotationY(angle: number): Matrix;
  22449. /**
  22450. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  22451. * @param angle defines the angle (in radians) to use
  22452. * @param result defines the target matrix
  22453. */
  22454. static RotationYToRef(angle: number, result: Matrix): void;
  22455. /**
  22456. * Creates a new rotation matrix for "angle" radians around the Z axis
  22457. * @param angle defines the angle (in radians) to use
  22458. * @return the new matrix
  22459. */
  22460. static RotationZ(angle: number): Matrix;
  22461. /**
  22462. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  22463. * @param angle defines the angle (in radians) to use
  22464. * @param result defines the target matrix
  22465. */
  22466. static RotationZToRef(angle: number, result: Matrix): void;
  22467. /**
  22468. * Creates a new rotation matrix for "angle" radians around the given axis
  22469. * @param axis defines the axis to use
  22470. * @param angle defines the angle (in radians) to use
  22471. * @return the new matrix
  22472. */
  22473. static RotationAxis(axis: Vector3, angle: number): Matrix;
  22474. /**
  22475. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  22476. * @param axis defines the axis to use
  22477. * @param angle defines the angle (in radians) to use
  22478. * @param result defines the target matrix
  22479. */
  22480. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  22481. /**
  22482. * Creates a rotation matrix
  22483. * @param yaw defines the yaw angle in radians (Y axis)
  22484. * @param pitch defines the pitch angle in radians (X axis)
  22485. * @param roll defines the roll angle in radians (X axis)
  22486. * @returns the new rotation matrix
  22487. */
  22488. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  22489. /**
  22490. * Creates a rotation matrix and stores it in a given matrix
  22491. * @param yaw defines the yaw angle in radians (Y axis)
  22492. * @param pitch defines the pitch angle in radians (X axis)
  22493. * @param roll defines the roll angle in radians (X axis)
  22494. * @param result defines the target matrix
  22495. */
  22496. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  22497. /**
  22498. * Creates a scaling matrix
  22499. * @param x defines the scale factor on X axis
  22500. * @param y defines the scale factor on Y axis
  22501. * @param z defines the scale factor on Z axis
  22502. * @returns the new matrix
  22503. */
  22504. static Scaling(x: number, y: number, z: number): Matrix;
  22505. /**
  22506. * Creates a scaling matrix and stores it in a given matrix
  22507. * @param x defines the scale factor on X axis
  22508. * @param y defines the scale factor on Y axis
  22509. * @param z defines the scale factor on Z axis
  22510. * @param result defines the target matrix
  22511. */
  22512. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  22513. /**
  22514. * Creates a translation matrix
  22515. * @param x defines the translation on X axis
  22516. * @param y defines the translation on Y axis
  22517. * @param z defines the translationon Z axis
  22518. * @returns the new matrix
  22519. */
  22520. static Translation(x: number, y: number, z: number): Matrix;
  22521. /**
  22522. * Creates a translation matrix and stores it in a given matrix
  22523. * @param x defines the translation on X axis
  22524. * @param y defines the translation on Y axis
  22525. * @param z defines the translationon Z axis
  22526. * @param result defines the target matrix
  22527. */
  22528. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  22529. /**
  22530. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22531. * @param startValue defines the start value
  22532. * @param endValue defines the end value
  22533. * @param gradient defines the gradient factor
  22534. * @returns the new matrix
  22535. */
  22536. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22537. /**
  22538. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22539. * @param startValue defines the start value
  22540. * @param endValue defines the end value
  22541. * @param gradient defines the gradient factor
  22542. * @param result defines the Matrix object where to store data
  22543. */
  22544. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22545. /**
  22546. * Builds a new matrix whose values are computed by:
  22547. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22548. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22549. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22550. * @param startValue defines the first matrix
  22551. * @param endValue defines the second matrix
  22552. * @param gradient defines the gradient between the two matrices
  22553. * @returns the new matrix
  22554. */
  22555. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22556. /**
  22557. * Update a matrix to values which are computed by:
  22558. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22559. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22560. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22561. * @param startValue defines the first matrix
  22562. * @param endValue defines the second matrix
  22563. * @param gradient defines the gradient between the two matrices
  22564. * @param result defines the target matrix
  22565. */
  22566. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22567. /**
  22568. * 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"
  22569. * This function works in left handed mode
  22570. * @param eye defines the final position of the entity
  22571. * @param target defines where the entity should look at
  22572. * @param up defines the up vector for the entity
  22573. * @returns the new matrix
  22574. */
  22575. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22576. /**
  22577. * 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".
  22578. * This function works in left handed mode
  22579. * @param eye defines the final position of the entity
  22580. * @param target defines where the entity should look at
  22581. * @param up defines the up vector for the entity
  22582. * @param result defines the target matrix
  22583. */
  22584. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22585. /**
  22586. * 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"
  22587. * This function works in right handed mode
  22588. * @param eye defines the final position of the entity
  22589. * @param target defines where the entity should look at
  22590. * @param up defines the up vector for the entity
  22591. * @returns the new matrix
  22592. */
  22593. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22594. /**
  22595. * 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".
  22596. * This function works in right handed mode
  22597. * @param eye defines the final position of the entity
  22598. * @param target defines where the entity should look at
  22599. * @param up defines the up vector for the entity
  22600. * @param result defines the target matrix
  22601. */
  22602. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22603. /**
  22604. * Create a left-handed orthographic projection matrix
  22605. * @param width defines the viewport width
  22606. * @param height defines the viewport height
  22607. * @param znear defines the near clip plane
  22608. * @param zfar defines the far clip plane
  22609. * @returns a new matrix as a left-handed orthographic projection matrix
  22610. */
  22611. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  22612. /**
  22613. * Store a left-handed orthographic projection to a given matrix
  22614. * @param width defines the viewport width
  22615. * @param height defines the viewport height
  22616. * @param znear defines the near clip plane
  22617. * @param zfar defines the far clip plane
  22618. * @param result defines the target matrix
  22619. */
  22620. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  22621. /**
  22622. * Create a left-handed orthographic projection matrix
  22623. * @param left defines the viewport left coordinate
  22624. * @param right defines the viewport right coordinate
  22625. * @param bottom defines the viewport bottom coordinate
  22626. * @param top defines the viewport top coordinate
  22627. * @param znear defines the near clip plane
  22628. * @param zfar defines the far clip plane
  22629. * @returns a new matrix as a left-handed orthographic projection matrix
  22630. */
  22631. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  22632. /**
  22633. * Stores a left-handed orthographic projection into a given matrix
  22634. * @param left defines the viewport left coordinate
  22635. * @param right defines the viewport right coordinate
  22636. * @param bottom defines the viewport bottom coordinate
  22637. * @param top defines the viewport top coordinate
  22638. * @param znear defines the near clip plane
  22639. * @param zfar defines the far clip plane
  22640. * @param result defines the target matrix
  22641. */
  22642. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  22643. /**
  22644. * Creates a right-handed orthographic projection matrix
  22645. * @param left defines the viewport left coordinate
  22646. * @param right defines the viewport right coordinate
  22647. * @param bottom defines the viewport bottom coordinate
  22648. * @param top defines the viewport top coordinate
  22649. * @param znear defines the near clip plane
  22650. * @param zfar defines the far clip plane
  22651. * @returns a new matrix as a right-handed orthographic projection matrix
  22652. */
  22653. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  22654. /**
  22655. * Stores a right-handed orthographic projection into a given matrix
  22656. * @param left defines the viewport left coordinate
  22657. * @param right defines the viewport right coordinate
  22658. * @param bottom defines the viewport bottom coordinate
  22659. * @param top defines the viewport top coordinate
  22660. * @param znear defines the near clip plane
  22661. * @param zfar defines the far clip plane
  22662. * @param result defines the target matrix
  22663. */
  22664. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  22665. /**
  22666. * Creates a left-handed perspective projection matrix
  22667. * @param width defines the viewport width
  22668. * @param height defines the viewport height
  22669. * @param znear defines the near clip plane
  22670. * @param zfar defines the far clip plane
  22671. * @returns a new matrix as a left-handed perspective projection matrix
  22672. */
  22673. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  22674. /**
  22675. * Creates a left-handed perspective projection matrix
  22676. * @param fov defines the horizontal field of view
  22677. * @param aspect defines the aspect ratio
  22678. * @param znear defines the near clip plane
  22679. * @param zfar defines the far clip plane
  22680. * @returns a new matrix as a left-handed perspective projection matrix
  22681. */
  22682. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  22683. /**
  22684. * Stores a left-handed perspective projection into a given matrix
  22685. * @param fov defines the horizontal field of view
  22686. * @param aspect defines the aspect ratio
  22687. * @param znear defines the near clip plane
  22688. * @param zfar defines the far clip plane
  22689. * @param result defines the target matrix
  22690. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  22691. */
  22692. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  22693. /**
  22694. * Creates a right-handed perspective projection matrix
  22695. * @param fov defines the horizontal field of view
  22696. * @param aspect defines the aspect ratio
  22697. * @param znear defines the near clip plane
  22698. * @param zfar defines the far clip plane
  22699. * @returns a new matrix as a right-handed perspective projection matrix
  22700. */
  22701. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  22702. /**
  22703. * Stores a right-handed perspective projection into a given matrix
  22704. * @param fov defines the horizontal field of view
  22705. * @param aspect defines the aspect ratio
  22706. * @param znear defines the near clip plane
  22707. * @param zfar defines the far clip plane
  22708. * @param result defines the target matrix
  22709. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  22710. */
  22711. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  22712. /**
  22713. * Stores a perspective projection for WebVR info a given matrix
  22714. * @param fov defines the field of view
  22715. * @param znear defines the near clip plane
  22716. * @param zfar defines the far clip plane
  22717. * @param result defines the target matrix
  22718. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  22719. */
  22720. static PerspectiveFovWebVRToRef(fov: {
  22721. upDegrees: number;
  22722. downDegrees: number;
  22723. leftDegrees: number;
  22724. rightDegrees: number;
  22725. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  22726. /**
  22727. * Computes a complete transformation matrix
  22728. * @param viewport defines the viewport to use
  22729. * @param world defines the world matrix
  22730. * @param view defines the view matrix
  22731. * @param projection defines the projection matrix
  22732. * @param zmin defines the near clip plane
  22733. * @param zmax defines the far clip plane
  22734. * @returns the transformation matrix
  22735. */
  22736. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  22737. /**
  22738. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  22739. * @param matrix defines the matrix to use
  22740. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  22741. */
  22742. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  22743. /**
  22744. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  22745. * @param matrix defines the matrix to use
  22746. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  22747. */
  22748. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  22749. /**
  22750. * Compute the transpose of a given matrix
  22751. * @param matrix defines the matrix to transpose
  22752. * @returns the new matrix
  22753. */
  22754. static Transpose(matrix: Matrix): Matrix;
  22755. /**
  22756. * Compute the transpose of a matrix and store it in a target matrix
  22757. * @param matrix defines the matrix to transpose
  22758. * @param result defines the target matrix
  22759. */
  22760. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  22761. /**
  22762. * Computes a reflection matrix from a plane
  22763. * @param plane defines the reflection plane
  22764. * @returns a new matrix
  22765. */
  22766. static Reflection(plane: Plane): Matrix;
  22767. /**
  22768. * Computes a reflection matrix from a plane
  22769. * @param plane defines the reflection plane
  22770. * @param result defines the target matrix
  22771. */
  22772. static ReflectionToRef(plane: Plane, result: Matrix): void;
  22773. /**
  22774. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  22775. * @param xaxis defines the value of the 1st axis
  22776. * @param yaxis defines the value of the 2nd axis
  22777. * @param zaxis defines the value of the 3rd axis
  22778. * @param result defines the target matrix
  22779. */
  22780. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  22781. /**
  22782. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  22783. * @param quat defines the quaternion to use
  22784. * @param result defines the target matrix
  22785. */
  22786. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  22787. }
  22788. /**
  22789. * Represens a plane by the equation ax + by + cz + d = 0
  22790. */
  22791. class Plane {
  22792. /**
  22793. * Normal of the plane (a,b,c)
  22794. */
  22795. normal: Vector3;
  22796. /**
  22797. * d component of the plane
  22798. */
  22799. d: number;
  22800. /**
  22801. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  22802. * @param a a component of the plane
  22803. * @param b b component of the plane
  22804. * @param c c component of the plane
  22805. * @param d d component of the plane
  22806. */
  22807. constructor(a: number, b: number, c: number, d: number);
  22808. /**
  22809. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  22810. */
  22811. asArray(): number[];
  22812. /**
  22813. * @returns a new plane copied from the current Plane.
  22814. */
  22815. clone(): Plane;
  22816. /**
  22817. * @returns the string "Plane".
  22818. */
  22819. getClassName(): string;
  22820. /**
  22821. * @returns the Plane hash code.
  22822. */
  22823. getHashCode(): number;
  22824. /**
  22825. * Normalize the current Plane in place.
  22826. * @returns the updated Plane.
  22827. */
  22828. normalize(): Plane;
  22829. /**
  22830. * Applies a transformation the plane and returns the result
  22831. * @param transformation the transformation matrix to be applied to the plane
  22832. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  22833. */
  22834. transform(transformation: Matrix): Plane;
  22835. /**
  22836. * Calcualtte the dot product between the point and the plane normal
  22837. * @param point point to calculate the dot product with
  22838. * @returns the dot product (float) of the point coordinates and the plane normal.
  22839. */
  22840. dotCoordinate(point: Vector3): number;
  22841. /**
  22842. * Updates the current Plane from the plane defined by the three given points.
  22843. * @param point1 one of the points used to contruct the plane
  22844. * @param point2 one of the points used to contruct the plane
  22845. * @param point3 one of the points used to contruct the plane
  22846. * @returns the updated Plane.
  22847. */
  22848. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  22849. /**
  22850. * Checks if the plane is facing a given direction
  22851. * @param direction the direction to check if the plane is facing
  22852. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  22853. * @returns True is the vector "direction" is the same side than the plane normal.
  22854. */
  22855. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  22856. /**
  22857. * Calculates the distance to a point
  22858. * @param point point to calculate distance to
  22859. * @returns the signed distance (float) from the given point to the Plane.
  22860. */
  22861. signedDistanceTo(point: Vector3): number;
  22862. /**
  22863. * Creates a plane from an array
  22864. * @param array the array to create a plane from
  22865. * @returns a new Plane from the given array.
  22866. */
  22867. static FromArray(array: ArrayLike<number>): Plane;
  22868. /**
  22869. * Creates a plane from three points
  22870. * @param point1 point used to create the plane
  22871. * @param point2 point used to create the plane
  22872. * @param point3 point used to create the plane
  22873. * @returns a new Plane defined by the three given points.
  22874. */
  22875. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  22876. /**
  22877. * Creates a plane from an origin point and a normal
  22878. * @param origin origin of the plane to be constructed
  22879. * @param normal normal of the plane to be constructed
  22880. * @returns a new Plane the normal vector to this plane at the given origin point.
  22881. * Note : the vector "normal" is updated because normalized.
  22882. */
  22883. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  22884. /**
  22885. * Calculates the distance from a plane and a point
  22886. * @param origin origin of the plane to be constructed
  22887. * @param normal normal of the plane to be constructed
  22888. * @param point point to calculate distance to
  22889. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  22890. */
  22891. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  22892. }
  22893. /**
  22894. * Class used to represent a viewport on screen
  22895. */
  22896. class Viewport {
  22897. /** viewport left coordinate */
  22898. x: number;
  22899. /** viewport top coordinate */
  22900. y: number;
  22901. /**viewport width */
  22902. width: number;
  22903. /** viewport height */
  22904. height: number;
  22905. /**
  22906. * Creates a Viewport object located at (x, y) and sized (width, height)
  22907. * @param x defines viewport left coordinate
  22908. * @param y defines viewport top coordinate
  22909. * @param width defines the viewport width
  22910. * @param height defines the viewport height
  22911. */
  22912. constructor(
  22913. /** viewport left coordinate */
  22914. x: number,
  22915. /** viewport top coordinate */
  22916. y: number,
  22917. /**viewport width */
  22918. width: number,
  22919. /** viewport height */
  22920. height: number);
  22921. /**
  22922. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  22923. * @param renderWidthOrEngine defines either an engine or the rendering width
  22924. * @param renderHeight defines the rendering height
  22925. * @returns a new Viewport
  22926. */
  22927. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  22928. /**
  22929. * Returns a new Viewport copied from the current one
  22930. * @returns a new Viewport
  22931. */
  22932. clone(): Viewport;
  22933. }
  22934. /**
  22935. * Reprasents a camera frustum
  22936. */
  22937. class Frustum {
  22938. /**
  22939. * Gets the planes representing the frustum
  22940. * @param transform matrix to be applied to the returned planes
  22941. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  22942. */
  22943. static GetPlanes(transform: Matrix): Plane[];
  22944. /**
  22945. * Gets the near frustum plane transformed by the transform matrix
  22946. * @param transform transformation matrix to be applied to the resulting frustum plane
  22947. * @param frustumPlane the resuling frustum plane
  22948. */
  22949. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22950. /**
  22951. * Gets the far frustum plane transformed by the transform matrix
  22952. * @param transform transformation matrix to be applied to the resulting frustum plane
  22953. * @param frustumPlane the resuling frustum plane
  22954. */
  22955. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22956. /**
  22957. * Gets the left frustum plane transformed by the transform matrix
  22958. * @param transform transformation matrix to be applied to the resulting frustum plane
  22959. * @param frustumPlane the resuling frustum plane
  22960. */
  22961. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22962. /**
  22963. * Gets the right frustum plane transformed by the transform matrix
  22964. * @param transform transformation matrix to be applied to the resulting frustum plane
  22965. * @param frustumPlane the resuling frustum plane
  22966. */
  22967. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22968. /**
  22969. * Gets the top frustum plane transformed by the transform matrix
  22970. * @param transform transformation matrix to be applied to the resulting frustum plane
  22971. * @param frustumPlane the resuling frustum plane
  22972. */
  22973. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22974. /**
  22975. * Gets the bottom frustum plane transformed by the transform matrix
  22976. * @param transform transformation matrix to be applied to the resulting frustum plane
  22977. * @param frustumPlane the resuling frustum plane
  22978. */
  22979. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22980. /**
  22981. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  22982. * @param transform transformation matrix to be applied to the resulting frustum planes
  22983. * @param frustumPlanes the resuling frustum planes
  22984. */
  22985. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  22986. }
  22987. /** Defines supported spaces */
  22988. enum Space {
  22989. /** Local (object) space */
  22990. LOCAL = 0,
  22991. /** World space */
  22992. WORLD = 1,
  22993. /** Bone space */
  22994. BONE = 2
  22995. }
  22996. /** Defines the 3 main axes */
  22997. class Axis {
  22998. /** X axis */
  22999. static X: Vector3;
  23000. /** Y axis */
  23001. static Y: Vector3;
  23002. /** Z axis */
  23003. static Z: Vector3;
  23004. }
  23005. /** Class used to represent a Bezier curve */
  23006. class BezierCurve {
  23007. /**
  23008. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23009. * @param t defines the time
  23010. * @param x1 defines the left coordinate on X axis
  23011. * @param y1 defines the left coordinate on Y axis
  23012. * @param x2 defines the right coordinate on X axis
  23013. * @param y2 defines the right coordinate on Y axis
  23014. * @returns the interpolated value
  23015. */
  23016. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23017. }
  23018. /**
  23019. * Defines potential orientation for back face culling
  23020. */
  23021. enum Orientation {
  23022. /**
  23023. * Clockwise
  23024. */
  23025. CW = 0,
  23026. /** Counter clockwise */
  23027. CCW = 1
  23028. }
  23029. /**
  23030. * Defines angle representation
  23031. */
  23032. class Angle {
  23033. private _radians;
  23034. /**
  23035. * Creates an Angle object of "radians" radians (float).
  23036. */
  23037. constructor(radians: number);
  23038. /**
  23039. * Get value in degrees
  23040. * @returns the Angle value in degrees (float)
  23041. */
  23042. degrees(): number;
  23043. /**
  23044. * Get value in radians
  23045. * @returns the Angle value in radians (float)
  23046. */
  23047. radians(): number;
  23048. /**
  23049. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23050. * @param a defines first vector
  23051. * @param b defines second vector
  23052. * @returns a new Angle
  23053. */
  23054. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  23055. /**
  23056. * Gets a new Angle object from the given float in radians
  23057. * @param radians defines the angle value in radians
  23058. * @returns a new Angle
  23059. */
  23060. static FromRadians(radians: number): Angle;
  23061. /**
  23062. * Gets a new Angle object from the given float in degrees
  23063. * @param degrees defines the angle value in degrees
  23064. * @returns a new Angle
  23065. */
  23066. static FromDegrees(degrees: number): Angle;
  23067. }
  23068. /**
  23069. * This represents an arc in a 2d space.
  23070. */
  23071. class Arc2 {
  23072. /** Defines the start point of the arc */
  23073. startPoint: Vector2;
  23074. /** Defines the mid point of the arc */
  23075. midPoint: Vector2;
  23076. /** Defines the end point of the arc */
  23077. endPoint: Vector2;
  23078. /**
  23079. * Defines the center point of the arc.
  23080. */
  23081. centerPoint: Vector2;
  23082. /**
  23083. * Defines the radius of the arc.
  23084. */
  23085. radius: number;
  23086. /**
  23087. * Defines the angle of the arc (from mid point to end point).
  23088. */
  23089. angle: Angle;
  23090. /**
  23091. * Defines the start angle of the arc (from start point to middle point).
  23092. */
  23093. startAngle: Angle;
  23094. /**
  23095. * Defines the orientation of the arc (clock wise/counter clock wise).
  23096. */
  23097. orientation: Orientation;
  23098. /**
  23099. * Creates an Arc object from the three given points : start, middle and end.
  23100. * @param startPoint Defines the start point of the arc
  23101. * @param midPoint Defines the midlle point of the arc
  23102. * @param endPoint Defines the end point of the arc
  23103. */
  23104. constructor(
  23105. /** Defines the start point of the arc */
  23106. startPoint: Vector2,
  23107. /** Defines the mid point of the arc */
  23108. midPoint: Vector2,
  23109. /** Defines the end point of the arc */
  23110. endPoint: Vector2);
  23111. }
  23112. /**
  23113. * Represents a 2D path made up of multiple 2D points
  23114. */
  23115. class Path2 {
  23116. private _points;
  23117. private _length;
  23118. /**
  23119. * If the path start and end point are the same
  23120. */
  23121. closed: boolean;
  23122. /**
  23123. * Creates a Path2 object from the starting 2D coordinates x and y.
  23124. * @param x the starting points x value
  23125. * @param y the starting points y value
  23126. */
  23127. constructor(x: number, y: number);
  23128. /**
  23129. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23130. * @param x the added points x value
  23131. * @param y the added points y value
  23132. * @returns the updated Path2.
  23133. */
  23134. addLineTo(x: number, y: number): Path2;
  23135. /**
  23136. * 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.
  23137. * @param midX middle point x value
  23138. * @param midY middle point y value
  23139. * @param endX end point x value
  23140. * @param endY end point y value
  23141. * @param numberOfSegments (default: 36)
  23142. * @returns the updated Path2.
  23143. */
  23144. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23145. /**
  23146. * Closes the Path2.
  23147. * @returns the Path2.
  23148. */
  23149. close(): Path2;
  23150. /**
  23151. * Gets the sum of the distance between each sequential point in the path
  23152. * @returns the Path2 total length (float).
  23153. */
  23154. length(): number;
  23155. /**
  23156. * Gets the points which construct the path
  23157. * @returns the Path2 internal array of points.
  23158. */
  23159. getPoints(): Vector2[];
  23160. /**
  23161. * Retreives the point at the distance aways from the starting point
  23162. * @param normalizedLengthPosition the length along the path to retreive the point from
  23163. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23164. */
  23165. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23166. /**
  23167. * Creates a new path starting from an x and y position
  23168. * @param x starting x value
  23169. * @param y starting y value
  23170. * @returns a new Path2 starting at the coordinates (x, y).
  23171. */
  23172. static StartingAt(x: number, y: number): Path2;
  23173. }
  23174. /**
  23175. * Represents a 3D path made up of multiple 3D points
  23176. */
  23177. class Path3D {
  23178. /**
  23179. * an array of Vector3, the curve axis of the Path3D
  23180. */
  23181. path: Vector3[];
  23182. private _curve;
  23183. private _distances;
  23184. private _tangents;
  23185. private _normals;
  23186. private _binormals;
  23187. private _raw;
  23188. /**
  23189. * new Path3D(path, normal, raw)
  23190. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23191. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  23192. * @param path an array of Vector3, the curve axis of the Path3D
  23193. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23194. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23195. */
  23196. constructor(
  23197. /**
  23198. * an array of Vector3, the curve axis of the Path3D
  23199. */
  23200. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23201. /**
  23202. * Returns the Path3D array of successive Vector3 designing its curve.
  23203. * @returns the Path3D array of successive Vector3 designing its curve.
  23204. */
  23205. getCurve(): Vector3[];
  23206. /**
  23207. * Returns an array populated with tangent vectors on each Path3D curve point.
  23208. * @returns an array populated with tangent vectors on each Path3D curve point.
  23209. */
  23210. getTangents(): Vector3[];
  23211. /**
  23212. * Returns an array populated with normal vectors on each Path3D curve point.
  23213. * @returns an array populated with normal vectors on each Path3D curve point.
  23214. */
  23215. getNormals(): Vector3[];
  23216. /**
  23217. * Returns an array populated with binormal vectors on each Path3D curve point.
  23218. * @returns an array populated with binormal vectors on each Path3D curve point.
  23219. */
  23220. getBinormals(): Vector3[];
  23221. /**
  23222. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23223. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23224. */
  23225. getDistances(): number[];
  23226. /**
  23227. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23228. * @param path path which all values are copied into the curves points
  23229. * @param firstNormal which should be projected onto the curve
  23230. * @returns the same object updated.
  23231. */
  23232. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23233. private _compute;
  23234. private _getFirstNonNullVector;
  23235. private _getLastNonNullVector;
  23236. private _normalVector;
  23237. }
  23238. /**
  23239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23240. * A Curve3 is designed from a series of successive Vector3.
  23241. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23242. */
  23243. class Curve3 {
  23244. private _points;
  23245. private _length;
  23246. /**
  23247. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  23248. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23249. * @param v1 (Vector3) the control point
  23250. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23251. * @param nbPoints (integer) the wanted number of points in the curve
  23252. * @returns the created Curve3
  23253. */
  23254. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  23255. /**
  23256. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  23257. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23258. * @param v1 (Vector3) the first control point
  23259. * @param v2 (Vector3) the second control point
  23260. * @param v3 (Vector3) the end point of the Cubic Bezier
  23261. * @param nbPoints (integer) the wanted number of points in the curve
  23262. * @returns the created Curve3
  23263. */
  23264. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  23265. /**
  23266. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  23267. * @param p1 (Vector3) the origin point of the Hermite Spline
  23268. * @param t1 (Vector3) the tangent vector at the origin point
  23269. * @param p2 (Vector3) the end point of the Hermite Spline
  23270. * @param t2 (Vector3) the tangent vector at the end point
  23271. * @param nbPoints (integer) the wanted number of points in the curve
  23272. * @returns the created Curve3
  23273. */
  23274. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  23275. /**
  23276. * Returns a Curve3 object along a CatmullRom Spline curve :
  23277. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  23278. * @param nbPoints (integer) the wanted number of points between each curve control points
  23279. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  23280. * @returns the created Curve3
  23281. */
  23282. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  23283. /**
  23284. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23285. * A Curve3 is designed from a series of successive Vector3.
  23286. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  23287. * @param points points which make up the curve
  23288. */
  23289. constructor(points: Vector3[]);
  23290. /**
  23291. * @returns the Curve3 stored array of successive Vector3
  23292. */
  23293. getPoints(): Vector3[];
  23294. /**
  23295. * @returns the computed length (float) of the curve.
  23296. */
  23297. length(): number;
  23298. /**
  23299. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  23300. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  23301. * curveA and curveB keep unchanged.
  23302. * @param curve the curve to continue from this curve
  23303. * @returns the newly constructed curve
  23304. */
  23305. continue(curve: Curve3): Curve3;
  23306. private _computeLength;
  23307. }
  23308. /**
  23309. * Contains position and normal vectors for a vertex
  23310. */
  23311. class PositionNormalVertex {
  23312. /** the position of the vertex (defaut: 0,0,0) */
  23313. position: Vector3;
  23314. /** the normal of the vertex (defaut: 0,1,0) */
  23315. normal: Vector3;
  23316. /**
  23317. * Creates a PositionNormalVertex
  23318. * @param position the position of the vertex (defaut: 0,0,0)
  23319. * @param normal the normal of the vertex (defaut: 0,1,0)
  23320. */
  23321. constructor(
  23322. /** the position of the vertex (defaut: 0,0,0) */
  23323. position?: Vector3,
  23324. /** the normal of the vertex (defaut: 0,1,0) */
  23325. normal?: Vector3);
  23326. /**
  23327. * Clones the PositionNormalVertex
  23328. * @returns the cloned PositionNormalVertex
  23329. */
  23330. clone(): PositionNormalVertex;
  23331. }
  23332. /**
  23333. * Contains position, normal and uv vectors for a vertex
  23334. */
  23335. class PositionNormalTextureVertex {
  23336. /** the position of the vertex (defaut: 0,0,0) */
  23337. position: Vector3;
  23338. /** the normal of the vertex (defaut: 0,1,0) */
  23339. normal: Vector3;
  23340. /** the uv of the vertex (default: 0,0) */
  23341. uv: Vector2;
  23342. /**
  23343. * Creates a PositionNormalTextureVertex
  23344. * @param position the position of the vertex (defaut: 0,0,0)
  23345. * @param normal the normal of the vertex (defaut: 0,1,0)
  23346. * @param uv the uv of the vertex (default: 0,0)
  23347. */
  23348. constructor(
  23349. /** the position of the vertex (defaut: 0,0,0) */
  23350. position?: Vector3,
  23351. /** the normal of the vertex (defaut: 0,1,0) */
  23352. normal?: Vector3,
  23353. /** the uv of the vertex (default: 0,0) */
  23354. uv?: Vector2);
  23355. /**
  23356. * Clones the PositionNormalTextureVertex
  23357. * @returns the cloned PositionNormalTextureVertex
  23358. */
  23359. clone(): PositionNormalTextureVertex;
  23360. }
  23361. /**
  23362. * @hidden
  23363. */
  23364. class Tmp {
  23365. static Color3: Color3[];
  23366. static Color4: Color4[];
  23367. static Vector2: Vector2[];
  23368. static Vector3: Vector3[];
  23369. static Vector4: Vector4[];
  23370. static Quaternion: Quaternion[];
  23371. static Matrix: Matrix[];
  23372. }
  23373. }
  23374. declare module BABYLON {
  23375. /**
  23376. * Class representing spherical polynomial coefficients to the 3rd degree
  23377. */
  23378. class SphericalPolynomial {
  23379. /**
  23380. * The x coefficients of the spherical polynomial
  23381. */
  23382. x: Vector3;
  23383. /**
  23384. * The y coefficients of the spherical polynomial
  23385. */
  23386. y: Vector3;
  23387. /**
  23388. * The z coefficients of the spherical polynomial
  23389. */
  23390. z: Vector3;
  23391. /**
  23392. * The xx coefficients of the spherical polynomial
  23393. */
  23394. xx: Vector3;
  23395. /**
  23396. * The yy coefficients of the spherical polynomial
  23397. */
  23398. yy: Vector3;
  23399. /**
  23400. * The zz coefficients of the spherical polynomial
  23401. */
  23402. zz: Vector3;
  23403. /**
  23404. * The xy coefficients of the spherical polynomial
  23405. */
  23406. xy: Vector3;
  23407. /**
  23408. * The yz coefficients of the spherical polynomial
  23409. */
  23410. yz: Vector3;
  23411. /**
  23412. * The zx coefficients of the spherical polynomial
  23413. */
  23414. zx: Vector3;
  23415. /**
  23416. * Adds an ambient color to the spherical polynomial
  23417. * @param color the color to add
  23418. */
  23419. addAmbient(color: Color3): void;
  23420. /**
  23421. * Scales the spherical polynomial by the given amount
  23422. * @param scale the amount to scale
  23423. */
  23424. scale(scale: number): void;
  23425. /**
  23426. * Gets the spherical polynomial from harmonics
  23427. * @param harmonics the spherical harmonics
  23428. * @returns the spherical polynomial
  23429. */
  23430. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  23431. /**
  23432. * Constructs a spherical polynomial from an array.
  23433. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  23434. * @returns the spherical polynomial
  23435. */
  23436. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  23437. }
  23438. /**
  23439. * Class representing spherical harmonics coefficients to the 3rd degree
  23440. */
  23441. class SphericalHarmonics {
  23442. /**
  23443. * The l0,0 coefficients of the spherical harmonics
  23444. */
  23445. l00: Vector3;
  23446. /**
  23447. * The l1,-1 coefficients of the spherical harmonics
  23448. */
  23449. l1_1: Vector3;
  23450. /**
  23451. * The l1,0 coefficients of the spherical harmonics
  23452. */
  23453. l10: Vector3;
  23454. /**
  23455. * The l1,1 coefficients of the spherical harmonics
  23456. */
  23457. l11: Vector3;
  23458. /**
  23459. * The l2,-2 coefficients of the spherical harmonics
  23460. */
  23461. l2_2: Vector3;
  23462. /**
  23463. * The l2,-1 coefficients of the spherical harmonics
  23464. */
  23465. l2_1: Vector3;
  23466. /**
  23467. * The l2,0 coefficients of the spherical harmonics
  23468. */
  23469. l20: Vector3;
  23470. /**
  23471. * The l2,1 coefficients of the spherical harmonics
  23472. */
  23473. l21: Vector3;
  23474. /**
  23475. * The l2,2 coefficients of the spherical harmonics
  23476. */
  23477. lL22: Vector3;
  23478. /**
  23479. * Adds a light to the spherical harmonics
  23480. * @param direction the direction of the light
  23481. * @param color the color of the light
  23482. * @param deltaSolidAngle the delta solid angle of the light
  23483. */
  23484. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  23485. /**
  23486. * Scales the spherical harmonics by the given amount
  23487. * @param scale the amount to scale
  23488. */
  23489. scale(scale: number): void;
  23490. /**
  23491. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  23492. *
  23493. * ```
  23494. * E_lm = A_l * L_lm
  23495. * ```
  23496. *
  23497. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  23498. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  23499. * the scaling factors are given in equation 9.
  23500. */
  23501. convertIncidentRadianceToIrradiance(): void;
  23502. /**
  23503. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  23504. *
  23505. * ```
  23506. * L = (1/pi) * E * rho
  23507. * ```
  23508. *
  23509. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  23510. */
  23511. convertIrradianceToLambertianRadiance(): void;
  23512. /**
  23513. * Gets the spherical harmonics from polynomial
  23514. * @param polynomial the spherical polynomial
  23515. * @returns the spherical harmonics
  23516. */
  23517. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  23518. /**
  23519. * Constructs a spherical harmonics from an array.
  23520. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  23521. * @returns the spherical harmonics
  23522. */
  23523. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  23524. }
  23525. }
  23526. declare module BABYLON {
  23527. /**
  23528. * Class used to store all common mesh properties
  23529. */
  23530. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23531. /** No occlusion */
  23532. static OCCLUSION_TYPE_NONE: number;
  23533. /** Occlusion set to optimisitic */
  23534. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23535. /** Occlusion set to strict */
  23536. static OCCLUSION_TYPE_STRICT: number;
  23537. /** Use an accurante occlusion algorithm */
  23538. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23539. /** Use a conservative occlusion algorithm */
  23540. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23541. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  23542. static readonly CULLINGSTRATEGY_STANDARD: number;
  23543. /** Culling strategy with bounding sphere only and then frustum culling */
  23544. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23545. /**
  23546. * No billboard
  23547. */
  23548. static readonly BILLBOARDMODE_NONE: number;
  23549. /** Billboard on X axis */
  23550. static readonly BILLBOARDMODE_X: number;
  23551. /** Billboard on Y axis */
  23552. static readonly BILLBOARDMODE_Y: number;
  23553. /** Billboard on Z axis */
  23554. static readonly BILLBOARDMODE_Z: number;
  23555. /** Billboard on all axes */
  23556. static readonly BILLBOARDMODE_ALL: number;
  23557. private _facetData;
  23558. /** Gets ot sets the culling strategy to use to find visible meshes */
  23559. cullingStrategy: number;
  23560. /**
  23561. * Gets the number of facets in the mesh
  23562. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23563. */
  23564. readonly facetNb: number;
  23565. /**
  23566. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23568. */
  23569. partitioningSubdivisions: number;
  23570. /**
  23571. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23572. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23574. */
  23575. partitioningBBoxRatio: number;
  23576. /**
  23577. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23578. * Works only for updatable meshes.
  23579. * Doesn't work with multi-materials
  23580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23581. */
  23582. mustDepthSortFacets: boolean;
  23583. /**
  23584. * The location (Vector3) where the facet depth sort must be computed from.
  23585. * By default, the active camera position.
  23586. * Used only when facet depth sort is enabled
  23587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23588. */
  23589. facetDepthSortFrom: Vector3;
  23590. /**
  23591. * gets a boolean indicating if facetData is enabled
  23592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23593. */
  23594. readonly isFacetDataEnabled: boolean;
  23595. /** @hidden */
  23596. _updateNonUniformScalingState(value: boolean): boolean;
  23597. /**
  23598. * An event triggered when this mesh collides with another one
  23599. */
  23600. onCollideObservable: Observable<AbstractMesh>;
  23601. private _onCollideObserver;
  23602. /** Set a function to call when this mesh collides with another one */
  23603. onCollide: () => void;
  23604. /**
  23605. * An event triggered when the collision's position changes
  23606. */
  23607. onCollisionPositionChangeObservable: Observable<Vector3>;
  23608. private _onCollisionPositionChangeObserver;
  23609. /** Set a function to call when the collision's position changes */
  23610. onCollisionPositionChange: () => void;
  23611. /**
  23612. * An event triggered when material is changed
  23613. */
  23614. onMaterialChangedObservable: Observable<AbstractMesh>;
  23615. /**
  23616. * Gets or sets the orientation for POV movement & rotation
  23617. */
  23618. definedFacingForward: boolean;
  23619. /** @hidden */
  23620. _occlusionQuery: Nullable<WebGLQuery>;
  23621. private _visibility;
  23622. /**
  23623. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23624. */
  23625. /**
  23626. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23627. */
  23628. visibility: number;
  23629. /** Gets or sets the alpha index used to sort transparent meshes
  23630. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23631. */
  23632. alphaIndex: number;
  23633. /**
  23634. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23635. */
  23636. isVisible: boolean;
  23637. /**
  23638. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23639. */
  23640. isPickable: boolean;
  23641. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23642. showSubMeshesBoundingBox: boolean;
  23643. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23644. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23645. */
  23646. isBlocker: boolean;
  23647. /**
  23648. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23649. */
  23650. enablePointerMoveEvents: boolean;
  23651. /**
  23652. * Specifies the rendering group id for this mesh (0 by default)
  23653. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23654. */
  23655. renderingGroupId: number;
  23656. private _material;
  23657. /** Gets or sets current material */
  23658. material: Nullable<Material>;
  23659. private _receiveShadows;
  23660. /**
  23661. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23662. * @see http://doc.babylonjs.com/babylon101/shadows
  23663. */
  23664. receiveShadows: boolean;
  23665. /** Defines color to use when rendering outline */
  23666. outlineColor: Color3;
  23667. /** Define width to use when rendering outline */
  23668. outlineWidth: number;
  23669. /** Defines color to use when rendering overlay */
  23670. overlayColor: Color3;
  23671. /** Defines alpha to use when rendering overlay */
  23672. overlayAlpha: number;
  23673. private _hasVertexAlpha;
  23674. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23675. hasVertexAlpha: boolean;
  23676. private _useVertexColors;
  23677. /** 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) */
  23678. useVertexColors: boolean;
  23679. private _computeBonesUsingShaders;
  23680. /**
  23681. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23682. */
  23683. computeBonesUsingShaders: boolean;
  23684. private _numBoneInfluencers;
  23685. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23686. numBoneInfluencers: number;
  23687. private _applyFog;
  23688. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23689. applyFog: boolean;
  23690. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23691. useOctreeForRenderingSelection: boolean;
  23692. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23693. useOctreeForPicking: boolean;
  23694. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23695. useOctreeForCollisions: boolean;
  23696. private _layerMask;
  23697. /**
  23698. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23699. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23700. */
  23701. layerMask: number;
  23702. /**
  23703. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23704. */
  23705. alwaysSelectAsActiveMesh: boolean;
  23706. /**
  23707. * Gets or sets the current action manager
  23708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23709. */
  23710. actionManager: Nullable<ActionManager>;
  23711. private _checkCollisions;
  23712. private _collisionMask;
  23713. private _collisionGroup;
  23714. /**
  23715. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23717. */
  23718. ellipsoid: Vector3;
  23719. /**
  23720. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23721. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23722. */
  23723. ellipsoidOffset: Vector3;
  23724. private _collider;
  23725. private _oldPositionForCollisions;
  23726. private _diffPositionForCollisions;
  23727. /**
  23728. * Gets or sets a collision mask used to mask collisions (default is -1).
  23729. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23730. */
  23731. collisionMask: number;
  23732. /**
  23733. * Gets or sets the current collision group mask (-1 by default).
  23734. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23735. */
  23736. collisionGroup: number;
  23737. /**
  23738. * Defines edge width used when edgesRenderer is enabled
  23739. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23740. */
  23741. edgesWidth: number;
  23742. /**
  23743. * Defines edge color used when edgesRenderer is enabled
  23744. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23745. */
  23746. edgesColor: Color4;
  23747. /** @hidden */
  23748. _edgesRenderer: Nullable<IEdgesRenderer>;
  23749. /** @hidden */
  23750. _masterMesh: Nullable<AbstractMesh>;
  23751. /** @hidden */
  23752. _boundingInfo: Nullable<BoundingInfo>;
  23753. /** @hidden */
  23754. _renderId: number;
  23755. /**
  23756. * Gets or sets the list of subMeshes
  23757. * @see http://doc.babylonjs.com/how_to/multi_materials
  23758. */
  23759. subMeshes: SubMesh[];
  23760. /** @hidden */
  23761. _intersectionsInProgress: AbstractMesh[];
  23762. /** @hidden */
  23763. _unIndexed: boolean;
  23764. /** @hidden */
  23765. _lightSources: Light[];
  23766. /** @hidden */
  23767. readonly _positions: Nullable<Vector3[]>;
  23768. /** @hidden */
  23769. _waitingActions: any;
  23770. /** @hidden */
  23771. _waitingFreezeWorldMatrix: Nullable<boolean>;
  23772. private _skeleton;
  23773. /** @hidden */
  23774. _bonesTransformMatrices: Nullable<Float32Array>;
  23775. /**
  23776. * Gets or sets a skeleton to apply skining transformations
  23777. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23778. */
  23779. skeleton: Nullable<Skeleton>;
  23780. /**
  23781. * An event triggered when the mesh is rebuilt.
  23782. */
  23783. onRebuildObservable: Observable<AbstractMesh>;
  23784. /**
  23785. * Creates a new AbstractMesh
  23786. * @param name defines the name of the mesh
  23787. * @param scene defines the hosting scene
  23788. */
  23789. constructor(name: string, scene?: Nullable<Scene>);
  23790. /**
  23791. * Returns the string "AbstractMesh"
  23792. * @returns "AbstractMesh"
  23793. */
  23794. getClassName(): string;
  23795. /**
  23796. * Gets a string representation of the current mesh
  23797. * @param fullDetails defines a boolean indicating if full details must be included
  23798. * @returns a string representation of the current mesh
  23799. */
  23800. toString(fullDetails?: boolean): string;
  23801. /** @hidden */
  23802. _rebuild(): void;
  23803. /** @hidden */
  23804. _resyncLightSources(): void;
  23805. /** @hidden */
  23806. _resyncLighSource(light: Light): void;
  23807. /** @hidden */
  23808. _unBindEffect(): void;
  23809. /** @hidden */
  23810. _removeLightSource(light: Light): void;
  23811. private _markSubMeshesAsDirty;
  23812. /** @hidden */
  23813. _markSubMeshesAsLightDirty(): void;
  23814. /** @hidden */
  23815. _markSubMeshesAsAttributesDirty(): void;
  23816. /** @hidden */
  23817. _markSubMeshesAsMiscDirty(): void;
  23818. /**
  23819. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23820. */
  23821. scaling: Vector3;
  23822. /**
  23823. * Returns true if the mesh is blocked. Implemented by child classes
  23824. */
  23825. readonly isBlocked: boolean;
  23826. /**
  23827. * Returns the mesh itself by default. Implemented by child classes
  23828. * @param camera defines the camera to use to pick the right LOD level
  23829. * @returns the currentAbstractMesh
  23830. */
  23831. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23832. /**
  23833. * Returns 0 by default. Implemented by child classes
  23834. * @returns an integer
  23835. */
  23836. getTotalVertices(): number;
  23837. /**
  23838. * Returns null by default. Implemented by child classes
  23839. * @returns null
  23840. */
  23841. getIndices(): Nullable<IndicesArray>;
  23842. /**
  23843. * Returns the array of the requested vertex data kind. Implemented by child classes
  23844. * @param kind defines the vertex data kind to use
  23845. * @returns null
  23846. */
  23847. getVerticesData(kind: string): Nullable<FloatArray>;
  23848. /**
  23849. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23850. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23851. * Note that a new underlying VertexBuffer object is created each call.
  23852. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23853. * @param kind defines vertex data kind:
  23854. * * BABYLON.VertexBuffer.PositionKind
  23855. * * BABYLON.VertexBuffer.UVKind
  23856. * * BABYLON.VertexBuffer.UV2Kind
  23857. * * BABYLON.VertexBuffer.UV3Kind
  23858. * * BABYLON.VertexBuffer.UV4Kind
  23859. * * BABYLON.VertexBuffer.UV5Kind
  23860. * * BABYLON.VertexBuffer.UV6Kind
  23861. * * BABYLON.VertexBuffer.ColorKind
  23862. * * BABYLON.VertexBuffer.MatricesIndicesKind
  23863. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23864. * * BABYLON.VertexBuffer.MatricesWeightsKind
  23865. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23866. * @param data defines the data source
  23867. * @param updatable defines if the data must be flagged as updatable (or static)
  23868. * @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
  23869. * @returns the current mesh
  23870. */
  23871. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23872. /**
  23873. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23874. * If the mesh has no geometry, it is simply returned as it is.
  23875. * @param kind defines vertex data kind:
  23876. * * BABYLON.VertexBuffer.PositionKind
  23877. * * BABYLON.VertexBuffer.UVKind
  23878. * * BABYLON.VertexBuffer.UV2Kind
  23879. * * BABYLON.VertexBuffer.UV3Kind
  23880. * * BABYLON.VertexBuffer.UV4Kind
  23881. * * BABYLON.VertexBuffer.UV5Kind
  23882. * * BABYLON.VertexBuffer.UV6Kind
  23883. * * BABYLON.VertexBuffer.ColorKind
  23884. * * BABYLON.VertexBuffer.MatricesIndicesKind
  23885. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23886. * * BABYLON.VertexBuffer.MatricesWeightsKind
  23887. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23888. * @param data defines the data source
  23889. * @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
  23890. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23891. * @returns the current mesh
  23892. */
  23893. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23894. /**
  23895. * Sets the mesh indices,
  23896. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23897. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23898. * @param totalVertices Defines the total number of vertices
  23899. * @returns the current mesh
  23900. */
  23901. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23902. /**
  23903. * Gets a boolean indicating if specific vertex data is present
  23904. * @param kind defines the vertex data kind to use
  23905. * @returns true is data kind is present
  23906. */
  23907. isVerticesDataPresent(kind: string): boolean;
  23908. /**
  23909. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23910. * @returns a BoundingInfo
  23911. */
  23912. getBoundingInfo(): BoundingInfo;
  23913. /**
  23914. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23915. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  23916. * @returns the current mesh
  23917. */
  23918. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  23919. /**
  23920. * Overwrite the current bounding info
  23921. * @param boundingInfo defines the new bounding info
  23922. * @returns the current mesh
  23923. */
  23924. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23925. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23926. readonly useBones: boolean;
  23927. /** @hidden */
  23928. _preActivate(): void;
  23929. /** @hidden */
  23930. _preActivateForIntermediateRendering(renderId: number): void;
  23931. /** @hidden */
  23932. _activate(renderId: number): void;
  23933. /**
  23934. * Gets the current world matrix
  23935. * @returns a Matrix
  23936. */
  23937. getWorldMatrix(): Matrix;
  23938. /** @hidden */
  23939. _getWorldMatrixDeterminant(): number;
  23940. /**
  23941. * Perform relative position change from the point of view of behind the front of the mesh.
  23942. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23943. * Supports definition of mesh facing forward or backward
  23944. * @param amountRight defines the distance on the right axis
  23945. * @param amountUp defines the distance on the up axis
  23946. * @param amountForward defines the distance on the forward axis
  23947. * @returns the current mesh
  23948. */
  23949. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23950. /**
  23951. * Calculate relative position change from the point of view of behind the front of the mesh.
  23952. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23953. * Supports definition of mesh facing forward or backward
  23954. * @param amountRight defines the distance on the right axis
  23955. * @param amountUp defines the distance on the up axis
  23956. * @param amountForward defines the distance on the forward axis
  23957. * @returns the new displacement vector
  23958. */
  23959. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23960. /**
  23961. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23962. * Supports definition of mesh facing forward or backward
  23963. * @param flipBack defines the flip
  23964. * @param twirlClockwise defines the twirl
  23965. * @param tiltRight defines the tilt
  23966. * @returns the current mesh
  23967. */
  23968. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23969. /**
  23970. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23971. * Supports definition of mesh facing forward or backward.
  23972. * @param flipBack defines the flip
  23973. * @param twirlClockwise defines the twirl
  23974. * @param tiltRight defines the tilt
  23975. * @returns the new rotation vector
  23976. */
  23977. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23978. /**
  23979. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23980. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23981. * @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
  23982. * @returns the new bounding vectors
  23983. */
  23984. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23985. min: Vector3;
  23986. max: Vector3;
  23987. };
  23988. /** @hidden */
  23989. _updateBoundingInfo(): AbstractMesh;
  23990. /** @hidden */
  23991. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  23992. /** @hidden */
  23993. protected _afterComputeWorldMatrix(): void;
  23994. /**
  23995. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23996. * A mesh is in the frustum if its bounding box intersects the frustum
  23997. * @param frustumPlanes defines the frustum to test
  23998. * @returns true if the mesh is in the frustum planes
  23999. */
  24000. isInFrustum(frustumPlanes: Plane[]): boolean;
  24001. /**
  24002. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24003. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24004. * @param frustumPlanes defines the frustum to test
  24005. * @returns true if the mesh is completely in the frustum planes
  24006. */
  24007. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24008. /**
  24009. * True if the mesh intersects another mesh or a SolidParticle object
  24010. * @param mesh defines a target mesh or SolidParticle to test
  24011. * @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)
  24012. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24013. * @returns true if there is an intersection
  24014. */
  24015. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24016. /**
  24017. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24018. * @param point defines the point to test
  24019. * @returns true if there is an intersection
  24020. */
  24021. intersectsPoint(point: Vector3): boolean;
  24022. /**
  24023. * Gets the position of the current mesh in camera space
  24024. * @param camera defines the camera to use
  24025. * @returns a position
  24026. */
  24027. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  24028. /**
  24029. * Returns the distance from the mesh to the active camera
  24030. * @param camera defines the camera to use
  24031. * @returns the distance
  24032. */
  24033. getDistanceToCamera(camera?: Nullable<Camera>): number;
  24034. /**
  24035. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24036. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24037. */
  24038. checkCollisions: boolean;
  24039. /**
  24040. * Gets Collider object used to compute collisions (not physics)
  24041. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24042. */
  24043. readonly collider: Collider;
  24044. /**
  24045. * Move the mesh using collision engine
  24046. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24047. * @param displacement defines the requested displacement vector
  24048. * @returns the current mesh
  24049. */
  24050. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24051. private _onCollisionPositionChange;
  24052. /** @hidden */
  24053. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24054. /** @hidden */
  24055. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24056. /** @hidden */
  24057. _checkCollision(collider: Collider): AbstractMesh;
  24058. /** @hidden */
  24059. _generatePointsArray(): boolean;
  24060. /**
  24061. * Checks if the passed Ray intersects with the mesh
  24062. * @param ray defines the ray to use
  24063. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24064. * @returns the picking info
  24065. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24066. */
  24067. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24068. /**
  24069. * Clones the current mesh
  24070. * @param name defines the mesh name
  24071. * @param newParent defines the new mesh parent
  24072. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24073. * @returns the new mesh
  24074. */
  24075. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24076. /**
  24077. * Disposes all the submeshes of the current meshnp
  24078. * @returns the current mesh
  24079. */
  24080. releaseSubMeshes(): AbstractMesh;
  24081. /**
  24082. * Releases resources associated with this abstract mesh.
  24083. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24084. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24085. */
  24086. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24087. /**
  24088. * Adds the passed mesh as a child to the current mesh
  24089. * @param mesh defines the child mesh
  24090. * @returns the current mesh
  24091. */
  24092. addChild(mesh: AbstractMesh): AbstractMesh;
  24093. /**
  24094. * Removes the passed mesh from the current mesh children list
  24095. * @param mesh defines the child mesh
  24096. * @returns the current mesh
  24097. */
  24098. removeChild(mesh: AbstractMesh): AbstractMesh;
  24099. /** @hidden */
  24100. private _initFacetData;
  24101. /**
  24102. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24103. * This method can be called within the render loop.
  24104. * 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
  24105. * @returns the current mesh
  24106. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24107. */
  24108. updateFacetData(): AbstractMesh;
  24109. /**
  24110. * Returns the facetLocalNormals array.
  24111. * The normals are expressed in the mesh local spac
  24112. * @returns an array of Vector3
  24113. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24114. */
  24115. getFacetLocalNormals(): Vector3[];
  24116. /**
  24117. * Returns the facetLocalPositions array.
  24118. * The facet positions are expressed in the mesh local space
  24119. * @returns an array of Vector3
  24120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24121. */
  24122. getFacetLocalPositions(): Vector3[];
  24123. /**
  24124. * Returns the facetLocalPartioning array
  24125. * @returns an array of array of numbers
  24126. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24127. */
  24128. getFacetLocalPartitioning(): number[][];
  24129. /**
  24130. * Returns the i-th facet position in the world system.
  24131. * This method allocates a new Vector3 per call
  24132. * @param i defines the facet index
  24133. * @returns a new Vector3
  24134. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24135. */
  24136. getFacetPosition(i: number): Vector3;
  24137. /**
  24138. * Sets the reference Vector3 with the i-th facet position in the world system
  24139. * @param i defines the facet index
  24140. * @param ref defines the target vector
  24141. * @returns the current mesh
  24142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24143. */
  24144. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24145. /**
  24146. * Returns the i-th facet normal in the world system.
  24147. * This method allocates a new Vector3 per call
  24148. * @param i defines the facet index
  24149. * @returns a new Vector3
  24150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24151. */
  24152. getFacetNormal(i: number): Vector3;
  24153. /**
  24154. * Sets the reference Vector3 with the i-th facet normal in the world system
  24155. * @param i defines the facet index
  24156. * @param ref defines the target vector
  24157. * @returns the current mesh
  24158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24159. */
  24160. getFacetNormalToRef(i: number, ref: Vector3): this;
  24161. /**
  24162. * 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)
  24163. * @param x defines x coordinate
  24164. * @param y defines y coordinate
  24165. * @param z defines z coordinate
  24166. * @returns the array of facet indexes
  24167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24168. */
  24169. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24170. /**
  24171. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24172. * @param projected sets as the (x,y,z) world projection on the facet
  24173. * @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
  24174. * @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
  24175. * @param x defines x coordinate
  24176. * @param y defines y coordinate
  24177. * @param z defines z coordinate
  24178. * @returns the face index if found (or null instead)
  24179. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24180. */
  24181. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24182. /**
  24183. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24184. * @param projected sets as the (x,y,z) local projection on the facet
  24185. * @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
  24186. * @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
  24187. * @param x defines x coordinate
  24188. * @param y defines y coordinate
  24189. * @param z defines z coordinate
  24190. * @returns the face index if found (or null instead)
  24191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24192. */
  24193. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24194. /**
  24195. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24196. * @returns the parameters
  24197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24198. */
  24199. getFacetDataParameters(): any;
  24200. /**
  24201. * Disables the feature FacetData and frees the related memory
  24202. * @returns the current mesh
  24203. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24204. */
  24205. disableFacetData(): AbstractMesh;
  24206. /**
  24207. * Updates the AbstractMesh indices array
  24208. * @param indices defines the data source
  24209. * @returns the current mesh
  24210. */
  24211. updateIndices(indices: IndicesArray): AbstractMesh;
  24212. /**
  24213. * Creates new normals data for the mesh
  24214. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24215. * @returns the current mesh
  24216. */
  24217. createNormals(updatable: boolean): AbstractMesh;
  24218. /**
  24219. * Align the mesh with a normal
  24220. * @param normal defines the normal to use
  24221. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24222. * @returns the current mesh
  24223. */
  24224. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24225. /** @hidden */
  24226. _checkOcclusionQuery(): boolean;
  24227. }
  24228. }
  24229. declare module BABYLON {
  24230. /**
  24231. * Class used to store data that will be store in GPU memory
  24232. */
  24233. class Buffer {
  24234. private _engine;
  24235. private _buffer;
  24236. /** @hidden */
  24237. _data: Nullable<DataArray>;
  24238. private _updatable;
  24239. private _instanced;
  24240. /**
  24241. * Gets the byte stride.
  24242. */
  24243. readonly byteStride: number;
  24244. /**
  24245. * Constructor
  24246. * @param engine the engine
  24247. * @param data the data to use for this buffer
  24248. * @param updatable whether the data is updatable
  24249. * @param stride the stride (optional)
  24250. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24251. * @param instanced whether the buffer is instanced (optional)
  24252. * @param useBytes set to true if the stride in in bytes (optional)
  24253. */
  24254. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24255. /**
  24256. * Create a new VertexBuffer based on the current buffer
  24257. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24258. * @param offset defines offset in the buffer (0 by default)
  24259. * @param size defines the size in floats of attributes (position is 3 for instance)
  24260. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24261. * @param instanced defines if the vertex buffer contains indexed data
  24262. * @param useBytes defines if the offset and stride are in bytes
  24263. * @returns the new vertex buffer
  24264. */
  24265. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24266. /**
  24267. * Gets a boolean indicating if the Buffer is updatable?
  24268. * @returns true if the buffer is updatable
  24269. */
  24270. isUpdatable(): boolean;
  24271. /**
  24272. * Gets current buffer's data
  24273. * @returns a DataArray or null
  24274. */
  24275. getData(): Nullable<DataArray>;
  24276. /**
  24277. * Gets underlying native buffer
  24278. * @returns underlying native buffer
  24279. */
  24280. getBuffer(): Nullable<WebGLBuffer>;
  24281. /**
  24282. * Gets the stride in float32 units (i.e. byte stride / 4).
  24283. * May not be an integer if the byte stride is not divisible by 4.
  24284. * DEPRECATED. Use byteStride instead.
  24285. * @returns the stride in float32 units
  24286. */
  24287. getStrideSize(): number;
  24288. /**
  24289. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24290. * @param data defines the data to store
  24291. */
  24292. create(data?: Nullable<DataArray>): void;
  24293. /** @hidden */
  24294. _rebuild(): void;
  24295. /**
  24296. * Update current buffer data
  24297. * @param data defines the data to store
  24298. */
  24299. update(data: DataArray): void;
  24300. /**
  24301. * Updates the data directly.
  24302. * @param data the new data
  24303. * @param offset the new offset
  24304. * @param vertexCount the vertex count (optional)
  24305. * @param useBytes set to true if the offset is in bytes
  24306. */
  24307. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  24308. /**
  24309. * Release all resources
  24310. */
  24311. dispose(): void;
  24312. }
  24313. }
  24314. declare module BABYLON {
  24315. /**
  24316. * Class for building Constructive Solid Geometry
  24317. */
  24318. class CSG {
  24319. private polygons;
  24320. /**
  24321. * The world matrix
  24322. */
  24323. matrix: Matrix;
  24324. /**
  24325. * Stores the position
  24326. */
  24327. position: Vector3;
  24328. /**
  24329. * Stores the rotation
  24330. */
  24331. rotation: Vector3;
  24332. /**
  24333. * Stores the rotation quaternion
  24334. */
  24335. rotationQuaternion: Nullable<Quaternion>;
  24336. /**
  24337. * Stores the scaling vector
  24338. */
  24339. scaling: Vector3;
  24340. /**
  24341. * Convert the BABYLON.Mesh to BABYLON.CSG
  24342. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  24343. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  24344. */
  24345. static FromMesh(mesh: Mesh): CSG;
  24346. /**
  24347. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  24348. * @param polygons Polygons used to construct a BABYLON.CSG solid
  24349. */
  24350. private static FromPolygons;
  24351. /**
  24352. * Clones, or makes a deep copy, of the BABYLON.CSG
  24353. * @returns A new BABYLON.CSG
  24354. */
  24355. clone(): CSG;
  24356. /**
  24357. * Unions this CSG with another CSG
  24358. * @param csg The CSG to union against this CSG
  24359. * @returns The unioned CSG
  24360. */
  24361. union(csg: CSG): CSG;
  24362. /**
  24363. * Unions this CSG with another CSG in place
  24364. * @param csg The CSG to union against this CSG
  24365. */
  24366. unionInPlace(csg: CSG): void;
  24367. /**
  24368. * Subtracts this CSG with another CSG
  24369. * @param csg The CSG to subtract against this CSG
  24370. * @returns A new BABYLON.CSG
  24371. */
  24372. subtract(csg: CSG): CSG;
  24373. /**
  24374. * Subtracts this CSG with another CSG in place
  24375. * @param csg The CSG to subtact against this CSG
  24376. */
  24377. subtractInPlace(csg: CSG): void;
  24378. /**
  24379. * Intersect this CSG with another CSG
  24380. * @param csg The CSG to intersect against this CSG
  24381. * @returns A new BABYLON.CSG
  24382. */
  24383. intersect(csg: CSG): CSG;
  24384. /**
  24385. * Intersects this CSG with another CSG in place
  24386. * @param csg The CSG to intersect against this CSG
  24387. */
  24388. intersectInPlace(csg: CSG): void;
  24389. /**
  24390. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  24391. * not modified.
  24392. * @returns A new BABYLON.CSG solid with solid and empty space switched
  24393. */
  24394. inverse(): CSG;
  24395. /**
  24396. * Inverses the BABYLON.CSG in place
  24397. */
  24398. inverseInPlace(): void;
  24399. /**
  24400. * This is used to keep meshes transformations so they can be restored
  24401. * when we build back a Babylon Mesh
  24402. * NB : All CSG operations are performed in world coordinates
  24403. * @param csg The BABYLON.CSG to copy the transform attributes from
  24404. * @returns This BABYLON.CSG
  24405. */
  24406. copyTransformAttributes(csg: CSG): CSG;
  24407. /**
  24408. * Build Raw mesh from CSG
  24409. * Coordinates here are in world space
  24410. * @param name The name of the mesh geometry
  24411. * @param scene The BABYLON.Scene
  24412. * @param keepSubMeshes Specifies if the submeshes should be kept
  24413. * @returns A new BABYLON.Mesh
  24414. */
  24415. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  24416. /**
  24417. * Build Mesh from CSG taking material and transforms into account
  24418. * @param name The name of the BABYLON.Mesh
  24419. * @param material The material of the BABYLON.Mesh
  24420. * @param scene The BABYLON.Scene
  24421. * @param keepSubMeshes Specifies if submeshes should be kept
  24422. * @returns The new BABYLON.Mesh
  24423. */
  24424. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  24425. }
  24426. }
  24427. declare module BABYLON {
  24428. /**
  24429. * Class used to store geometry data (vertex buffers + index buffer)
  24430. */
  24431. class Geometry implements IGetSetVerticesData {
  24432. /**
  24433. * Gets or sets the unique ID of the geometry
  24434. */
  24435. id: string;
  24436. /**
  24437. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24438. */
  24439. delayLoadState: number;
  24440. /**
  24441. * Gets the file containing the data to load when running in delay load state
  24442. */
  24443. delayLoadingFile: Nullable<string>;
  24444. /**
  24445. * Callback called when the geometry is updated
  24446. */
  24447. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24448. private _scene;
  24449. private _engine;
  24450. private _meshes;
  24451. private _totalVertices;
  24452. /** @hidden */
  24453. _indices: IndicesArray;
  24454. /** @hidden */
  24455. _vertexBuffers: {
  24456. [key: string]: VertexBuffer;
  24457. };
  24458. private _isDisposed;
  24459. private _extend;
  24460. private _boundingBias;
  24461. /** @hidden */
  24462. _delayInfo: Array<string>;
  24463. private _indexBuffer;
  24464. private _indexBufferIsUpdatable;
  24465. /** @hidden */
  24466. _boundingInfo: Nullable<BoundingInfo>;
  24467. /** @hidden */
  24468. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24469. /** @hidden */
  24470. _softwareSkinningFrameId: number;
  24471. private _vertexArrayObjects;
  24472. private _updatable;
  24473. /** @hidden */
  24474. _positions: Nullable<Vector3[]>;
  24475. /**
  24476. * 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
  24477. */
  24478. /**
  24479. * 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
  24480. */
  24481. boundingBias: Vector2;
  24482. /**
  24483. * Static function used to attach a new empty geometry to a mesh
  24484. * @param mesh defines the mesh to attach the geometry to
  24485. * @returns the new Geometry
  24486. */
  24487. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24488. /**
  24489. * Creates a new geometry
  24490. * @param id defines the unique ID
  24491. * @param scene defines the hosting scene
  24492. * @param vertexData defines the VertexData used to get geometry data
  24493. * @param updatable defines if geometry must be updatable (false by default)
  24494. * @param mesh defines the mesh that will be associated with the geometry
  24495. */
  24496. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24497. /**
  24498. * Gets the current extend of the geometry
  24499. */
  24500. readonly extend: {
  24501. minimum: Vector3;
  24502. maximum: Vector3;
  24503. };
  24504. /**
  24505. * Gets the hosting scene
  24506. * @returns the hosting Scene
  24507. */
  24508. getScene(): Scene;
  24509. /**
  24510. * Gets the hosting engine
  24511. * @returns the hosting Engine
  24512. */
  24513. getEngine(): Engine;
  24514. /**
  24515. * Defines if the geometry is ready to use
  24516. * @returns true if the geometry is ready to be used
  24517. */
  24518. isReady(): boolean;
  24519. /**
  24520. * Gets a value indicating that the geometry should not be serialized
  24521. */
  24522. readonly doNotSerialize: boolean;
  24523. /** @hidden */
  24524. _rebuild(): void;
  24525. /**
  24526. * Affects all geometry data in one call
  24527. * @param vertexData defines the geometry data
  24528. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24529. */
  24530. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24531. /**
  24532. * Set specific vertex data
  24533. * @param kind defines the data kind (Position, normal, etc...)
  24534. * @param data defines the vertex data to use
  24535. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24536. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24537. */
  24538. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24539. /**
  24540. * Removes a specific vertex data
  24541. * @param kind defines the data kind (Position, normal, etc...)
  24542. */
  24543. removeVerticesData(kind: string): void;
  24544. /**
  24545. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24546. * @param buffer defines the vertex buffer to use
  24547. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24548. */
  24549. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24550. /**
  24551. * Update a specific vertex buffer
  24552. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  24553. * It will do nothing if the buffer is not updatable
  24554. * @param kind defines the data kind (Position, normal, etc...)
  24555. * @param data defines the data to use
  24556. * @param offset defines the offset in the target buffer where to store the data
  24557. * @param useBytes set to true if the offset is in bytes
  24558. */
  24559. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24560. /**
  24561. * Update a specific vertex buffer
  24562. * This function will create a new buffer if the current one is not updatable
  24563. * @param kind defines the data kind (Position, normal, etc...)
  24564. * @param data defines the data to use
  24565. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24566. */
  24567. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24568. private _updateBoundingInfo;
  24569. /** @hidden */
  24570. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  24571. /**
  24572. * Gets total number of vertices
  24573. * @returns the total number of vertices
  24574. */
  24575. getTotalVertices(): number;
  24576. /**
  24577. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24578. * @param kind defines the data kind (Position, normal, etc...)
  24579. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24580. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24581. * @returns a float array containing vertex data
  24582. */
  24583. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24584. /**
  24585. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24586. * @param kind defines the data kind (Position, normal, etc...)
  24587. * @returns true if the vertex buffer with the specified kind is updatable
  24588. */
  24589. isVertexBufferUpdatable(kind: string): boolean;
  24590. /**
  24591. * Gets a specific vertex buffer
  24592. * @param kind defines the data kind (Position, normal, etc...)
  24593. * @returns a VertexBuffer
  24594. */
  24595. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24596. /**
  24597. * Returns all vertex buffers
  24598. * @return an object holding all vertex buffers indexed by kind
  24599. */
  24600. getVertexBuffers(): Nullable<{
  24601. [key: string]: VertexBuffer;
  24602. }>;
  24603. /**
  24604. * Gets a boolean indicating if specific vertex buffer is present
  24605. * @param kind defines the data kind (Position, normal, etc...)
  24606. * @returns true if data is present
  24607. */
  24608. isVerticesDataPresent(kind: string): boolean;
  24609. /**
  24610. * Gets a list of all attached data kinds (Position, normal, etc...)
  24611. * @returns a list of string containing all kinds
  24612. */
  24613. getVerticesDataKinds(): string[];
  24614. /**
  24615. * Update index buffer
  24616. * @param indices defines the indices to store in the index buffer
  24617. * @param offset defines the offset in the target buffer where to store the data
  24618. */
  24619. updateIndices(indices: IndicesArray, offset?: number): void;
  24620. /**
  24621. * Creates a new index buffer
  24622. * @param indices defines the indices to store in the index buffer
  24623. * @param totalVertices defines the total number of vertices (could be null)
  24624. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24625. */
  24626. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24627. /**
  24628. * Return the total number of indices
  24629. * @returns the total number of indices
  24630. */
  24631. getTotalIndices(): number;
  24632. /**
  24633. * Gets the index buffer array
  24634. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24635. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24636. * @returns the index buffer array
  24637. */
  24638. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24639. /**
  24640. * Gets the index buffer
  24641. * @return the index buffer
  24642. */
  24643. getIndexBuffer(): Nullable<WebGLBuffer>;
  24644. /** @hidden */
  24645. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24646. /**
  24647. * Release the associated resources for a specific mesh
  24648. * @param mesh defines the source mesh
  24649. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24650. */
  24651. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24652. /**
  24653. * Apply current geometry to a given mesh
  24654. * @param mesh defines the mesh to apply geometry to
  24655. */
  24656. applyToMesh(mesh: Mesh): void;
  24657. private _updateExtend;
  24658. private _applyToMesh;
  24659. private notifyUpdate;
  24660. /**
  24661. * Load the geometry if it was flagged as delay loaded
  24662. * @param scene defines the hosting scene
  24663. * @param onLoaded defines a callback called when the geometry is loaded
  24664. */
  24665. load(scene: Scene, onLoaded?: () => void): void;
  24666. private _queueLoad;
  24667. /**
  24668. * Invert the geometry to move from a right handed system to a left handed one.
  24669. */
  24670. toLeftHanded(): void;
  24671. /** @hidden */
  24672. _resetPointsArrayCache(): void;
  24673. /** @hidden */
  24674. _generatePointsArray(): boolean;
  24675. /**
  24676. * Gets a value indicating if the geometry is disposed
  24677. * @returns true if the geometry was disposed
  24678. */
  24679. isDisposed(): boolean;
  24680. private _disposeVertexArrayObjects;
  24681. /**
  24682. * Free all associated resources
  24683. */
  24684. dispose(): void;
  24685. /**
  24686. * Clone the current geometry into a new geometry
  24687. * @param id defines the unique ID of the new geometry
  24688. * @returns a new geometry object
  24689. */
  24690. copy(id: string): Geometry;
  24691. /**
  24692. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24693. * @return a JSON representation of the current geometry data (without the vertices data)
  24694. */
  24695. serialize(): any;
  24696. private toNumberArray;
  24697. /**
  24698. * Serialize all vertices data into a JSON oject
  24699. * @returns a JSON representation of the current geometry data
  24700. */
  24701. serializeVerticeData(): any;
  24702. /**
  24703. * Extracts a clone of a mesh geometry
  24704. * @param mesh defines the source mesh
  24705. * @param id defines the unique ID of the new geometry object
  24706. * @returns the new geometry object
  24707. */
  24708. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24709. /**
  24710. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24711. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24712. * Be aware Math.random() could cause collisions, but:
  24713. * "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"
  24714. * @returns a string containing a new GUID
  24715. */
  24716. static RandomId(): string;
  24717. /** @hidden */
  24718. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24719. private static _CleanMatricesWeights;
  24720. /**
  24721. * Create a new geometry from persisted data (Using .babylon file format)
  24722. * @param parsedVertexData defines the persisted data
  24723. * @param scene defines the hosting scene
  24724. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24725. * @returns the new geometry object
  24726. */
  24727. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24728. }
  24729. /**
  24730. * Abstract class used to provide common services for all typed geometries
  24731. * @hidden
  24732. */
  24733. class _PrimitiveGeometry extends Geometry {
  24734. private _canBeRegenerated;
  24735. private _beingRegenerated;
  24736. /**
  24737. * Creates a new typed geometry
  24738. * @param id defines the unique ID of the geometry
  24739. * @param scene defines the hosting scene
  24740. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24741. * @param mesh defines the hosting mesh (can be null)
  24742. */
  24743. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  24744. /**
  24745. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  24746. * @returns true if the geometry can be regenerated
  24747. */
  24748. canBeRegenerated(): boolean;
  24749. /**
  24750. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  24751. */
  24752. regenerate(): void;
  24753. /**
  24754. * Clone the geometry
  24755. * @param id defines the unique ID of the new geometry
  24756. * @returns the new geometry
  24757. */
  24758. asNewGeometry(id: string): Geometry;
  24759. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24760. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  24761. /** @hidden */
  24762. _regenerateVertexData(): VertexData;
  24763. copy(id: string): Geometry;
  24764. serialize(): any;
  24765. }
  24766. /**
  24767. * Creates a ribbon geometry
  24768. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  24769. */
  24770. class RibbonGeometry extends _PrimitiveGeometry {
  24771. /**
  24772. * Defines the array of paths to use
  24773. */
  24774. pathArray: Vector3[][];
  24775. /**
  24776. * Defines if the last and first points of each path in your pathArray must be joined
  24777. */
  24778. closeArray: boolean;
  24779. /**
  24780. * Defines if the last and first points of each path in your pathArray must be joined
  24781. */
  24782. closePath: boolean;
  24783. /**
  24784. * Defines the offset between points
  24785. */
  24786. offset: number;
  24787. /**
  24788. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24789. */
  24790. side: number;
  24791. /**
  24792. * Creates a ribbon geometry
  24793. * @param id defines the unique ID of the geometry
  24794. * @param scene defines the hosting scene
  24795. * @param pathArray defines the array of paths to use
  24796. * @param closeArray defines if the last path and the first path must be joined
  24797. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  24798. * @param offset defines the offset between points
  24799. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24800. * @param mesh defines the hosting mesh (can be null)
  24801. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24802. */
  24803. constructor(id: string, scene: Scene,
  24804. /**
  24805. * Defines the array of paths to use
  24806. */
  24807. pathArray: Vector3[][],
  24808. /**
  24809. * Defines if the last and first points of each path in your pathArray must be joined
  24810. */
  24811. closeArray: boolean,
  24812. /**
  24813. * Defines if the last and first points of each path in your pathArray must be joined
  24814. */
  24815. closePath: boolean,
  24816. /**
  24817. * Defines the offset between points
  24818. */
  24819. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  24820. /**
  24821. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24822. */
  24823. side?: number);
  24824. /** @hidden */
  24825. _regenerateVertexData(): VertexData;
  24826. copy(id: string): Geometry;
  24827. }
  24828. /**
  24829. * Creates a box geometry
  24830. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  24831. */
  24832. class BoxGeometry extends _PrimitiveGeometry {
  24833. /**
  24834. * Defines the zise of the box (width, height and depth are the same)
  24835. */
  24836. size: number;
  24837. /**
  24838. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24839. */
  24840. side: number;
  24841. /**
  24842. * Creates a box geometry
  24843. * @param id defines the unique ID of the geometry
  24844. * @param scene defines the hosting scene
  24845. * @param size defines the zise of the box (width, height and depth are the same)
  24846. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24847. * @param mesh defines the hosting mesh (can be null)
  24848. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24849. */
  24850. constructor(id: string, scene: Scene,
  24851. /**
  24852. * Defines the zise of the box (width, height and depth are the same)
  24853. */
  24854. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24855. /**
  24856. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24857. */
  24858. side?: number);
  24859. /** @hidden */
  24860. _regenerateVertexData(): VertexData;
  24861. copy(id: string): Geometry;
  24862. serialize(): any;
  24863. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  24864. }
  24865. /**
  24866. * Creates a sphere geometry
  24867. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  24868. */
  24869. class SphereGeometry extends _PrimitiveGeometry {
  24870. /**
  24871. * Defines the number of segments to use to create the sphere
  24872. */
  24873. segments: number;
  24874. /**
  24875. * Defines the diameter of the sphere
  24876. */
  24877. diameter: number;
  24878. /**
  24879. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24880. */
  24881. side: number;
  24882. /**
  24883. * Create a new sphere geometry
  24884. * @param id defines the unique ID of the geometry
  24885. * @param scene defines the hosting scene
  24886. * @param segments defines the number of segments to use to create the sphere
  24887. * @param diameter defines the diameter of the sphere
  24888. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24889. * @param mesh defines the hosting mesh (can be null)
  24890. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24891. */
  24892. constructor(id: string, scene: Scene,
  24893. /**
  24894. * Defines the number of segments to use to create the sphere
  24895. */
  24896. segments: number,
  24897. /**
  24898. * Defines the diameter of the sphere
  24899. */
  24900. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24901. /**
  24902. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24903. */
  24904. side?: number);
  24905. /** @hidden */
  24906. _regenerateVertexData(): VertexData;
  24907. copy(id: string): Geometry;
  24908. serialize(): any;
  24909. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  24910. }
  24911. /**
  24912. * Creates a disc geometry
  24913. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24914. */
  24915. class DiscGeometry extends _PrimitiveGeometry {
  24916. /**
  24917. * Defines the radius of the disc
  24918. */
  24919. radius: number;
  24920. /**
  24921. * Defines the tesselation factor to apply to the disc
  24922. */
  24923. tessellation: number;
  24924. /**
  24925. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24926. */
  24927. side: number;
  24928. /**
  24929. * Creates a new disc geometry
  24930. * @param id defines the unique ID of the geometry
  24931. * @param scene defines the hosting scene
  24932. * @param radius defines the radius of the disc
  24933. * @param tessellation defines the tesselation factor to apply to the disc
  24934. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24935. * @param mesh defines the hosting mesh (can be null)
  24936. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24937. */
  24938. constructor(id: string, scene: Scene,
  24939. /**
  24940. * Defines the radius of the disc
  24941. */
  24942. radius: number,
  24943. /**
  24944. * Defines the tesselation factor to apply to the disc
  24945. */
  24946. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24947. /**
  24948. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24949. */
  24950. side?: number);
  24951. /** @hidden */
  24952. _regenerateVertexData(): VertexData;
  24953. copy(id: string): Geometry;
  24954. }
  24955. /**
  24956. * Creates a new cylinder geometry
  24957. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  24958. */
  24959. class CylinderGeometry extends _PrimitiveGeometry {
  24960. /**
  24961. * Defines the height of the cylinder
  24962. */
  24963. height: number;
  24964. /**
  24965. * Defines the diameter of the cylinder's top cap
  24966. */
  24967. diameterTop: number;
  24968. /**
  24969. * Defines the diameter of the cylinder's bottom cap
  24970. */
  24971. diameterBottom: number;
  24972. /**
  24973. * Defines the tessellation factor to apply to the cylinder
  24974. */
  24975. tessellation: number;
  24976. /**
  24977. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  24978. */
  24979. subdivisions: number;
  24980. /**
  24981. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24982. */
  24983. side: number;
  24984. /**
  24985. * Creates a new cylinder geometry
  24986. * @param id defines the unique ID of the geometry
  24987. * @param scene defines the hosting scene
  24988. * @param height defines the height of the cylinder
  24989. * @param diameterTop defines the diameter of the cylinder's top cap
  24990. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  24991. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  24992. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  24993. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24994. * @param mesh defines the hosting mesh (can be null)
  24995. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24996. */
  24997. constructor(id: string, scene: Scene,
  24998. /**
  24999. * Defines the height of the cylinder
  25000. */
  25001. height: number,
  25002. /**
  25003. * Defines the diameter of the cylinder's top cap
  25004. */
  25005. diameterTop: number,
  25006. /**
  25007. * Defines the diameter of the cylinder's bottom cap
  25008. */
  25009. diameterBottom: number,
  25010. /**
  25011. * Defines the tessellation factor to apply to the cylinder
  25012. */
  25013. tessellation: number,
  25014. /**
  25015. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25016. */
  25017. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25018. /**
  25019. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25020. */
  25021. side?: number);
  25022. /** @hidden */
  25023. _regenerateVertexData(): VertexData;
  25024. copy(id: string): Geometry;
  25025. serialize(): any;
  25026. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25027. }
  25028. /**
  25029. * Creates a new torus geometry
  25030. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25031. */
  25032. class TorusGeometry extends _PrimitiveGeometry {
  25033. /**
  25034. * Defines the diameter of the torus
  25035. */
  25036. diameter: number;
  25037. /**
  25038. * Defines the thickness of the torus (ie. internal diameter)
  25039. */
  25040. thickness: number;
  25041. /**
  25042. * Defines the tesselation factor to apply to the torus
  25043. */
  25044. tessellation: number;
  25045. /**
  25046. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25047. */
  25048. side: number;
  25049. /**
  25050. * Creates a new torus geometry
  25051. * @param id defines the unique ID of the geometry
  25052. * @param scene defines the hosting scene
  25053. * @param diameter defines the diameter of the torus
  25054. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25055. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25056. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25057. * @param mesh defines the hosting mesh (can be null)
  25058. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25059. */
  25060. constructor(id: string, scene: Scene,
  25061. /**
  25062. * Defines the diameter of the torus
  25063. */
  25064. diameter: number,
  25065. /**
  25066. * Defines the thickness of the torus (ie. internal diameter)
  25067. */
  25068. thickness: number,
  25069. /**
  25070. * Defines the tesselation factor to apply to the torus
  25071. */
  25072. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25073. /**
  25074. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25075. */
  25076. side?: number);
  25077. /** @hidden */
  25078. _regenerateVertexData(): VertexData;
  25079. copy(id: string): Geometry;
  25080. serialize(): any;
  25081. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25082. }
  25083. /**
  25084. * Creates a new ground geometry
  25085. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25086. */
  25087. class GroundGeometry extends _PrimitiveGeometry {
  25088. /**
  25089. * Defines the width of the ground
  25090. */
  25091. width: number;
  25092. /**
  25093. * Defines the height of the ground
  25094. */
  25095. height: number;
  25096. /**
  25097. * Defines the subdivisions to apply to the ground
  25098. */
  25099. subdivisions: number;
  25100. /**
  25101. * Creates a new ground geometry
  25102. * @param id defines the unique ID of the geometry
  25103. * @param scene defines the hosting scene
  25104. * @param width defines the width of the ground
  25105. * @param height defines the height of the ground
  25106. * @param subdivisions defines the subdivisions to apply to the ground
  25107. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25108. * @param mesh defines the hosting mesh (can be null)
  25109. */
  25110. constructor(id: string, scene: Scene,
  25111. /**
  25112. * Defines the width of the ground
  25113. */
  25114. width: number,
  25115. /**
  25116. * Defines the height of the ground
  25117. */
  25118. height: number,
  25119. /**
  25120. * Defines the subdivisions to apply to the ground
  25121. */
  25122. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25123. /** @hidden */
  25124. _regenerateVertexData(): VertexData;
  25125. copy(id: string): Geometry;
  25126. serialize(): any;
  25127. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25128. }
  25129. /**
  25130. * Creates a tiled ground geometry
  25131. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25132. */
  25133. class TiledGroundGeometry extends _PrimitiveGeometry {
  25134. /**
  25135. * Defines the minimum value on X axis
  25136. */
  25137. xmin: number;
  25138. /**
  25139. * Defines the minimum value on Z axis
  25140. */
  25141. zmin: number;
  25142. /**
  25143. * Defines the maximum value on X axis
  25144. */
  25145. xmax: number;
  25146. /**
  25147. * Defines the maximum value on Z axis
  25148. */
  25149. zmax: number;
  25150. /**
  25151. * Defines the subdivisions to apply to the ground
  25152. */
  25153. subdivisions: {
  25154. w: number;
  25155. h: number;
  25156. };
  25157. /**
  25158. * Defines the precision to use when computing the tiles
  25159. */
  25160. precision: {
  25161. w: number;
  25162. h: number;
  25163. };
  25164. /**
  25165. * Creates a tiled ground geometry
  25166. * @param id defines the unique ID of the geometry
  25167. * @param scene defines the hosting scene
  25168. * @param xmin defines the minimum value on X axis
  25169. * @param zmin defines the minimum value on Z axis
  25170. * @param xmax defines the maximum value on X axis
  25171. * @param zmax defines the maximum value on Z axis
  25172. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25173. * @param precision defines the precision to use when computing the tiles
  25174. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25175. * @param mesh defines the hosting mesh (can be null)
  25176. */
  25177. constructor(id: string, scene: Scene,
  25178. /**
  25179. * Defines the minimum value on X axis
  25180. */
  25181. xmin: number,
  25182. /**
  25183. * Defines the minimum value on Z axis
  25184. */
  25185. zmin: number,
  25186. /**
  25187. * Defines the maximum value on X axis
  25188. */
  25189. xmax: number,
  25190. /**
  25191. * Defines the maximum value on Z axis
  25192. */
  25193. zmax: number,
  25194. /**
  25195. * Defines the subdivisions to apply to the ground
  25196. */
  25197. subdivisions: {
  25198. w: number;
  25199. h: number;
  25200. },
  25201. /**
  25202. * Defines the precision to use when computing the tiles
  25203. */
  25204. precision: {
  25205. w: number;
  25206. h: number;
  25207. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25208. /** @hidden */
  25209. _regenerateVertexData(): VertexData;
  25210. copy(id: string): Geometry;
  25211. }
  25212. /**
  25213. * Creates a plane geometry
  25214. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25215. */
  25216. class PlaneGeometry extends _PrimitiveGeometry {
  25217. /**
  25218. * Defines the size of the plane (width === height)
  25219. */
  25220. size: number;
  25221. /**
  25222. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25223. */
  25224. side: number;
  25225. /**
  25226. * Creates a plane geometry
  25227. * @param id defines the unique ID of the geometry
  25228. * @param scene defines the hosting scene
  25229. * @param size defines the size of the plane (width === height)
  25230. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25231. * @param mesh defines the hosting mesh (can be null)
  25232. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25233. */
  25234. constructor(id: string, scene: Scene,
  25235. /**
  25236. * Defines the size of the plane (width === height)
  25237. */
  25238. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25239. /**
  25240. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25241. */
  25242. side?: number);
  25243. /** @hidden */
  25244. _regenerateVertexData(): VertexData;
  25245. copy(id: string): Geometry;
  25246. serialize(): any;
  25247. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25248. }
  25249. /**
  25250. * Creates a torus knot geometry
  25251. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25252. */
  25253. class TorusKnotGeometry extends _PrimitiveGeometry {
  25254. /**
  25255. * Defines the radius of the torus knot
  25256. */
  25257. radius: number;
  25258. /**
  25259. * Defines the thickness of the torus knot tube
  25260. */
  25261. tube: number;
  25262. /**
  25263. * Defines the number of radial segments
  25264. */
  25265. radialSegments: number;
  25266. /**
  25267. * Defines the number of tubular segments
  25268. */
  25269. tubularSegments: number;
  25270. /**
  25271. * Defines the first number of windings
  25272. */
  25273. p: number;
  25274. /**
  25275. * Defines the second number of windings
  25276. */
  25277. q: number;
  25278. /**
  25279. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25280. */
  25281. side: number;
  25282. /**
  25283. * Creates a torus knot geometry
  25284. * @param id defines the unique ID of the geometry
  25285. * @param scene defines the hosting scene
  25286. * @param radius defines the radius of the torus knot
  25287. * @param tube defines the thickness of the torus knot tube
  25288. * @param radialSegments defines the number of radial segments
  25289. * @param tubularSegments defines the number of tubular segments
  25290. * @param p defines the first number of windings
  25291. * @param q defines the second number of windings
  25292. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25293. * @param mesh defines the hosting mesh (can be null)
  25294. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25295. */
  25296. constructor(id: string, scene: Scene,
  25297. /**
  25298. * Defines the radius of the torus knot
  25299. */
  25300. radius: number,
  25301. /**
  25302. * Defines the thickness of the torus knot tube
  25303. */
  25304. tube: number,
  25305. /**
  25306. * Defines the number of radial segments
  25307. */
  25308. radialSegments: number,
  25309. /**
  25310. * Defines the number of tubular segments
  25311. */
  25312. tubularSegments: number,
  25313. /**
  25314. * Defines the first number of windings
  25315. */
  25316. p: number,
  25317. /**
  25318. * Defines the second number of windings
  25319. */
  25320. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25321. /**
  25322. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25323. */
  25324. side?: number);
  25325. /** @hidden */
  25326. _regenerateVertexData(): VertexData;
  25327. copy(id: string): Geometry;
  25328. serialize(): any;
  25329. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  25330. }
  25331. }
  25332. declare module BABYLON {
  25333. /**
  25334. * Mesh representing the gorund
  25335. */
  25336. class GroundMesh extends Mesh {
  25337. /** If octree should be generated */
  25338. generateOctree: boolean;
  25339. private _heightQuads;
  25340. /** @hidden */
  25341. _subdivisionsX: number;
  25342. /** @hidden */
  25343. _subdivisionsY: number;
  25344. /** @hidden */
  25345. _width: number;
  25346. /** @hidden */
  25347. _height: number;
  25348. /** @hidden */
  25349. _minX: number;
  25350. /** @hidden */
  25351. _maxX: number;
  25352. /** @hidden */
  25353. _minZ: number;
  25354. /** @hidden */
  25355. _maxZ: number;
  25356. constructor(name: string, scene: Scene);
  25357. /**
  25358. * "GroundMesh"
  25359. * @returns "GroundMesh"
  25360. */
  25361. getClassName(): string;
  25362. /**
  25363. * The minimum of x and y subdivisions
  25364. */
  25365. readonly subdivisions: number;
  25366. /**
  25367. * X subdivisions
  25368. */
  25369. readonly subdivisionsX: number;
  25370. /**
  25371. * Y subdivisions
  25372. */
  25373. readonly subdivisionsY: number;
  25374. /**
  25375. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25376. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25377. * @param chunksCount the number of subdivisions for x and y
  25378. * @param octreeBlocksSize (Default: 32)
  25379. */
  25380. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25381. /**
  25382. * Returns a height (y) value in the Worl system :
  25383. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25384. * @param x x coordinate
  25385. * @param z z coordinate
  25386. * @returns the ground y position if (x, z) are outside the ground surface.
  25387. */
  25388. getHeightAtCoordinates(x: number, z: number): number;
  25389. /**
  25390. * Returns a normalized vector (Vector3) orthogonal to the ground
  25391. * at the ground coordinates (x, z) expressed in the World system.
  25392. * @param x x coordinate
  25393. * @param z z coordinate
  25394. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25395. */
  25396. getNormalAtCoordinates(x: number, z: number): Vector3;
  25397. /**
  25398. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25399. * at the ground coordinates (x, z) expressed in the World system.
  25400. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25401. * @param x x coordinate
  25402. * @param z z coordinate
  25403. * @param ref vector to store the result
  25404. * @returns the GroundMesh.
  25405. */
  25406. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25407. /**
  25408. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25409. * if the ground has been updated.
  25410. * This can be used in the render loop.
  25411. * @returns the GroundMesh.
  25412. */
  25413. updateCoordinateHeights(): GroundMesh;
  25414. private _getFacetAt;
  25415. private _initHeightQuads;
  25416. private _computeHeightQuads;
  25417. /**
  25418. * Serializes this ground mesh
  25419. * @param serializationObject object to write serialization to
  25420. */
  25421. serialize(serializationObject: any): void;
  25422. /**
  25423. * Parses a serialized ground mesh
  25424. * @param parsedMesh the serialized mesh
  25425. * @param scene the scene to create the ground mesh in
  25426. * @returns the created ground mesh
  25427. */
  25428. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25429. }
  25430. }
  25431. declare module BABYLON {
  25432. /**
  25433. * Creates an instance based on a source mesh.
  25434. */
  25435. class InstancedMesh extends AbstractMesh {
  25436. private _sourceMesh;
  25437. private _currentLOD;
  25438. constructor(name: string, source: Mesh);
  25439. /**
  25440. * Returns the string "InstancedMesh".
  25441. */
  25442. getClassName(): string;
  25443. /**
  25444. * If the source mesh receives shadows
  25445. */
  25446. readonly receiveShadows: boolean;
  25447. /**
  25448. * The material of the source mesh
  25449. */
  25450. readonly material: Nullable<Material>;
  25451. /**
  25452. * Visibility of the source mesh
  25453. */
  25454. readonly visibility: number;
  25455. /**
  25456. * Skeleton of the source mesh
  25457. */
  25458. readonly skeleton: Nullable<Skeleton>;
  25459. /**
  25460. * Rendering ground id of the source mesh
  25461. */
  25462. renderingGroupId: number;
  25463. /**
  25464. * Returns the total number of vertices (integer).
  25465. */
  25466. getTotalVertices(): number;
  25467. /**
  25468. * The source mesh of the instance
  25469. */
  25470. readonly sourceMesh: Mesh;
  25471. /**
  25472. * Is this node ready to be used/rendered
  25473. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25474. * @return {boolean} is it ready
  25475. */
  25476. isReady(completeCheck?: boolean): boolean;
  25477. /**
  25478. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25479. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  25480. * @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.
  25481. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  25482. */
  25483. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  25484. /**
  25485. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25486. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25487. * The `data` are either a numeric array either a Float32Array.
  25488. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  25489. * 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).
  25490. * Note that a new underlying VertexBuffer object is created each call.
  25491. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25492. *
  25493. * Possible `kind` values :
  25494. * - BABYLON.VertexBuffer.PositionKind
  25495. * - BABYLON.VertexBuffer.UVKind
  25496. * - BABYLON.VertexBuffer.UV2Kind
  25497. * - BABYLON.VertexBuffer.UV3Kind
  25498. * - BABYLON.VertexBuffer.UV4Kind
  25499. * - BABYLON.VertexBuffer.UV5Kind
  25500. * - BABYLON.VertexBuffer.UV6Kind
  25501. * - BABYLON.VertexBuffer.ColorKind
  25502. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25503. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25504. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25505. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25506. *
  25507. * Returns the Mesh.
  25508. */
  25509. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  25510. /**
  25511. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25512. * If the mesh has no geometry, it is simply returned as it is.
  25513. * The `data` are either a numeric array either a Float32Array.
  25514. * No new underlying VertexBuffer object is created.
  25515. * 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.
  25516. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  25517. *
  25518. * Possible `kind` values :
  25519. * - BABYLON.VertexBuffer.PositionKind
  25520. * - BABYLON.VertexBuffer.UVKind
  25521. * - BABYLON.VertexBuffer.UV2Kind
  25522. * - BABYLON.VertexBuffer.UV3Kind
  25523. * - BABYLON.VertexBuffer.UV4Kind
  25524. * - BABYLON.VertexBuffer.UV5Kind
  25525. * - BABYLON.VertexBuffer.UV6Kind
  25526. * - BABYLON.VertexBuffer.ColorKind
  25527. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25528. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25529. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25530. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25531. *
  25532. * Returns the Mesh.
  25533. */
  25534. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  25535. /**
  25536. * Sets the mesh indices.
  25537. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  25538. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25539. * This method creates a new index buffer each call.
  25540. * Returns the Mesh.
  25541. */
  25542. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  25543. /**
  25544. * Boolean : True if the mesh owns the requested kind of data.
  25545. */
  25546. isVerticesDataPresent(kind: string): boolean;
  25547. /**
  25548. * Returns an array of indices (IndicesArray).
  25549. */
  25550. getIndices(): Nullable<IndicesArray>;
  25551. readonly _positions: Nullable<Vector3[]>;
  25552. /**
  25553. * Sets a new updated BoundingInfo to the mesh.
  25554. * @returns the mesh.
  25555. */
  25556. refreshBoundingInfo(): InstancedMesh;
  25557. /** @hidden */
  25558. _preActivate(): InstancedMesh;
  25559. /** @hidden */
  25560. _activate(renderId: number): InstancedMesh;
  25561. /**
  25562. * Returns the current associated LOD AbstractMesh.
  25563. */
  25564. getLOD(camera: Camera): AbstractMesh;
  25565. /** @hidden */
  25566. _syncSubMeshes(): InstancedMesh;
  25567. /** @hidden */
  25568. _generatePointsArray(): boolean;
  25569. /**
  25570. * Creates a new InstancedMesh from the current mesh.
  25571. * - name (string) : the cloned mesh name
  25572. * - newParent (optional Node) : the optional Node to parent the clone to.
  25573. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  25574. *
  25575. * Returns the clone.
  25576. */
  25577. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  25578. /**
  25579. * Disposes the InstancedMesh.
  25580. * Returns nothing.
  25581. */
  25582. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25583. }
  25584. }
  25585. declare module BABYLON {
  25586. /**
  25587. * Line mesh
  25588. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  25589. */
  25590. class LinesMesh extends Mesh {
  25591. /**
  25592. * If vertex color should be applied to the mesh
  25593. */
  25594. useVertexColor?: boolean | undefined;
  25595. /**
  25596. * If vertex alpha should be applied to the mesh
  25597. */
  25598. useVertexAlpha?: boolean | undefined;
  25599. /**
  25600. * Color of the line (Default: White)
  25601. */
  25602. color: Color3;
  25603. /**
  25604. * Alpha of the line (Default: 1)
  25605. */
  25606. alpha: number;
  25607. /**
  25608. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  25609. * This margin is expressed in world space coordinates, so its value may vary.
  25610. * Default value is 0.1
  25611. * @returns the intersection Threshold value.
  25612. */
  25613. /**
  25614. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  25615. * This margin is expressed in world space coordinates, so its value may vary.
  25616. */
  25617. intersectionThreshold: number;
  25618. private _intersectionThreshold;
  25619. private _colorShader;
  25620. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  25621. /**
  25622. * If vertex color should be applied to the mesh
  25623. */
  25624. useVertexColor?: boolean | undefined,
  25625. /**
  25626. * If vertex alpha should be applied to the mesh
  25627. */
  25628. useVertexAlpha?: boolean | undefined);
  25629. /**
  25630. * Returns the string "LineMesh"
  25631. */
  25632. getClassName(): string;
  25633. /**
  25634. * @hidden
  25635. */
  25636. /**
  25637. * @hidden
  25638. */
  25639. material: Material;
  25640. /**
  25641. * @hidden
  25642. */
  25643. readonly checkCollisions: boolean;
  25644. /** @hidden */
  25645. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  25646. /** @hidden */
  25647. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  25648. /**
  25649. * Disposes of the line mesh
  25650. * @param doNotRecurse If children should be disposed
  25651. */
  25652. dispose(doNotRecurse?: boolean): void;
  25653. /**
  25654. * Returns a new LineMesh object cloned from the current one.
  25655. */
  25656. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  25657. }
  25658. }
  25659. declare module BABYLON {
  25660. /**
  25661. * @hidden
  25662. **/
  25663. class _CreationDataStorage {
  25664. closePath?: boolean;
  25665. closeArray?: boolean;
  25666. idx: number[];
  25667. dashSize: number;
  25668. gapSize: number;
  25669. path3D: Path3D;
  25670. pathArray: Vector3[][];
  25671. arc: number;
  25672. radius: number;
  25673. cap: number;
  25674. tessellation: number;
  25675. }
  25676. /**
  25677. * @hidden
  25678. **/
  25679. class _InstanceDataStorage {
  25680. visibleInstances: any;
  25681. renderIdForInstances: number[];
  25682. batchCache: _InstancesBatch;
  25683. instancesBufferSize: number;
  25684. instancesBuffer: Nullable<Buffer>;
  25685. instancesData: Float32Array;
  25686. overridenInstanceCount: number;
  25687. }
  25688. /**
  25689. * @hidden
  25690. **/
  25691. class _InstancesBatch {
  25692. mustReturn: boolean;
  25693. visibleInstances: Nullable<InstancedMesh[]>[];
  25694. renderSelf: boolean[];
  25695. }
  25696. /**
  25697. * Class used to represent renderable models
  25698. */
  25699. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25700. /**
  25701. * Mesh side orientation : usually the external or front surface
  25702. */
  25703. static readonly FRONTSIDE: number;
  25704. /**
  25705. * Mesh side orientation : usually the internal or back surface
  25706. */
  25707. static readonly BACKSIDE: number;
  25708. /**
  25709. * Mesh side orientation : both internal and external or front and back surfaces
  25710. */
  25711. static readonly DOUBLESIDE: number;
  25712. /**
  25713. * Mesh side orientation : by default, `FRONTSIDE`
  25714. */
  25715. static readonly DEFAULTSIDE: number;
  25716. /**
  25717. * Mesh cap setting : no cap
  25718. */
  25719. static readonly NO_CAP: number;
  25720. /**
  25721. * Mesh cap setting : one cap at the beginning of the mesh
  25722. */
  25723. static readonly CAP_START: number;
  25724. /**
  25725. * Mesh cap setting : one cap at the end of the mesh
  25726. */
  25727. static readonly CAP_END: number;
  25728. /**
  25729. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25730. */
  25731. static readonly CAP_ALL: number;
  25732. private _onBeforeRenderObservable;
  25733. private _onAfterRenderObservable;
  25734. private _onBeforeDrawObservable;
  25735. /**
  25736. * An event triggered before rendering the mesh
  25737. */
  25738. readonly onBeforeRenderObservable: Observable<Mesh>;
  25739. /**
  25740. * An event triggered after rendering the mesh
  25741. */
  25742. readonly onAfterRenderObservable: Observable<Mesh>;
  25743. /**
  25744. * An event triggered before drawing the mesh
  25745. */
  25746. readonly onBeforeDrawObservable: Observable<Mesh>;
  25747. private _onBeforeDrawObserver;
  25748. /**
  25749. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25750. */
  25751. onBeforeDraw: () => void;
  25752. /**
  25753. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25754. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25755. */
  25756. delayLoadState: number;
  25757. /**
  25758. * Gets the list of instances created from this mesh
  25759. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25760. */
  25761. instances: InstancedMesh[];
  25762. /**
  25763. * Gets the file containing delay loading data for this mesh
  25764. */
  25765. delayLoadingFile: string;
  25766. /** @hidden */
  25767. _binaryInfo: any;
  25768. private _LODLevels;
  25769. /**
  25770. * User defined function used to change how LOD level selection is done
  25771. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25772. */
  25773. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25774. private _morphTargetManager;
  25775. /**
  25776. * Gets or sets the morph target manager
  25777. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25778. */
  25779. morphTargetManager: Nullable<MorphTargetManager>;
  25780. /** @hidden */
  25781. _creationDataStorage: Nullable<_CreationDataStorage>;
  25782. /** @hidden */
  25783. _geometry: Nullable<Geometry>;
  25784. /** @hidden */
  25785. _delayInfo: Array<string>;
  25786. /** @hidden */
  25787. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25788. /** @hidden */
  25789. _instanceDataStorage: _InstanceDataStorage;
  25790. private _effectiveMaterial;
  25791. /** @hidden */
  25792. _shouldGenerateFlatShading: boolean;
  25793. private _preActivateId;
  25794. /** @hidden */
  25795. _originalBuilderSideOrientation: number;
  25796. /**
  25797. * Use this property to change the original side orientation defined at construction time
  25798. */
  25799. overrideMaterialSideOrientation: Nullable<number>;
  25800. private _areNormalsFrozen;
  25801. private _sourcePositions;
  25802. private _sourceNormals;
  25803. private _source;
  25804. /**
  25805. * Gets the source mesh (the one used to clone this one from)
  25806. */
  25807. readonly source: Nullable<Mesh>;
  25808. /**
  25809. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25810. */
  25811. isUnIndexed: boolean;
  25812. /**
  25813. * @constructor
  25814. * @param name The value used by scene.getMeshByName() to do a lookup.
  25815. * @param scene The scene to add this mesh to.
  25816. * @param parent The parent of this mesh, if it has one
  25817. * @param source An optional Mesh from which geometry is shared, cloned.
  25818. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25819. * When false, achieved by calling a clone(), also passing False.
  25820. * This will make creation of children, recursive.
  25821. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25822. */
  25823. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25824. /**
  25825. * Gets the class name
  25826. * @returns the string "Mesh".
  25827. */
  25828. getClassName(): string;
  25829. /**
  25830. * Returns a description of this mesh
  25831. * @param fullDetails define if full details about this mesh must be used
  25832. * @returns a descriptive string representing this mesh
  25833. */
  25834. toString(fullDetails?: boolean): string;
  25835. /** @hidden */
  25836. _unBindEffect(): void;
  25837. /**
  25838. * Gets a boolean indicating if this mesh has LOD
  25839. */
  25840. readonly hasLODLevels: boolean;
  25841. /**
  25842. * Gets the list of MeshLODLevel associated with the current mesh
  25843. * @returns an array of MeshLODLevel
  25844. */
  25845. getLODLevels(): MeshLODLevel[];
  25846. private _sortLODLevels;
  25847. /**
  25848. * Add a mesh as LOD level triggered at the given distance.
  25849. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25850. * @param distance The distance from the center of the object to show this level
  25851. * @param mesh The mesh to be added as LOD level (can be null)
  25852. * @return This mesh (for chaining)
  25853. */
  25854. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25855. /**
  25856. * Returns the LOD level mesh at the passed distance or null if not found.
  25857. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25858. * @param distance The distance from the center of the object to show this level
  25859. * @returns a Mesh or `null`
  25860. */
  25861. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25862. /**
  25863. * Remove a mesh from the LOD array
  25864. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25865. * @param mesh defines the mesh to be removed
  25866. * @return This mesh (for chaining)
  25867. */
  25868. removeLODLevel(mesh: Mesh): Mesh;
  25869. /**
  25870. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25871. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25872. * @param camera defines the camera to use to compute distance
  25873. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25874. * @return This mesh (for chaining)
  25875. */
  25876. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25877. /**
  25878. * Gets the mesh internal Geometry object
  25879. */
  25880. readonly geometry: Nullable<Geometry>;
  25881. /**
  25882. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25883. * @returns the total number of vertices
  25884. */
  25885. getTotalVertices(): number;
  25886. /**
  25887. * Returns the content of an associated vertex buffer
  25888. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25889. * - BABYLON.VertexBuffer.PositionKind
  25890. * - BABYLON.VertexBuffer.UVKind
  25891. * - BABYLON.VertexBuffer.UV2Kind
  25892. * - BABYLON.VertexBuffer.UV3Kind
  25893. * - BABYLON.VertexBuffer.UV4Kind
  25894. * - BABYLON.VertexBuffer.UV5Kind
  25895. * - BABYLON.VertexBuffer.UV6Kind
  25896. * - BABYLON.VertexBuffer.ColorKind
  25897. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25898. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25899. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25900. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25901. * @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
  25902. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25903. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25904. */
  25905. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25906. /**
  25907. * Returns the mesh VertexBuffer object from the requested `kind`
  25908. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25909. * - BABYLON.VertexBuffer.PositionKind
  25910. * - BABYLON.VertexBuffer.UVKind
  25911. * - BABYLON.VertexBuffer.UV2Kind
  25912. * - BABYLON.VertexBuffer.UV3Kind
  25913. * - BABYLON.VertexBuffer.UV4Kind
  25914. * - BABYLON.VertexBuffer.UV5Kind
  25915. * - BABYLON.VertexBuffer.UV6Kind
  25916. * - BABYLON.VertexBuffer.ColorKind
  25917. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25918. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25919. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25920. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25921. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25922. */
  25923. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25924. /**
  25925. * Tests if a specific vertex buffer is associated with this mesh
  25926. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25927. * - BABYLON.VertexBuffer.PositionKind
  25928. * - BABYLON.VertexBuffer.UVKind
  25929. * - BABYLON.VertexBuffer.UV2Kind
  25930. * - BABYLON.VertexBuffer.UV3Kind
  25931. * - BABYLON.VertexBuffer.UV4Kind
  25932. * - BABYLON.VertexBuffer.UV5Kind
  25933. * - BABYLON.VertexBuffer.UV6Kind
  25934. * - BABYLON.VertexBuffer.ColorKind
  25935. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25936. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25937. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25938. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25939. * @returns a boolean
  25940. */
  25941. isVerticesDataPresent(kind: string): boolean;
  25942. /**
  25943. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25944. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25945. * - BABYLON.VertexBuffer.PositionKind
  25946. * - BABYLON.VertexBuffer.UVKind
  25947. * - BABYLON.VertexBuffer.UV2Kind
  25948. * - BABYLON.VertexBuffer.UV3Kind
  25949. * - BABYLON.VertexBuffer.UV4Kind
  25950. * - BABYLON.VertexBuffer.UV5Kind
  25951. * - BABYLON.VertexBuffer.UV6Kind
  25952. * - BABYLON.VertexBuffer.ColorKind
  25953. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25954. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25955. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25956. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25957. * @returns a boolean
  25958. */
  25959. isVertexBufferUpdatable(kind: string): boolean;
  25960. /**
  25961. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25962. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25963. * - BABYLON.VertexBuffer.PositionKind
  25964. * - BABYLON.VertexBuffer.UVKind
  25965. * - BABYLON.VertexBuffer.UV2Kind
  25966. * - BABYLON.VertexBuffer.UV3Kind
  25967. * - BABYLON.VertexBuffer.UV4Kind
  25968. * - BABYLON.VertexBuffer.UV5Kind
  25969. * - BABYLON.VertexBuffer.UV6Kind
  25970. * - BABYLON.VertexBuffer.ColorKind
  25971. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25972. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25973. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25974. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25975. * @returns an array of strings
  25976. */
  25977. getVerticesDataKinds(): string[];
  25978. /**
  25979. * Returns a positive integer : the total number of indices in this mesh geometry.
  25980. * @returns the numner of indices or zero if the mesh has no geometry.
  25981. */
  25982. getTotalIndices(): number;
  25983. /**
  25984. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25985. * @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.
  25986. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25987. * @returns the indices array or an empty array if the mesh has no geometry
  25988. */
  25989. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25990. readonly isBlocked: boolean;
  25991. /**
  25992. * Determine if the current mesh is ready to be rendered
  25993. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25994. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25995. * @returns true if all associated assets are ready (material, textures, shaders)
  25996. */
  25997. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25998. /**
  25999. * 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.
  26000. */
  26001. readonly areNormalsFrozen: boolean;
  26002. /**
  26003. * 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.
  26004. * @returns the current mesh
  26005. */
  26006. freezeNormals(): Mesh;
  26007. /**
  26008. * 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
  26009. * @returns the current mesh
  26010. */
  26011. unfreezeNormals(): Mesh;
  26012. /**
  26013. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26014. */
  26015. overridenInstanceCount: number;
  26016. /** @hidden */
  26017. _preActivate(): Mesh;
  26018. /** @hidden */
  26019. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26020. /** @hidden */
  26021. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26022. /**
  26023. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26024. * This means the mesh underlying bounding box and sphere are recomputed.
  26025. * @returns the current mesh
  26026. */
  26027. refreshBoundingInfo(): Mesh;
  26028. /** @hidden */
  26029. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  26030. private _getPositionData;
  26031. /** @hidden */
  26032. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26033. /**
  26034. * This function will subdivide the mesh into multiple submeshes
  26035. * @param count defines the expected number of submeshes
  26036. */
  26037. subdivide(count: number): void;
  26038. /**
  26039. * Copy a FloatArray into a specific associated vertex buffer
  26040. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26041. * - BABYLON.VertexBuffer.PositionKind
  26042. * - BABYLON.VertexBuffer.UVKind
  26043. * - BABYLON.VertexBuffer.UV2Kind
  26044. * - BABYLON.VertexBuffer.UV3Kind
  26045. * - BABYLON.VertexBuffer.UV4Kind
  26046. * - BABYLON.VertexBuffer.UV5Kind
  26047. * - BABYLON.VertexBuffer.UV6Kind
  26048. * - BABYLON.VertexBuffer.ColorKind
  26049. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26050. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26051. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26052. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26053. * @param data defines the data source
  26054. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26055. * @param stride defines the data stride size (can be null)
  26056. * @returns the current mesh
  26057. */
  26058. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26059. /**
  26060. * Flags an associated vertex buffer as updatable
  26061. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26062. * - BABYLON.VertexBuffer.PositionKind
  26063. * - BABYLON.VertexBuffer.UVKind
  26064. * - BABYLON.VertexBuffer.UV2Kind
  26065. * - BABYLON.VertexBuffer.UV3Kind
  26066. * - BABYLON.VertexBuffer.UV4Kind
  26067. * - BABYLON.VertexBuffer.UV5Kind
  26068. * - BABYLON.VertexBuffer.UV6Kind
  26069. * - BABYLON.VertexBuffer.ColorKind
  26070. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26071. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26072. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26073. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26074. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26075. */
  26076. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26077. /**
  26078. * Sets the mesh global Vertex Buffer
  26079. * @param buffer defines the buffer to use
  26080. * @returns the current mesh
  26081. */
  26082. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26083. /**
  26084. * Update a specific associated vertex buffer
  26085. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26086. * - BABYLON.VertexBuffer.PositionKind
  26087. * - BABYLON.VertexBuffer.UVKind
  26088. * - BABYLON.VertexBuffer.UV2Kind
  26089. * - BABYLON.VertexBuffer.UV3Kind
  26090. * - BABYLON.VertexBuffer.UV4Kind
  26091. * - BABYLON.VertexBuffer.UV5Kind
  26092. * - BABYLON.VertexBuffer.UV6Kind
  26093. * - BABYLON.VertexBuffer.ColorKind
  26094. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26095. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26096. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26097. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26098. * @param data defines the data source
  26099. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26100. * @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)
  26101. * @returns the current mesh
  26102. */
  26103. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26104. /**
  26105. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26106. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26107. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26108. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26109. * @returns the current mesh
  26110. */
  26111. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26112. /**
  26113. * Creates a un-shared specific occurence of the geometry for the mesh.
  26114. * @returns the current mesh
  26115. */
  26116. makeGeometryUnique(): Mesh;
  26117. /**
  26118. * Set the index buffer of this mesh
  26119. * @param indices defines the source data
  26120. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26121. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26122. * @returns the current mesh
  26123. */
  26124. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26125. /**
  26126. * Update the current index buffer
  26127. * @param indices defines the source data
  26128. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26129. * @returns the current mesh
  26130. */
  26131. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26132. /**
  26133. * Invert the geometry to move from a right handed system to a left handed one.
  26134. * @returns the current mesh
  26135. */
  26136. toLeftHanded(): Mesh;
  26137. /** @hidden */
  26138. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26139. /** @hidden */
  26140. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26141. /**
  26142. * Registers for this mesh a javascript function called just before the rendering process
  26143. * @param func defines the function to call before rendering this mesh
  26144. * @returns the current mesh
  26145. */
  26146. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26147. /**
  26148. * Disposes a previously registered javascript function called before the rendering
  26149. * @param func defines the function to remove
  26150. * @returns the current mesh
  26151. */
  26152. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26153. /**
  26154. * Registers for this mesh a javascript function called just after the rendering is complete
  26155. * @param func defines the function to call after rendering this mesh
  26156. * @returns the current mesh
  26157. */
  26158. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26159. /**
  26160. * Disposes a previously registered javascript function called after the rendering.
  26161. * @param func defines the function to remove
  26162. * @returns the current mesh
  26163. */
  26164. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26165. /** @hidden */
  26166. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26167. /** @hidden */
  26168. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26169. /** @hidden */
  26170. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26171. /**
  26172. * 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
  26173. * @param subMesh defines the subMesh to render
  26174. * @param enableAlphaMode defines if alpha mode can be changed
  26175. * @returns the current mesh
  26176. */
  26177. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26178. private _onBeforeDraw;
  26179. /**
  26180. * Renormalize the mesh and patch it up if there are no weights
  26181. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26182. * However in the case of zero weights then we set just a single influence to 1.
  26183. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26184. */
  26185. cleanMatrixWeights(): void;
  26186. private normalizeSkinFourWeights;
  26187. private normalizeSkinWeightsAndExtra;
  26188. /**
  26189. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26190. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26191. * the user know there was an issue with importing the mesh
  26192. * @returns a validation object with skinned, valid and report string
  26193. */
  26194. validateSkinning(): {
  26195. skinned: boolean;
  26196. valid: boolean;
  26197. report: string;
  26198. };
  26199. /** @hidden */
  26200. _checkDelayState(): Mesh;
  26201. private _queueLoad;
  26202. /**
  26203. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26204. * A mesh is in the frustum if its bounding box intersects the frustum
  26205. * @param frustumPlanes defines the frustum to test
  26206. * @returns true if the mesh is in the frustum planes
  26207. */
  26208. isInFrustum(frustumPlanes: Plane[]): boolean;
  26209. /**
  26210. * Sets the mesh material by the material or multiMaterial `id` property
  26211. * @param id is a string identifying the material or the multiMaterial
  26212. * @returns the current mesh
  26213. */
  26214. setMaterialByID(id: string): Mesh;
  26215. /**
  26216. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26217. * @returns an array of IAnimatable
  26218. */
  26219. getAnimatables(): IAnimatable[];
  26220. /**
  26221. * Modifies the mesh geometry according to the passed transformation matrix.
  26222. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26223. * The mesh normals are modified using the same transformation.
  26224. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26225. * @param transform defines the transform matrix to use
  26226. * @see http://doc.babylonjs.com/resources/baking_transformations
  26227. * @returns the current mesh
  26228. */
  26229. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26230. /**
  26231. * Modifies the mesh geometry according to its own current World Matrix.
  26232. * The mesh World Matrix is then reset.
  26233. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26234. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26235. * @see http://doc.babylonjs.com/resources/baking_transformations
  26236. * @returns the current mesh
  26237. */
  26238. bakeCurrentTransformIntoVertices(): Mesh;
  26239. /** @hidden */
  26240. readonly _positions: Nullable<Vector3[]>;
  26241. /** @hidden */
  26242. _resetPointsArrayCache(): Mesh;
  26243. /** @hidden */
  26244. _generatePointsArray(): boolean;
  26245. /**
  26246. * Returns a new Mesh object generated from the current mesh properties.
  26247. * This method must not get confused with createInstance()
  26248. * @param name is a string, the name given to the new mesh
  26249. * @param newParent can be any Node object (default `null`)
  26250. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26251. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26252. * @returns a new mesh
  26253. */
  26254. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26255. /**
  26256. * Releases resources associated with this mesh.
  26257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26259. */
  26260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26261. /**
  26262. * Modifies the mesh geometry according to a displacement map.
  26263. * 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.
  26264. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26265. * @param url is a string, the URL from the image file is to be downloaded.
  26266. * @param minHeight is the lower limit of the displacement.
  26267. * @param maxHeight is the upper limit of the displacement.
  26268. * @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.
  26269. * @param uvOffset is an optional vector2 used to offset UV.
  26270. * @param uvScale is an optional vector2 used to scale UV.
  26271. * @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.
  26272. * @returns the Mesh.
  26273. */
  26274. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26275. /**
  26276. * Modifies the mesh geometry according to a displacementMap buffer.
  26277. * 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.
  26278. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26279. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26280. * @param heightMapWidth is the width of the buffer image.
  26281. * @param heightMapHeight is the height of the buffer image.
  26282. * @param minHeight is the lower limit of the displacement.
  26283. * @param maxHeight is the upper limit of the displacement.
  26284. * @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.
  26285. * @param uvOffset is an optional vector2 used to offset UV.
  26286. * @param uvScale is an optional vector2 used to scale UV.
  26287. * @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.
  26288. * @returns the Mesh.
  26289. */
  26290. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26291. /**
  26292. * Modify the mesh to get a flat shading rendering.
  26293. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26294. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26295. * @returns current mesh
  26296. */
  26297. convertToFlatShadedMesh(): Mesh;
  26298. /**
  26299. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26300. * In other words, more vertices, no more indices and a single bigger VBO.
  26301. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26302. * @returns current mesh
  26303. */
  26304. convertToUnIndexedMesh(): Mesh;
  26305. /**
  26306. * Inverses facet orientations.
  26307. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26308. * @param flipNormals will also inverts the normals
  26309. * @returns current mesh
  26310. */
  26311. flipFaces(flipNormals?: boolean): Mesh;
  26312. /**
  26313. * Creates a new InstancedMesh object from the mesh model.
  26314. * Warning : this method is not supported for Line mesh and LineSystem
  26315. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26316. * @param name defines the name of the new instance
  26317. * @returns a new InstancedMesh
  26318. */
  26319. createInstance(name: string): InstancedMesh;
  26320. /**
  26321. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26322. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26323. * @returns the current mesh
  26324. */
  26325. synchronizeInstances(): Mesh;
  26326. /**
  26327. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26328. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26329. * This should be used together with the simplification to avoid disappearing triangles.
  26330. * @param successCallback an optional success callback to be called after the optimization finished.
  26331. * @returns the current mesh
  26332. */
  26333. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26334. /**
  26335. * Serialize current mesh
  26336. * @param serializationObject defines the object which will receive the serialization data
  26337. */
  26338. serialize(serializationObject: any): void;
  26339. /** @hidden */
  26340. _syncGeometryWithMorphTargetManager(): void;
  26341. /**
  26342. * Returns a new Mesh object parsed from the source provided.
  26343. * @param parsedMesh is the source
  26344. * @param scene defines the hosting scene
  26345. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26346. * @returns a new Mesh
  26347. */
  26348. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26349. /**
  26350. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26351. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26352. * @param name defines the name of the mesh to create
  26353. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26354. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26355. * @param closePath creates a seam between the first and the last points of each path of the path array
  26356. * @param offset is taken in account only if the `pathArray` is containing a single path
  26357. * @param scene defines the hosting scene
  26358. * @param updatable defines if the mesh must be flagged as updatable
  26359. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26360. * @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)
  26361. * @returns a new Mesh
  26362. */
  26363. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26364. /**
  26365. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26366. * @param name defines the name of the mesh to create
  26367. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26368. * @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
  26369. * @param scene defines the hosting scene
  26370. * @param updatable defines if the mesh must be flagged as updatable
  26371. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26372. * @returns a new Mesh
  26373. */
  26374. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26375. /**
  26376. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26377. * @param name defines the name of the mesh to create
  26378. * @param size sets the size (float) of each box side (default 1)
  26379. * @param scene defines the hosting scene
  26380. * @param updatable defines if the mesh must be flagged as updatable
  26381. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26382. * @returns a new Mesh
  26383. */
  26384. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26385. /**
  26386. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26387. * @param name defines the name of the mesh to create
  26388. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26389. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26390. * @param scene defines the hosting scene
  26391. * @param updatable defines if the mesh must be flagged as updatable
  26392. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26393. * @returns a new Mesh
  26394. */
  26395. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26396. /**
  26397. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26398. * @param name defines the name of the mesh to create
  26399. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26400. * @param diameterTop set the top cap diameter (floats, default 1)
  26401. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26402. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26403. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26404. * @param scene defines the hosting scene
  26405. * @param updatable defines if the mesh must be flagged as updatable
  26406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26407. * @returns a new Mesh
  26408. */
  26409. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26410. /**
  26411. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26412. * @param name defines the name of the mesh to create
  26413. * @param diameter sets the diameter size (float) of the torus (default 1)
  26414. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26415. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26416. * @param scene defines the hosting scene
  26417. * @param updatable defines if the mesh must be flagged as updatable
  26418. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26419. * @returns a new Mesh
  26420. */
  26421. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26422. /**
  26423. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26424. * @param name defines the name of the mesh to create
  26425. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26426. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26427. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26428. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26429. * @param p the number of windings on X axis (positive integers, default 2)
  26430. * @param q the number of windings on Y axis (positive integers, default 3)
  26431. * @param scene defines the hosting scene
  26432. * @param updatable defines if the mesh must be flagged as updatable
  26433. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26434. * @returns a new Mesh
  26435. */
  26436. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26437. /**
  26438. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26439. * @param name defines the name of the mesh to create
  26440. * @param points is an array successive Vector3
  26441. * @param scene defines the hosting scene
  26442. * @param updatable defines if the mesh must be flagged as updatable
  26443. * @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).
  26444. * @returns a new Mesh
  26445. */
  26446. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26447. /**
  26448. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26449. * @param name defines the name of the mesh to create
  26450. * @param points is an array successive Vector3
  26451. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26452. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26453. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26454. * @param scene defines the hosting scene
  26455. * @param updatable defines if the mesh must be flagged as updatable
  26456. * @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)
  26457. * @returns a new Mesh
  26458. */
  26459. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26460. /**
  26461. * Creates a polygon mesh.
  26462. * Please consider using the same method from the MeshBuilder class instead.
  26463. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26464. * 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.
  26465. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26466. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26467. * Remember you can only change the shape positions, not their number when updating a polygon.
  26468. */
  26469. /**
  26470. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26471. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26472. * @param name defines the name of the mesh to create
  26473. * @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
  26474. * @param scene defines the hosting scene
  26475. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26476. * @param updatable defines if the mesh must be flagged as updatable
  26477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26478. * @returns a new Mesh
  26479. */
  26480. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26481. /**
  26482. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26483. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26484. * @param name defines the name of the mesh to create
  26485. * @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
  26486. * @param depth defines the height of extrusion
  26487. * @param scene defines the hosting scene
  26488. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26489. * @param updatable defines if the mesh must be flagged as updatable
  26490. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26491. * @returns a new Mesh
  26492. */
  26493. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26494. /**
  26495. * Creates an extruded shape mesh.
  26496. * 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
  26497. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26498. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26499. * @param name defines the name of the mesh to create
  26500. * @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
  26501. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26502. * @param scale is the value to scale the shape
  26503. * @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
  26504. * @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
  26505. * @param scene defines the hosting scene
  26506. * @param updatable defines if the mesh must be flagged as updatable
  26507. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26508. * @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)
  26509. * @returns a new Mesh
  26510. */
  26511. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26512. /**
  26513. * Creates an custom extruded shape mesh.
  26514. * The custom extrusion is a parametric shape.
  26515. * It has no predefined shape. Its final shape will depend on the input parameters.
  26516. * Please consider using the same method from the MeshBuilder class instead
  26517. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26518. * @param name defines the name of the mesh to create
  26519. * @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
  26520. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26521. * @param scaleFunction is a custom Javascript function called on each path point
  26522. * @param rotationFunction is a custom Javascript function called on each path point
  26523. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26524. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26525. * @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
  26526. * @param scene defines the hosting scene
  26527. * @param updatable defines if the mesh must be flagged as updatable
  26528. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26529. * @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)
  26530. * @returns a new Mesh
  26531. */
  26532. 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;
  26533. /**
  26534. * Creates lathe mesh.
  26535. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26536. * Please consider using the same method from the MeshBuilder class instead
  26537. * @param name defines the name of the mesh to create
  26538. * @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
  26539. * @param radius is the radius value of the lathe
  26540. * @param tessellation is the side number of the lathe.
  26541. * @param scene defines the hosting scene
  26542. * @param updatable defines if the mesh must be flagged as updatable
  26543. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26544. * @returns a new Mesh
  26545. */
  26546. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26547. /**
  26548. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26549. * @param name defines the name of the mesh to create
  26550. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26551. * @param scene defines the hosting scene
  26552. * @param updatable defines if the mesh must be flagged as updatable
  26553. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26554. * @returns a new Mesh
  26555. */
  26556. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26557. /**
  26558. * Creates a ground mesh.
  26559. * Please consider using the same method from the MeshBuilder class instead
  26560. * @param name defines the name of the mesh to create
  26561. * @param width set the width of the ground
  26562. * @param height set the height of the ground
  26563. * @param subdivisions sets the number of subdivisions per side
  26564. * @param scene defines the hosting scene
  26565. * @param updatable defines if the mesh must be flagged as updatable
  26566. * @returns a new Mesh
  26567. */
  26568. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26569. /**
  26570. * Creates a tiled ground mesh.
  26571. * Please consider using the same method from the MeshBuilder class instead
  26572. * @param name defines the name of the mesh to create
  26573. * @param xmin set the ground minimum X coordinate
  26574. * @param zmin set the ground minimum Y coordinate
  26575. * @param xmax set the ground maximum X coordinate
  26576. * @param zmax set the ground maximum Z coordinate
  26577. * @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
  26578. * @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
  26579. * @param scene defines the hosting scene
  26580. * @param updatable defines if the mesh must be flagged as updatable
  26581. * @returns a new Mesh
  26582. */
  26583. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26584. w: number;
  26585. h: number;
  26586. }, precision: {
  26587. w: number;
  26588. h: number;
  26589. }, scene: Scene, updatable?: boolean): Mesh;
  26590. /**
  26591. * Creates a ground mesh from a height map.
  26592. * Please consider using the same method from the MeshBuilder class instead
  26593. * @see http://doc.babylonjs.com/babylon101/height_map
  26594. * @param name defines the name of the mesh to create
  26595. * @param url sets the URL of the height map image resource
  26596. * @param width set the ground width size
  26597. * @param height set the ground height size
  26598. * @param subdivisions sets the number of subdivision per side
  26599. * @param minHeight is the minimum altitude on the ground
  26600. * @param maxHeight is the maximum altitude on the ground
  26601. * @param scene defines the hosting scene
  26602. * @param updatable defines if the mesh must be flagged as updatable
  26603. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26604. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26605. * @returns a new Mesh
  26606. */
  26607. 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;
  26608. /**
  26609. * Creates a tube mesh.
  26610. * The tube is a parametric shape.
  26611. * It has no predefined shape. Its final shape will depend on the input parameters.
  26612. * Please consider using the same method from the MeshBuilder class instead
  26613. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26614. * @param name defines the name of the mesh to create
  26615. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26616. * @param radius sets the tube radius size
  26617. * @param tessellation is the number of sides on the tubular surface
  26618. * @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
  26619. * @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
  26620. * @param scene defines the hosting scene
  26621. * @param updatable defines if the mesh must be flagged as updatable
  26622. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26623. * @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)
  26624. * @returns a new Mesh
  26625. */
  26626. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26627. (i: number, distance: number): number;
  26628. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26629. /**
  26630. * Creates a polyhedron mesh.
  26631. * Please consider using the same method from the MeshBuilder class instead.
  26632. * * 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
  26633. * * The parameter `size` (positive float, default 1) sets the polygon size
  26634. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26635. * * 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`
  26636. * * 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
  26637. * * 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)`)
  26638. * * 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
  26639. * * 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
  26640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26641. * * 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
  26642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26643. * @param name defines the name of the mesh to create
  26644. * @param options defines the options used to create the mesh
  26645. * @param scene defines the hosting scene
  26646. * @returns a new Mesh
  26647. */
  26648. static CreatePolyhedron(name: string, options: {
  26649. type?: number;
  26650. size?: number;
  26651. sizeX?: number;
  26652. sizeY?: number;
  26653. sizeZ?: number;
  26654. custom?: any;
  26655. faceUV?: Vector4[];
  26656. faceColors?: Color4[];
  26657. updatable?: boolean;
  26658. sideOrientation?: number;
  26659. }, scene: Scene): Mesh;
  26660. /**
  26661. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26662. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26663. * * 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`)
  26664. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26665. * * 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
  26666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26667. * * 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
  26668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26669. * @param name defines the name of the mesh
  26670. * @param options defines the options used to create the mesh
  26671. * @param scene defines the hosting scene
  26672. * @returns a new Mesh
  26673. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26674. */
  26675. static CreateIcoSphere(name: string, options: {
  26676. radius?: number;
  26677. flat?: boolean;
  26678. subdivisions?: number;
  26679. sideOrientation?: number;
  26680. updatable?: boolean;
  26681. }, scene: Scene): Mesh;
  26682. /**
  26683. * Creates a decal mesh.
  26684. * Please consider using the same method from the MeshBuilder class instead.
  26685. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26686. * @param name defines the name of the mesh
  26687. * @param sourceMesh defines the mesh receiving the decal
  26688. * @param position sets the position of the decal in world coordinates
  26689. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26690. * @param size sets the decal scaling
  26691. * @param angle sets the angle to rotate the decal
  26692. * @returns a new Mesh
  26693. */
  26694. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26695. /**
  26696. * Prepare internal position array for software CPU skinning
  26697. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26698. */
  26699. setPositionsForCPUSkinning(): Float32Array;
  26700. /**
  26701. * Prepare internal normal array for software CPU skinning
  26702. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26703. */
  26704. setNormalsForCPUSkinning(): Float32Array;
  26705. /**
  26706. * Updates the vertex buffer by applying transformation from the bones
  26707. * @param skeleton defines the skeleton to apply to current mesh
  26708. * @returns the current mesh
  26709. */
  26710. applySkeleton(skeleton: Skeleton): Mesh;
  26711. /**
  26712. * 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
  26713. * @param meshes defines the list of meshes to scan
  26714. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26715. */
  26716. static MinMax(meshes: AbstractMesh[]): {
  26717. min: Vector3;
  26718. max: Vector3;
  26719. };
  26720. /**
  26721. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26722. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26723. * @returns a vector3
  26724. */
  26725. static Center(meshesOrMinMaxVector: {
  26726. min: Vector3;
  26727. max: Vector3;
  26728. } | AbstractMesh[]): Vector3;
  26729. /**
  26730. * Merge the array of meshes into a single mesh for performance reasons.
  26731. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26732. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26733. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26734. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26735. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26736. * @returns a new mesh
  26737. */
  26738. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  26739. }
  26740. }
  26741. declare module BABYLON {
  26742. /**
  26743. * Define an interface for all classes that will get and set the data on vertices
  26744. */
  26745. interface IGetSetVerticesData {
  26746. /**
  26747. * Gets a boolean indicating if specific vertex data is present
  26748. * @param kind defines the vertex data kind to use
  26749. * @returns true is data kind is present
  26750. */
  26751. isVerticesDataPresent(kind: string): boolean;
  26752. /**
  26753. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26754. * @param kind defines the data kind (Position, normal, etc...)
  26755. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26756. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26757. * @returns a float array containing vertex data
  26758. */
  26759. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26760. /**
  26761. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26762. * @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.
  26763. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26764. * @returns the indices array or an empty array if the mesh has no geometry
  26765. */
  26766. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26767. /**
  26768. * Set specific vertex data
  26769. * @param kind defines the data kind (Position, normal, etc...)
  26770. * @param data defines the vertex data to use
  26771. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26772. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26773. */
  26774. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26775. /**
  26776. * Update a specific associated vertex buffer
  26777. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26778. * - BABYLON.VertexBuffer.PositionKind
  26779. * - BABYLON.VertexBuffer.UVKind
  26780. * - BABYLON.VertexBuffer.UV2Kind
  26781. * - BABYLON.VertexBuffer.UV3Kind
  26782. * - BABYLON.VertexBuffer.UV4Kind
  26783. * - BABYLON.VertexBuffer.UV5Kind
  26784. * - BABYLON.VertexBuffer.UV6Kind
  26785. * - BABYLON.VertexBuffer.ColorKind
  26786. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26787. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26788. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26789. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26790. * @param data defines the data source
  26791. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26792. * @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)
  26793. */
  26794. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26795. /**
  26796. * Creates a new index buffer
  26797. * @param indices defines the indices to store in the index buffer
  26798. * @param totalVertices defines the total number of vertices (could be null)
  26799. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26800. */
  26801. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26802. }
  26803. /**
  26804. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26805. */
  26806. class VertexData {
  26807. /**
  26808. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26809. */
  26810. positions: Nullable<FloatArray>;
  26811. /**
  26812. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26813. */
  26814. normals: Nullable<FloatArray>;
  26815. /**
  26816. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26817. */
  26818. tangents: Nullable<FloatArray>;
  26819. /**
  26820. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26821. */
  26822. uvs: Nullable<FloatArray>;
  26823. /**
  26824. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26825. */
  26826. uvs2: Nullable<FloatArray>;
  26827. /**
  26828. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26829. */
  26830. uvs3: Nullable<FloatArray>;
  26831. /**
  26832. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26833. */
  26834. uvs4: Nullable<FloatArray>;
  26835. /**
  26836. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26837. */
  26838. uvs5: Nullable<FloatArray>;
  26839. /**
  26840. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26841. */
  26842. uvs6: Nullable<FloatArray>;
  26843. /**
  26844. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26845. */
  26846. colors: Nullable<FloatArray>;
  26847. /**
  26848. * 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).
  26849. */
  26850. matricesIndices: Nullable<FloatArray>;
  26851. /**
  26852. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26853. */
  26854. matricesWeights: Nullable<FloatArray>;
  26855. /**
  26856. * An array extending the number of possible indices
  26857. */
  26858. matricesIndicesExtra: Nullable<FloatArray>;
  26859. /**
  26860. * An array extending the number of possible weights when the number of indices is extended
  26861. */
  26862. matricesWeightsExtra: Nullable<FloatArray>;
  26863. /**
  26864. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26865. */
  26866. indices: Nullable<IndicesArray>;
  26867. /**
  26868. * Uses the passed data array to set the set the values for the specified kind of data
  26869. * @param data a linear array of floating numbers
  26870. * @param kind the type of data that is being set, eg positions, colors etc
  26871. */
  26872. set(data: FloatArray, kind: string): void;
  26873. /**
  26874. * Associates the vertexData to the passed Mesh.
  26875. * Sets it as updatable or not (default `false`)
  26876. * @param mesh the mesh the vertexData is applied to
  26877. * @param updatable when used and having the value true allows new data to update the vertexData
  26878. * @returns the VertexData
  26879. */
  26880. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26881. /**
  26882. * Associates the vertexData to the passed Geometry.
  26883. * Sets it as updatable or not (default `false`)
  26884. * @param geometry the geometry the vertexData is applied to
  26885. * @param updatable when used and having the value true allows new data to update the vertexData
  26886. * @returns VertexData
  26887. */
  26888. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26889. /**
  26890. * Updates the associated mesh
  26891. * @param mesh the mesh to be updated
  26892. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26893. * @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
  26894. * @returns VertexData
  26895. */
  26896. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  26897. /**
  26898. * Updates the associated geometry
  26899. * @param geometry the geometry to be updated
  26900. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26901. * @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
  26902. * @returns VertexData.
  26903. */
  26904. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  26905. private _applyTo;
  26906. private _update;
  26907. /**
  26908. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26909. * @param matrix the transforming matrix
  26910. * @returns the VertexData
  26911. */
  26912. transform(matrix: Matrix): VertexData;
  26913. /**
  26914. * Merges the passed VertexData into the current one
  26915. * @param other the VertexData to be merged into the current one
  26916. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26917. * @returns the modified VertexData
  26918. */
  26919. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26920. private _mergeElement;
  26921. private _validate;
  26922. /**
  26923. * Serializes the VertexData
  26924. * @returns a serialized object
  26925. */
  26926. serialize(): any;
  26927. /**
  26928. * Extracts the vertexData from a mesh
  26929. * @param mesh the mesh from which to extract the VertexData
  26930. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26931. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26932. * @returns the object VertexData associated to the passed mesh
  26933. */
  26934. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26935. /**
  26936. * Extracts the vertexData from the geometry
  26937. * @param geometry the geometry from which to extract the VertexData
  26938. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26939. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26940. * @returns the object VertexData associated to the passed mesh
  26941. */
  26942. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26943. private static _ExtractFrom;
  26944. /**
  26945. * Creates the VertexData for a Ribbon
  26946. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26947. * * pathArray array of paths, each of which an array of successive Vector3
  26948. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26949. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26950. * * 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
  26951. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26952. * * 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)
  26953. * * 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)
  26954. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26955. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26956. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26957. * @returns the VertexData of the ribbon
  26958. */
  26959. static CreateRibbon(options: {
  26960. pathArray: Vector3[][];
  26961. closeArray?: boolean;
  26962. closePath?: boolean;
  26963. offset?: number;
  26964. sideOrientation?: number;
  26965. frontUVs?: Vector4;
  26966. backUVs?: Vector4;
  26967. invertUV?: boolean;
  26968. uvs?: Vector2[];
  26969. colors?: Color4[];
  26970. }): VertexData;
  26971. /**
  26972. * Creates the VertexData for a box
  26973. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26974. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26975. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26976. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26977. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26978. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26979. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26980. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26981. * * 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)
  26982. * * 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)
  26983. * @returns the VertexData of the box
  26984. */
  26985. static CreateBox(options: {
  26986. size?: number;
  26987. width?: number;
  26988. height?: number;
  26989. depth?: number;
  26990. faceUV?: Vector4[];
  26991. faceColors?: Color4[];
  26992. sideOrientation?: number;
  26993. frontUVs?: Vector4;
  26994. backUVs?: Vector4;
  26995. }): VertexData;
  26996. /**
  26997. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26998. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26999. * * segments sets the number of horizontal strips optional, default 32
  27000. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27001. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27002. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27003. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27004. * * 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
  27005. * * 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
  27006. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27007. * * 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)
  27008. * * 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)
  27009. * @returns the VertexData of the ellipsoid
  27010. */
  27011. static CreateSphere(options: {
  27012. segments?: number;
  27013. diameter?: number;
  27014. diameterX?: number;
  27015. diameterY?: number;
  27016. diameterZ?: number;
  27017. arc?: number;
  27018. slice?: number;
  27019. sideOrientation?: number;
  27020. frontUVs?: Vector4;
  27021. backUVs?: Vector4;
  27022. }): VertexData;
  27023. /**
  27024. * Creates the VertexData for a cylinder, cone or prism
  27025. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27026. * * height sets the height (y direction) of the cylinder, optional, default 2
  27027. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27028. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27029. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27030. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27031. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27032. * * 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
  27033. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27034. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27035. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27036. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27037. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27038. * * 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)
  27039. * * 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)
  27040. * @returns the VertexData of the cylinder, cone or prism
  27041. */
  27042. static CreateCylinder(options: {
  27043. height?: number;
  27044. diameterTop?: number;
  27045. diameterBottom?: number;
  27046. diameter?: number;
  27047. tessellation?: number;
  27048. subdivisions?: number;
  27049. arc?: number;
  27050. faceColors?: Color4[];
  27051. faceUV?: Vector4[];
  27052. hasRings?: boolean;
  27053. enclose?: boolean;
  27054. sideOrientation?: number;
  27055. frontUVs?: Vector4;
  27056. backUVs?: Vector4;
  27057. }): VertexData;
  27058. /**
  27059. * Creates the VertexData for a torus
  27060. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27061. * * diameter the diameter of the torus, optional default 1
  27062. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27063. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27064. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27065. * * 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)
  27066. * * 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)
  27067. * @returns the VertexData of the torus
  27068. */
  27069. static CreateTorus(options: {
  27070. diameter?: number;
  27071. thickness?: number;
  27072. tessellation?: number;
  27073. sideOrientation?: number;
  27074. frontUVs?: Vector4;
  27075. backUVs?: Vector4;
  27076. }): VertexData;
  27077. /**
  27078. * Creates the VertexData of the LineSystem
  27079. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27080. * - lines an array of lines, each line being an array of successive Vector3
  27081. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27082. * @returns the VertexData of the LineSystem
  27083. */
  27084. static CreateLineSystem(options: {
  27085. lines: Vector3[][];
  27086. colors?: Nullable<Color4[][]>;
  27087. }): VertexData;
  27088. /**
  27089. * Create the VertexData for a DashedLines
  27090. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27091. * - points an array successive Vector3
  27092. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27093. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27094. * - dashNb the intended total number of dashes, optional, default 200
  27095. * @returns the VertexData for the DashedLines
  27096. */
  27097. static CreateDashedLines(options: {
  27098. points: Vector3[];
  27099. dashSize?: number;
  27100. gapSize?: number;
  27101. dashNb?: number;
  27102. }): VertexData;
  27103. /**
  27104. * Creates the VertexData for a Ground
  27105. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27106. * - width the width (x direction) of the ground, optional, default 1
  27107. * - height the height (z direction) of the ground, optional, default 1
  27108. * - subdivisions the number of subdivisions per side, optional, default 1
  27109. * @returns the VertexData of the Ground
  27110. */
  27111. static CreateGround(options: {
  27112. width?: number;
  27113. height?: number;
  27114. subdivisions?: number;
  27115. subdivisionsX?: number;
  27116. subdivisionsY?: number;
  27117. }): VertexData;
  27118. /**
  27119. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27120. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27121. * * xmin the ground minimum X coordinate, optional, default -1
  27122. * * zmin the ground minimum Z coordinate, optional, default -1
  27123. * * xmax the ground maximum X coordinate, optional, default 1
  27124. * * zmax the ground maximum Z coordinate, optional, default 1
  27125. * * 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}
  27126. * * 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}
  27127. * @returns the VertexData of the TiledGround
  27128. */
  27129. static CreateTiledGround(options: {
  27130. xmin: number;
  27131. zmin: number;
  27132. xmax: number;
  27133. zmax: number;
  27134. subdivisions?: {
  27135. w: number;
  27136. h: number;
  27137. };
  27138. precision?: {
  27139. w: number;
  27140. h: number;
  27141. };
  27142. }): VertexData;
  27143. /**
  27144. * Creates the VertexData of the Ground designed from a heightmap
  27145. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27146. * * width the width (x direction) of the ground
  27147. * * height the height (z direction) of the ground
  27148. * * subdivisions the number of subdivisions per side
  27149. * * minHeight the minimum altitude on the ground, optional, default 0
  27150. * * maxHeight the maximum altitude on the ground, optional default 1
  27151. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27152. * * buffer the array holding the image color data
  27153. * * bufferWidth the width of image
  27154. * * bufferHeight the height of image
  27155. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27156. * @returns the VertexData of the Ground designed from a heightmap
  27157. */
  27158. static CreateGroundFromHeightMap(options: {
  27159. width: number;
  27160. height: number;
  27161. subdivisions: number;
  27162. minHeight: number;
  27163. maxHeight: number;
  27164. colorFilter: Color3;
  27165. buffer: Uint8Array;
  27166. bufferWidth: number;
  27167. bufferHeight: number;
  27168. alphaFilter: number;
  27169. }): VertexData;
  27170. /**
  27171. * Creates the VertexData for a Plane
  27172. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27173. * * size sets the width and height of the plane to the value of size, optional default 1
  27174. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27175. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27176. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27177. * * 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)
  27178. * * 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)
  27179. * @returns the VertexData of the box
  27180. */
  27181. static CreatePlane(options: {
  27182. size?: number;
  27183. width?: number;
  27184. height?: number;
  27185. sideOrientation?: number;
  27186. frontUVs?: Vector4;
  27187. backUVs?: Vector4;
  27188. }): VertexData;
  27189. /**
  27190. * Creates the VertexData of the Disc or regular Polygon
  27191. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27192. * * radius the radius of the disc, optional default 0.5
  27193. * * tessellation the number of polygon sides, optional, default 64
  27194. * * 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
  27195. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27196. * * 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)
  27197. * * 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)
  27198. * @returns the VertexData of the box
  27199. */
  27200. static CreateDisc(options: {
  27201. radius?: number;
  27202. tessellation?: number;
  27203. arc?: number;
  27204. sideOrientation?: number;
  27205. frontUVs?: Vector4;
  27206. backUVs?: Vector4;
  27207. }): VertexData;
  27208. /**
  27209. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27210. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27211. * @param polygon a mesh built from polygonTriangulation.build()
  27212. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27213. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27214. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27215. * @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)
  27216. * @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)
  27217. * @returns the VertexData of the Polygon
  27218. */
  27219. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27220. /**
  27221. * Creates the VertexData of the IcoSphere
  27222. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27223. * * radius the radius of the IcoSphere, optional default 1
  27224. * * radiusX allows stretching in the x direction, optional, default radius
  27225. * * radiusY allows stretching in the y direction, optional, default radius
  27226. * * radiusZ allows stretching in the z direction, optional, default radius
  27227. * * flat when true creates a flat shaded mesh, optional, default true
  27228. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27229. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27230. * * 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)
  27231. * * 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)
  27232. * @returns the VertexData of the IcoSphere
  27233. */
  27234. static CreateIcoSphere(options: {
  27235. radius?: number;
  27236. radiusX?: number;
  27237. radiusY?: number;
  27238. radiusZ?: number;
  27239. flat?: boolean;
  27240. subdivisions?: number;
  27241. sideOrientation?: number;
  27242. frontUVs?: Vector4;
  27243. backUVs?: Vector4;
  27244. }): VertexData;
  27245. /**
  27246. * Creates the VertexData for a Polyhedron
  27247. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27248. * * type provided types are:
  27249. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27250. * * 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)
  27251. * * size the size of the IcoSphere, optional default 1
  27252. * * sizeX allows stretching in the x direction, optional, default size
  27253. * * sizeY allows stretching in the y direction, optional, default size
  27254. * * sizeZ allows stretching in the z direction, optional, default size
  27255. * * 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
  27256. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27257. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27258. * * flat when true creates a flat shaded mesh, optional, default true
  27259. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27260. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27261. * * 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)
  27262. * * 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)
  27263. * @returns the VertexData of the Polyhedron
  27264. */
  27265. static CreatePolyhedron(options: {
  27266. type?: number;
  27267. size?: number;
  27268. sizeX?: number;
  27269. sizeY?: number;
  27270. sizeZ?: number;
  27271. custom?: any;
  27272. faceUV?: Vector4[];
  27273. faceColors?: Color4[];
  27274. flat?: boolean;
  27275. sideOrientation?: number;
  27276. frontUVs?: Vector4;
  27277. backUVs?: Vector4;
  27278. }): VertexData;
  27279. /**
  27280. * Creates the VertexData for a TorusKnot
  27281. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27282. * * radius the radius of the torus knot, optional, default 2
  27283. * * tube the thickness of the tube, optional, default 0.5
  27284. * * radialSegments the number of sides on each tube segments, optional, default 32
  27285. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27286. * * p the number of windings around the z axis, optional, default 2
  27287. * * q the number of windings around the x axis, optional, default 3
  27288. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27289. * * 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)
  27290. * * 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)
  27291. * @returns the VertexData of the Torus Knot
  27292. */
  27293. static CreateTorusKnot(options: {
  27294. radius?: number;
  27295. tube?: number;
  27296. radialSegments?: number;
  27297. tubularSegments?: number;
  27298. p?: number;
  27299. q?: number;
  27300. sideOrientation?: number;
  27301. frontUVs?: Vector4;
  27302. backUVs?: Vector4;
  27303. }): VertexData;
  27304. /**
  27305. * Compute normals for given positions and indices
  27306. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27307. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27308. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27309. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27310. * * facetNormals : optional array of facet normals (vector3)
  27311. * * facetPositions : optional array of facet positions (vector3)
  27312. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27313. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27314. * * bInfo : optional bounding info, required for facetPartitioning computation
  27315. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27316. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27317. * * useRightHandedSystem: optional boolean to for right handed system computation
  27318. * * depthSort : optional boolean to enable the facet depth sort computation
  27319. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27320. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27321. */
  27322. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27323. facetNormals?: any;
  27324. facetPositions?: any;
  27325. facetPartitioning?: any;
  27326. ratio?: number;
  27327. bInfo?: any;
  27328. bbSize?: Vector3;
  27329. subDiv?: any;
  27330. useRightHandedSystem?: boolean;
  27331. depthSort?: boolean;
  27332. distanceTo?: Vector3;
  27333. depthSortedFacets?: any;
  27334. }): void;
  27335. private static _ComputeSides;
  27336. /**
  27337. * Applies VertexData created from the imported parameters to the geometry
  27338. * @param parsedVertexData the parsed data from an imported file
  27339. * @param geometry the geometry to apply the VertexData to
  27340. */
  27341. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27342. }
  27343. }
  27344. declare module BABYLON {
  27345. /**
  27346. * Class containing static functions to help procedurally build meshes
  27347. */
  27348. class MeshBuilder {
  27349. private static updateSideOrientation;
  27350. /**
  27351. * Creates a box mesh
  27352. * * The parameter `size` sets the size (float) of each box side (default 1)
  27353. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  27354. * * 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)
  27355. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27357. * * 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
  27358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27359. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  27360. * @param name defines the name of the mesh
  27361. * @param options defines the options used to create the mesh
  27362. * @param scene defines the hosting scene
  27363. * @returns the box mesh
  27364. */
  27365. static CreateBox(name: string, options: {
  27366. size?: number;
  27367. width?: number;
  27368. height?: number;
  27369. depth?: number;
  27370. faceUV?: Vector4[];
  27371. faceColors?: Color4[];
  27372. sideOrientation?: number;
  27373. frontUVs?: Vector4;
  27374. backUVs?: Vector4;
  27375. updatable?: boolean;
  27376. }, scene?: Nullable<Scene>): Mesh;
  27377. /**
  27378. * Creates a sphere mesh
  27379. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  27380. * * 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`)
  27381. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  27382. * * 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
  27383. * * 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)
  27384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27385. * * 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
  27386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27387. * @param name defines the name of the mesh
  27388. * @param options defines the options used to create the mesh
  27389. * @param scene defines the hosting scene
  27390. * @returns the sphere mesh
  27391. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  27392. */
  27393. static CreateSphere(name: string, options: {
  27394. segments?: number;
  27395. diameter?: number;
  27396. diameterX?: number;
  27397. diameterY?: number;
  27398. diameterZ?: number;
  27399. arc?: number;
  27400. slice?: number;
  27401. sideOrientation?: number;
  27402. frontUVs?: Vector4;
  27403. backUVs?: Vector4;
  27404. updatable?: boolean;
  27405. }, scene: any): Mesh;
  27406. /**
  27407. * Creates a plane polygonal mesh. By default, this is a disc
  27408. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27409. * * 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
  27410. * * 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
  27411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27412. * * 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
  27413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27414. * @param name defines the name of the mesh
  27415. * @param options defines the options used to create the mesh
  27416. * @param scene defines the hosting scene
  27417. * @returns the plane polygonal mesh
  27418. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27419. */
  27420. static CreateDisc(name: string, options: {
  27421. radius?: number;
  27422. tessellation?: number;
  27423. arc?: number;
  27424. updatable?: boolean;
  27425. sideOrientation?: number;
  27426. frontUVs?: Vector4;
  27427. backUVs?: Vector4;
  27428. }, scene?: Nullable<Scene>): Mesh;
  27429. /**
  27430. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27431. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27432. * * 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`)
  27433. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27434. * * 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
  27435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27436. * * 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
  27437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27438. * @param name defines the name of the mesh
  27439. * @param options defines the options used to create the mesh
  27440. * @param scene defines the hosting scene
  27441. * @returns the icosahedron mesh
  27442. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27443. */
  27444. static CreateIcoSphere(name: string, options: {
  27445. radius?: number;
  27446. radiusX?: number;
  27447. radiusY?: number;
  27448. radiusZ?: number;
  27449. flat?: boolean;
  27450. subdivisions?: number;
  27451. sideOrientation?: number;
  27452. frontUVs?: Vector4;
  27453. backUVs?: Vector4;
  27454. updatable?: boolean;
  27455. }, scene: Scene): Mesh;
  27456. /**
  27457. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  27458. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  27459. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  27460. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  27461. * * 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
  27462. * * 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
  27463. * * 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
  27464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27465. * * 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
  27466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27467. * * 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
  27468. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  27469. * * 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
  27470. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  27471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27472. * @param name defines the name of the mesh
  27473. * @param options defines the options used to create the mesh
  27474. * @param scene defines the hosting scene
  27475. * @returns the ribbon mesh
  27476. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  27477. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27478. */
  27479. static CreateRibbon(name: string, options: {
  27480. pathArray: Vector3[][];
  27481. closeArray?: boolean;
  27482. closePath?: boolean;
  27483. offset?: number;
  27484. updatable?: boolean;
  27485. sideOrientation?: number;
  27486. frontUVs?: Vector4;
  27487. backUVs?: Vector4;
  27488. instance?: Mesh;
  27489. invertUV?: boolean;
  27490. uvs?: Vector2[];
  27491. colors?: Color4[];
  27492. }, scene?: Nullable<Scene>): Mesh;
  27493. /**
  27494. * Creates a cylinder or a cone mesh
  27495. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  27496. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  27497. * * 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.
  27498. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  27499. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  27500. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  27501. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  27502. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  27503. * * 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).
  27504. * * 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
  27505. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  27506. * * 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
  27507. * * 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.
  27508. * * If `enclose` is false, a ring surface is one element.
  27509. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  27510. * * 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
  27511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27512. * * 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
  27513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27514. * @param name defines the name of the mesh
  27515. * @param options defines the options used to create the mesh
  27516. * @param scene defines the hosting scene
  27517. * @returns the cylinder mesh
  27518. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  27519. */
  27520. static CreateCylinder(name: string, options: {
  27521. height?: number;
  27522. diameterTop?: number;
  27523. diameterBottom?: number;
  27524. diameter?: number;
  27525. tessellation?: number;
  27526. subdivisions?: number;
  27527. arc?: number;
  27528. faceColors?: Color4[];
  27529. faceUV?: Vector4[];
  27530. updatable?: boolean;
  27531. hasRings?: boolean;
  27532. enclose?: boolean;
  27533. sideOrientation?: number;
  27534. frontUVs?: Vector4;
  27535. backUVs?: Vector4;
  27536. }, scene: any): Mesh;
  27537. /**
  27538. * Creates a torus mesh
  27539. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  27540. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  27541. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  27542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27543. * * 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
  27544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27545. * @param name defines the name of the mesh
  27546. * @param options defines the options used to create the mesh
  27547. * @param scene defines the hosting scene
  27548. * @returns the torus mesh
  27549. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  27550. */
  27551. static CreateTorus(name: string, options: {
  27552. diameter?: number;
  27553. thickness?: number;
  27554. tessellation?: number;
  27555. updatable?: boolean;
  27556. sideOrientation?: number;
  27557. frontUVs?: Vector4;
  27558. backUVs?: Vector4;
  27559. }, scene: any): Mesh;
  27560. /**
  27561. * Creates a torus knot mesh
  27562. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  27563. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  27564. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  27565. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  27566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27567. * * 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
  27568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27569. * @param name defines the name of the mesh
  27570. * @param options defines the options used to create the mesh
  27571. * @param scene defines the hosting scene
  27572. * @returns the torus knot mesh
  27573. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  27574. */
  27575. static CreateTorusKnot(name: string, options: {
  27576. radius?: number;
  27577. tube?: number;
  27578. radialSegments?: number;
  27579. tubularSegments?: number;
  27580. p?: number;
  27581. q?: number;
  27582. updatable?: boolean;
  27583. sideOrientation?: number;
  27584. frontUVs?: Vector4;
  27585. backUVs?: Vector4;
  27586. }, scene: any): Mesh;
  27587. /**
  27588. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  27589. * * 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
  27590. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  27591. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  27592. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  27593. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  27594. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  27595. * * 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
  27596. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  27597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27598. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  27599. * @param name defines the name of the new line system
  27600. * @param options defines the options used to create the line system
  27601. * @param scene defines the hosting scene
  27602. * @returns a new line system mesh
  27603. */
  27604. static CreateLineSystem(name: string, options: {
  27605. lines: Vector3[][];
  27606. updatable?: boolean;
  27607. instance?: Nullable<LinesMesh>;
  27608. colors?: Nullable<Color4[][]>;
  27609. useVertexAlpha?: boolean;
  27610. }, scene: Nullable<Scene>): LinesMesh;
  27611. /**
  27612. * Creates a line mesh
  27613. * 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
  27614. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  27615. * * The parameter `points` is an array successive Vector3
  27616. * * 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
  27617. * * The optional parameter `colors` is an array of successive Color4, one per line point
  27618. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  27619. * * When updating an instance, remember that only point positions can change, not the number of points
  27620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27621. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  27622. * @param name defines the name of the new line system
  27623. * @param options defines the options used to create the line system
  27624. * @param scene defines the hosting scene
  27625. * @returns a new line mesh
  27626. */
  27627. static CreateLines(name: string, options: {
  27628. points: Vector3[];
  27629. updatable?: boolean;
  27630. instance?: Nullable<LinesMesh>;
  27631. colors?: Color4[];
  27632. useVertexAlpha?: boolean;
  27633. }, scene?: Nullable<Scene>): LinesMesh;
  27634. /**
  27635. * Creates a dashed line mesh
  27636. * * 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
  27637. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  27638. * * The parameter `points` is an array successive Vector3
  27639. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  27640. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  27641. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27642. * * 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
  27643. * * When updating an instance, remember that only point positions can change, not the number of points
  27644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27645. * @param name defines the name of the mesh
  27646. * @param options defines the options used to create the mesh
  27647. * @param scene defines the hosting scene
  27648. * @returns the dashed line mesh
  27649. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  27650. */
  27651. static CreateDashedLines(name: string, options: {
  27652. points: Vector3[];
  27653. dashSize?: number;
  27654. gapSize?: number;
  27655. dashNb?: number;
  27656. updatable?: boolean;
  27657. instance?: LinesMesh;
  27658. }, scene?: Nullable<Scene>): LinesMesh;
  27659. /**
  27660. * 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.
  27661. * * 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.
  27662. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  27663. * * 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.
  27664. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  27665. * * 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
  27666. * * 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
  27667. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  27668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27669. * * 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
  27670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  27671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27672. * @param name defines the name of the mesh
  27673. * @param options defines the options used to create the mesh
  27674. * @param scene defines the hosting scene
  27675. * @returns the extruded shape mesh
  27676. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27677. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27678. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27679. */
  27680. static ExtrudeShape(name: string, options: {
  27681. shape: Vector3[];
  27682. path: Vector3[];
  27683. scale?: number;
  27684. rotation?: number;
  27685. cap?: number;
  27686. updatable?: boolean;
  27687. sideOrientation?: number;
  27688. frontUVs?: Vector4;
  27689. backUVs?: Vector4;
  27690. instance?: Mesh;
  27691. invertUV?: boolean;
  27692. }, scene?: Nullable<Scene>): Mesh;
  27693. /**
  27694. * Creates an custom extruded shape mesh.
  27695. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  27696. * * 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.
  27697. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  27698. * * 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
  27699. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  27700. * * 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
  27701. * * It must returns a float value that will be the scale value applied to the shape on each path point
  27702. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27703. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  27704. * * 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
  27705. * * 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
  27706. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  27707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27708. * * 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
  27709. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27711. * @param name defines the name of the mesh
  27712. * @param options defines the options used to create the mesh
  27713. * @param scene defines the hosting scene
  27714. * @returns the custom extruded shape mesh
  27715. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  27716. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27717. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27718. */
  27719. static ExtrudeShapeCustom(name: string, options: {
  27720. shape: Vector3[];
  27721. path: Vector3[];
  27722. scaleFunction?: any;
  27723. rotationFunction?: any;
  27724. ribbonCloseArray?: boolean;
  27725. ribbonClosePath?: boolean;
  27726. cap?: number;
  27727. updatable?: boolean;
  27728. sideOrientation?: number;
  27729. frontUVs?: Vector4;
  27730. backUVs?: Vector4;
  27731. instance?: Mesh;
  27732. invertUV?: boolean;
  27733. }, scene: Scene): Mesh;
  27734. /**
  27735. * Creates lathe mesh.
  27736. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  27737. * * 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
  27738. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  27739. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  27740. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  27741. * * 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
  27742. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  27743. * * 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
  27744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27745. * * 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
  27746. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27748. * @param name defines the name of the mesh
  27749. * @param options defines the options used to create the mesh
  27750. * @param scene defines the hosting scene
  27751. * @returns the lathe mesh
  27752. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  27753. */
  27754. static CreateLathe(name: string, options: {
  27755. shape: Vector3[];
  27756. radius?: number;
  27757. tessellation?: number;
  27758. clip?: number;
  27759. arc?: number;
  27760. closed?: boolean;
  27761. updatable?: boolean;
  27762. sideOrientation?: number;
  27763. frontUVs?: Vector4;
  27764. backUVs?: Vector4;
  27765. cap?: number;
  27766. invertUV?: boolean;
  27767. }, scene: Scene): Mesh;
  27768. /**
  27769. * Creates a plane mesh
  27770. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  27771. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  27772. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  27773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27774. * * 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
  27775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27776. * @param name defines the name of the mesh
  27777. * @param options defines the options used to create the mesh
  27778. * @param scene defines the hosting scene
  27779. * @returns the plane mesh
  27780. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  27781. */
  27782. static CreatePlane(name: string, options: {
  27783. size?: number;
  27784. width?: number;
  27785. height?: number;
  27786. sideOrientation?: number;
  27787. frontUVs?: Vector4;
  27788. backUVs?: Vector4;
  27789. updatable?: boolean;
  27790. sourcePlane?: Plane;
  27791. }, scene: Scene): Mesh;
  27792. /**
  27793. * Creates a ground mesh
  27794. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  27795. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  27796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27797. * @param name defines the name of the mesh
  27798. * @param options defines the options used to create the mesh
  27799. * @param scene defines the hosting scene
  27800. * @returns the ground mesh
  27801. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  27802. */
  27803. static CreateGround(name: string, options: {
  27804. width?: number;
  27805. height?: number;
  27806. subdivisions?: number;
  27807. subdivisionsX?: number;
  27808. subdivisionsY?: number;
  27809. updatable?: boolean;
  27810. }, scene: any): Mesh;
  27811. /**
  27812. * Creates a tiled ground mesh
  27813. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  27814. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  27815. * * 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
  27816. * * 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
  27817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27818. * @param name defines the name of the mesh
  27819. * @param options defines the options used to create the mesh
  27820. * @param scene defines the hosting scene
  27821. * @returns the tiled ground mesh
  27822. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  27823. */
  27824. static CreateTiledGround(name: string, options: {
  27825. xmin: number;
  27826. zmin: number;
  27827. xmax: number;
  27828. zmax: number;
  27829. subdivisions?: {
  27830. w: number;
  27831. h: number;
  27832. };
  27833. precision?: {
  27834. w: number;
  27835. h: number;
  27836. };
  27837. updatable?: boolean;
  27838. }, scene: Scene): Mesh;
  27839. /**
  27840. * Creates a ground mesh from a height map
  27841. * * The parameter `url` sets the URL of the height map image resource.
  27842. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  27843. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  27844. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  27845. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  27846. * * 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.
  27847. * * 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).
  27848. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27850. * @param name defines the name of the mesh
  27851. * @param url defines the url to the height map
  27852. * @param options defines the options used to create the mesh
  27853. * @param scene defines the hosting scene
  27854. * @returns the ground mesh
  27855. * @see http://doc.babylonjs.com/babylon101/height_map
  27856. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  27857. */
  27858. static CreateGroundFromHeightMap(name: string, url: string, options: {
  27859. width?: number;
  27860. height?: number;
  27861. subdivisions?: number;
  27862. minHeight?: number;
  27863. maxHeight?: number;
  27864. colorFilter?: Color3;
  27865. alphaFilter?: number;
  27866. updatable?: boolean;
  27867. onReady?: (mesh: GroundMesh) => void;
  27868. }, scene: Scene): GroundMesh;
  27869. /**
  27870. * Creates a polygon mesh
  27871. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  27872. * * 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
  27873. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27875. * * 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)
  27876. * * Remember you can only change the shape positions, not their number when updating a polygon
  27877. * @param name defines the name of the mesh
  27878. * @param options defines the options used to create the mesh
  27879. * @param scene defines the hosting scene
  27880. * @returns the polygon mesh
  27881. */
  27882. static CreatePolygon(name: string, options: {
  27883. shape: Vector3[];
  27884. holes?: Vector3[][];
  27885. depth?: number;
  27886. faceUV?: Vector4[];
  27887. faceColors?: Color4[];
  27888. updatable?: boolean;
  27889. sideOrientation?: number;
  27890. frontUVs?: Vector4;
  27891. backUVs?: Vector4;
  27892. }, scene: Scene): Mesh;
  27893. /**
  27894. * Creates an extruded polygon mesh, with depth in the Y direction.
  27895. * * 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)
  27896. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27897. * @param name defines the name of the mesh
  27898. * @param options defines the options used to create the mesh
  27899. * @param scene defines the hosting scene
  27900. * @returns the polygon mesh
  27901. */
  27902. static ExtrudePolygon(name: string, options: {
  27903. shape: Vector3[];
  27904. holes?: Vector3[][];
  27905. depth?: number;
  27906. faceUV?: Vector4[];
  27907. faceColors?: Color4[];
  27908. updatable?: boolean;
  27909. sideOrientation?: number;
  27910. frontUVs?: Vector4;
  27911. backUVs?: Vector4;
  27912. }, scene: Scene): Mesh;
  27913. /**
  27914. * Creates a tube mesh.
  27915. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  27916. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  27917. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  27918. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  27919. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  27920. * * 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)
  27921. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  27922. * * 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
  27923. * * 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
  27924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27925. * * 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
  27926. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27928. * @param name defines the name of the mesh
  27929. * @param options defines the options used to create the mesh
  27930. * @param scene defines the hosting scene
  27931. * @returns the tube mesh
  27932. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27933. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  27934. */
  27935. static CreateTube(name: string, options: {
  27936. path: Vector3[];
  27937. radius?: number;
  27938. tessellation?: number;
  27939. radiusFunction?: {
  27940. (i: number, distance: number): number;
  27941. };
  27942. cap?: number;
  27943. arc?: number;
  27944. updatable?: boolean;
  27945. sideOrientation?: number;
  27946. frontUVs?: Vector4;
  27947. backUVs?: Vector4;
  27948. instance?: Mesh;
  27949. invertUV?: boolean;
  27950. }, scene: Scene): Mesh;
  27951. /**
  27952. * Creates a polyhedron mesh
  27953. * * 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
  27954. * * The parameter `size` (positive float, default 1) sets the polygon size
  27955. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27956. * * 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`
  27957. * * 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
  27958. * * 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)`)
  27959. * * 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
  27960. * * 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
  27961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27962. * * 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
  27963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27964. * @param name defines the name of the mesh
  27965. * @param options defines the options used to create the mesh
  27966. * @param scene defines the hosting scene
  27967. * @returns the polyhedron mesh
  27968. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  27969. */
  27970. static CreatePolyhedron(name: string, options: {
  27971. type?: number;
  27972. size?: number;
  27973. sizeX?: number;
  27974. sizeY?: number;
  27975. sizeZ?: number;
  27976. custom?: any;
  27977. faceUV?: Vector4[];
  27978. faceColors?: Color4[];
  27979. flat?: boolean;
  27980. updatable?: boolean;
  27981. sideOrientation?: number;
  27982. frontUVs?: Vector4;
  27983. backUVs?: Vector4;
  27984. }, scene: Scene): Mesh;
  27985. /**
  27986. * Creates a decal mesh.
  27987. * 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
  27988. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  27989. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  27990. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  27991. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  27992. * @param name defines the name of the mesh
  27993. * @param sourceMesh defines the mesh where the decal must be applied
  27994. * @param options defines the options used to create the mesh
  27995. * @param scene defines the hosting scene
  27996. * @returns the decal mesh
  27997. * @see http://doc.babylonjs.com/how_to/decals
  27998. */
  27999. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28000. position?: Vector3;
  28001. normal?: Vector3;
  28002. size?: Vector3;
  28003. angle?: number;
  28004. }): Mesh;
  28005. private static _ExtrudeShapeGeneric;
  28006. }
  28007. }
  28008. declare module BABYLON {
  28009. /**
  28010. * Class used to represent a specific level of detail of a mesh
  28011. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28012. */
  28013. class MeshLODLevel {
  28014. /** Defines the distance where this level should star being displayed */
  28015. distance: number;
  28016. /** Defines the mesh to use to render this level */
  28017. mesh: Nullable<Mesh>;
  28018. /**
  28019. * Creates a new LOD level
  28020. * @param distance defines the distance where this level should star being displayed
  28021. * @param mesh defines the mesh to use to render this level
  28022. */
  28023. constructor(
  28024. /** Defines the distance where this level should star being displayed */
  28025. distance: number,
  28026. /** Defines the mesh to use to render this level */
  28027. mesh: Nullable<Mesh>);
  28028. }
  28029. }
  28030. declare module BABYLON {
  28031. /**
  28032. * A simplifier interface for future simplification implementations
  28033. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28034. */
  28035. interface ISimplifier {
  28036. /**
  28037. * Simplification of a given mesh according to the given settings.
  28038. * Since this requires computation, it is assumed that the function runs async.
  28039. * @param settings The settings of the simplification, including quality and distance
  28040. * @param successCallback A callback that will be called after the mesh was simplified.
  28041. * @param errorCallback in case of an error, this callback will be called. optional.
  28042. */
  28043. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28044. }
  28045. /**
  28046. * Expected simplification settings.
  28047. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28048. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28049. */
  28050. interface ISimplificationSettings {
  28051. /**
  28052. * Gets or sets the expected quality
  28053. */
  28054. quality: number;
  28055. /**
  28056. * Gets or sets the distance when this optimized version should be used
  28057. */
  28058. distance: number;
  28059. /**
  28060. * Gets an already optimized mesh
  28061. */
  28062. optimizeMesh?: boolean;
  28063. }
  28064. /**
  28065. * Class used to specify simplification options
  28066. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28067. */
  28068. class SimplificationSettings implements ISimplificationSettings {
  28069. /** expected quality */
  28070. quality: number;
  28071. /** distance when this optimized version should be used */
  28072. distance: number;
  28073. /** already optimized mesh */
  28074. optimizeMesh?: boolean | undefined;
  28075. /**
  28076. * Creates a SimplificationSettings
  28077. * @param quality expected quality
  28078. * @param distance distance when this optimized version should be used
  28079. * @param optimizeMesh already optimized mesh
  28080. */
  28081. constructor(
  28082. /** expected quality */
  28083. quality: number,
  28084. /** distance when this optimized version should be used */
  28085. distance: number,
  28086. /** already optimized mesh */
  28087. optimizeMesh?: boolean | undefined);
  28088. }
  28089. /**
  28090. * Interface used to define a simplification task
  28091. */
  28092. interface ISimplificationTask {
  28093. /**
  28094. * Array of settings
  28095. */
  28096. settings: Array<ISimplificationSettings>;
  28097. /**
  28098. * Simplification type
  28099. */
  28100. simplificationType: SimplificationType;
  28101. /**
  28102. * Mesh to simplify
  28103. */
  28104. mesh: Mesh;
  28105. /**
  28106. * Callback called on success
  28107. */
  28108. successCallback?: () => void;
  28109. /**
  28110. * Defines if parallel processing can be used
  28111. */
  28112. parallelProcessing: boolean;
  28113. }
  28114. /**
  28115. * Queue used to order the simplification tasks
  28116. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28117. */
  28118. class SimplificationQueue {
  28119. private _simplificationArray;
  28120. /**
  28121. * Gets a boolean indicating that the process is still running
  28122. */
  28123. running: boolean;
  28124. /**
  28125. * Creates a new queue
  28126. */
  28127. constructor();
  28128. /**
  28129. * Adds a new simplification task
  28130. * @param task defines a task to add
  28131. */
  28132. addTask(task: ISimplificationTask): void;
  28133. /**
  28134. * Execute next task
  28135. */
  28136. executeNext(): void;
  28137. /**
  28138. * Execute a simplification task
  28139. * @param task defines the task to run
  28140. */
  28141. runSimplification(task: ISimplificationTask): void;
  28142. private getSimplifier;
  28143. }
  28144. /**
  28145. * The implemented types of simplification
  28146. * At the moment only Quadratic Error Decimation is implemented
  28147. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28148. */
  28149. enum SimplificationType {
  28150. /** Quadratic error decimation */
  28151. QUADRATIC = 0
  28152. }
  28153. }
  28154. declare module BABYLON {
  28155. interface Scene {
  28156. /** @hidden (Backing field) */
  28157. _simplificationQueue: SimplificationQueue;
  28158. /**
  28159. * Gets or sets the simplification queue attached to the scene
  28160. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28161. */
  28162. simplificationQueue: SimplificationQueue;
  28163. }
  28164. interface Mesh {
  28165. /**
  28166. * Simplify the mesh according to the given array of settings.
  28167. * Function will return immediately and will simplify async
  28168. * @param settings a collection of simplification settings
  28169. * @param parallelProcessing should all levels calculate parallel or one after the other
  28170. * @param simplificationType the type of simplification to run
  28171. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28172. * @returns the current mesh
  28173. */
  28174. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28175. }
  28176. /**
  28177. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28178. * created in a scene
  28179. */
  28180. class SimplicationQueueSceneComponent implements ISceneComponent {
  28181. /**
  28182. * The component name helpfull to identify the component in the list of scene components.
  28183. */
  28184. readonly name: string;
  28185. /**
  28186. * The scene the component belongs to.
  28187. */
  28188. scene: Scene;
  28189. /**
  28190. * Creates a new instance of the component for the given scene
  28191. * @param scene Defines the scene to register the component in
  28192. */
  28193. constructor(scene: Scene);
  28194. /**
  28195. * Registers the component in a given scene
  28196. */
  28197. register(): void;
  28198. /**
  28199. * Rebuilds the elements related to this component in case of
  28200. * context lost for instance.
  28201. */
  28202. rebuild(): void;
  28203. /**
  28204. * Disposes the component and the associated ressources
  28205. */
  28206. dispose(): void;
  28207. private _beforeCameraUpdate;
  28208. }
  28209. }
  28210. declare module BABYLON {
  28211. /**
  28212. * Polygon
  28213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28214. */
  28215. class Polygon {
  28216. /**
  28217. * Creates a rectangle
  28218. * @param xmin bottom X coord
  28219. * @param ymin bottom Y coord
  28220. * @param xmax top X coord
  28221. * @param ymax top Y coord
  28222. * @returns points that make the resulting rectation
  28223. */
  28224. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28225. /**
  28226. * Creates a circle
  28227. * @param radius radius of circle
  28228. * @param cx scale in x
  28229. * @param cy scale in y
  28230. * @param numberOfSides number of sides that make up the circle
  28231. * @returns points that make the resulting circle
  28232. */
  28233. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28234. /**
  28235. * Creates a polygon from input string
  28236. * @param input Input polygon data
  28237. * @returns the parsed points
  28238. */
  28239. static Parse(input: string): Vector2[];
  28240. /**
  28241. * Starts building a polygon from x and y coordinates
  28242. * @param x x coordinate
  28243. * @param y y coordinate
  28244. * @returns the started path2
  28245. */
  28246. static StartingAt(x: number, y: number): Path2;
  28247. }
  28248. /**
  28249. * Builds a polygon
  28250. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28251. */
  28252. class PolygonMeshBuilder {
  28253. private _points;
  28254. private _outlinepoints;
  28255. private _holes;
  28256. private _name;
  28257. private _scene;
  28258. private _epoints;
  28259. private _eholes;
  28260. private _addToepoint;
  28261. /**
  28262. * Creates a PolygonMeshBuilder
  28263. * @param name name of the builder
  28264. * @param contours Path of the polygon
  28265. * @param scene scene to add to
  28266. */
  28267. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  28268. /**
  28269. * Adds a whole within the polygon
  28270. * @param hole Array of points defining the hole
  28271. * @returns this
  28272. */
  28273. addHole(hole: Vector2[]): PolygonMeshBuilder;
  28274. /**
  28275. * Creates the polygon
  28276. * @param updatable If the mesh should be updatable
  28277. * @param depth The depth of the mesh created
  28278. * @returns the created mesh
  28279. */
  28280. build(updatable?: boolean, depth?: number): Mesh;
  28281. /**
  28282. * Adds a side to the polygon
  28283. * @param positions points that make the polygon
  28284. * @param normals normals of the polygon
  28285. * @param uvs uvs of the polygon
  28286. * @param indices indices of the polygon
  28287. * @param bounds bounds of the polygon
  28288. * @param points points of the polygon
  28289. * @param depth depth of the polygon
  28290. * @param flip flip of the polygon
  28291. */
  28292. private addSide;
  28293. }
  28294. }
  28295. declare module BABYLON {
  28296. /**
  28297. * Base class for submeshes
  28298. */
  28299. class BaseSubMesh {
  28300. /** @hidden */
  28301. _materialDefines: Nullable<MaterialDefines>;
  28302. /** @hidden */
  28303. _materialEffect: Nullable<Effect>;
  28304. /**
  28305. * Gets associated effect
  28306. */
  28307. readonly effect: Nullable<Effect>;
  28308. /**
  28309. * Sets associated effect (effect used to render this submesh)
  28310. * @param effect defines the effect to associate with
  28311. * @param defines defines the set of defines used to compile this effect
  28312. */
  28313. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  28314. }
  28315. /**
  28316. * Defines a subdivision inside a mesh
  28317. */
  28318. class SubMesh extends BaseSubMesh implements ICullable {
  28319. /** the material index to use */
  28320. materialIndex: number;
  28321. /** vertex index start */
  28322. verticesStart: number;
  28323. /** vertices count */
  28324. verticesCount: number;
  28325. /** index start */
  28326. indexStart: number;
  28327. /** indices count */
  28328. indexCount: number;
  28329. /** @hidden */
  28330. _linesIndexCount: number;
  28331. private _mesh;
  28332. private _renderingMesh;
  28333. private _boundingInfo;
  28334. private _linesIndexBuffer;
  28335. /** @hidden */
  28336. _lastColliderWorldVertices: Nullable<Vector3[]>;
  28337. /** @hidden */
  28338. _trianglePlanes: Plane[];
  28339. /** @hidden */
  28340. _lastColliderTransformMatrix: Matrix;
  28341. /** @hidden */
  28342. _renderId: number;
  28343. /** @hidden */
  28344. _alphaIndex: number;
  28345. /** @hidden */
  28346. _distanceToCamera: number;
  28347. /** @hidden */
  28348. _id: number;
  28349. private _currentMaterial;
  28350. /**
  28351. * Add a new submesh to a mesh
  28352. * @param materialIndex defines the material index to use
  28353. * @param verticesStart defines vertex index start
  28354. * @param verticesCount defines vertices count
  28355. * @param indexStart defines index start
  28356. * @param indexCount defines indices count
  28357. * @param mesh defines the parent mesh
  28358. * @param renderingMesh defines an optional rendering mesh
  28359. * @param createBoundingBox defines if bounding box should be created for this submesh
  28360. * @returns the new submesh
  28361. */
  28362. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  28363. /**
  28364. * Creates a new submesh
  28365. * @param materialIndex defines the material index to use
  28366. * @param verticesStart defines vertex index start
  28367. * @param verticesCount defines vertices count
  28368. * @param indexStart defines index start
  28369. * @param indexCount defines indices count
  28370. * @param mesh defines the parent mesh
  28371. * @param renderingMesh defines an optional rendering mesh
  28372. * @param createBoundingBox defines if bounding box should be created for this submesh
  28373. */
  28374. constructor(
  28375. /** the material index to use */
  28376. materialIndex: number,
  28377. /** vertex index start */
  28378. verticesStart: number,
  28379. /** vertices count */
  28380. verticesCount: number,
  28381. /** index start */
  28382. indexStart: number,
  28383. /** indices count */
  28384. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  28385. /**
  28386. * Returns true if this submesh covers the entire parent mesh
  28387. * @ignorenaming
  28388. */
  28389. readonly IsGlobal: boolean;
  28390. /**
  28391. * Returns the submesh BoudingInfo object
  28392. * @returns current bounding info (or mesh's one if the submesh is global)
  28393. */
  28394. getBoundingInfo(): BoundingInfo;
  28395. /**
  28396. * Sets the submesh BoundingInfo
  28397. * @param boundingInfo defines the new bounding info to use
  28398. * @returns the SubMesh
  28399. */
  28400. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  28401. /**
  28402. * Returns the mesh of the current submesh
  28403. * @return the parent mesh
  28404. */
  28405. getMesh(): AbstractMesh;
  28406. /**
  28407. * Returns the rendering mesh of the submesh
  28408. * @returns the rendering mesh (could be different from parent mesh)
  28409. */
  28410. getRenderingMesh(): Mesh;
  28411. /**
  28412. * Returns the submesh material
  28413. * @returns null or the current material
  28414. */
  28415. getMaterial(): Nullable<Material>;
  28416. /**
  28417. * Sets a new updated BoundingInfo object to the submesh
  28418. * @returns the SubMesh
  28419. */
  28420. refreshBoundingInfo(): SubMesh;
  28421. /** @hidden */
  28422. _checkCollision(collider: Collider): boolean;
  28423. /**
  28424. * Updates the submesh BoundingInfo
  28425. * @param world defines the world matrix to use to update the bounding info
  28426. * @returns the submesh
  28427. */
  28428. updateBoundingInfo(world: Matrix): SubMesh;
  28429. /**
  28430. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  28431. * @param frustumPlanes defines the frustum planes
  28432. * @returns true if the submesh is intersecting with the frustum
  28433. */
  28434. isInFrustum(frustumPlanes: Plane[]): boolean;
  28435. /**
  28436. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  28437. * @param frustumPlanes defines the frustum planes
  28438. * @returns true if the submesh is inside the frustum
  28439. */
  28440. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28441. /**
  28442. * Renders the submesh
  28443. * @param enableAlphaMode defines if alpha needs to be used
  28444. * @returns the submesh
  28445. */
  28446. render(enableAlphaMode: boolean): SubMesh;
  28447. /**
  28448. * @hidden
  28449. */
  28450. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  28451. /**
  28452. * Checks if the submesh intersects with a ray
  28453. * @param ray defines the ray to test
  28454. * @returns true is the passed ray intersects the submesh bounding box
  28455. */
  28456. canIntersects(ray: Ray): boolean;
  28457. /**
  28458. * Intersects current submesh with a ray
  28459. * @param ray defines the ray to test
  28460. * @param positions defines mesh's positions array
  28461. * @param indices defines mesh's indices array
  28462. * @param fastCheck defines if only bounding info should be used
  28463. * @returns intersection info or null if no intersection
  28464. */
  28465. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  28466. /** @hidden */
  28467. private _intersectLines;
  28468. /** @hidden */
  28469. private _intersectTriangles;
  28470. /** @hidden */
  28471. _rebuild(): void;
  28472. /**
  28473. * Creates a new submesh from the passed mesh
  28474. * @param newMesh defines the new hosting mesh
  28475. * @param newRenderingMesh defines an optional rendering mesh
  28476. * @returns the new submesh
  28477. */
  28478. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  28479. /**
  28480. * Release associated resources
  28481. */
  28482. dispose(): void;
  28483. /**
  28484. * Creates a new submesh from indices data
  28485. * @param materialIndex the index of the main mesh material
  28486. * @param startIndex the index where to start the copy in the mesh indices array
  28487. * @param indexCount the number of indices to copy then from the startIndex
  28488. * @param mesh the main mesh to create the submesh from
  28489. * @param renderingMesh the optional rendering mesh
  28490. * @returns a new submesh
  28491. */
  28492. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  28493. }
  28494. }
  28495. declare module BABYLON {
  28496. /**
  28497. * 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.
  28498. * @see https://doc.babylonjs.com/how_to/transformnode
  28499. */
  28500. class TransformNode extends Node {
  28501. /**
  28502. * Object will not rotate to face the camera
  28503. */
  28504. static BILLBOARDMODE_NONE: number;
  28505. /**
  28506. * Object will rotate to face the camera but only on the x axis
  28507. */
  28508. static BILLBOARDMODE_X: number;
  28509. /**
  28510. * Object will rotate to face the camera but only on the y axis
  28511. */
  28512. static BILLBOARDMODE_Y: number;
  28513. /**
  28514. * Object will rotate to face the camera but only on the z axis
  28515. */
  28516. static BILLBOARDMODE_Z: number;
  28517. /**
  28518. * Object will rotate to face the camera
  28519. */
  28520. static BILLBOARDMODE_ALL: number;
  28521. private _forward;
  28522. private _forwardInverted;
  28523. private _up;
  28524. private _right;
  28525. private _rightInverted;
  28526. private _position;
  28527. private _rotation;
  28528. private _rotationQuaternion;
  28529. protected _scaling: Vector3;
  28530. protected _isDirty: boolean;
  28531. private _transformToBoneReferal;
  28532. /**
  28533. * Set the billboard mode. Default is 0.
  28534. *
  28535. * | Value | Type | Description |
  28536. * | --- | --- | --- |
  28537. * | 0 | BILLBOARDMODE_NONE | |
  28538. * | 1 | BILLBOARDMODE_X | |
  28539. * | 2 | BILLBOARDMODE_Y | |
  28540. * | 4 | BILLBOARDMODE_Z | |
  28541. * | 7 | BILLBOARDMODE_ALL | |
  28542. *
  28543. */
  28544. billboardMode: number;
  28545. /**
  28546. * 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
  28547. */
  28548. scalingDeterminant: number;
  28549. /**
  28550. * Sets the distance of the object to max, often used by skybox
  28551. */
  28552. infiniteDistance: boolean;
  28553. /**
  28554. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  28555. * By default the system will update normals to compensate
  28556. */
  28557. ignoreNonUniformScaling: boolean;
  28558. /** @hidden */
  28559. _poseMatrix: Matrix;
  28560. private _localWorld;
  28561. private _absolutePosition;
  28562. private _pivotMatrix;
  28563. private _pivotMatrixInverse;
  28564. private _postMultiplyPivotMatrix;
  28565. protected _isWorldMatrixFrozen: boolean;
  28566. /**
  28567. * An event triggered after the world matrix is updated
  28568. */
  28569. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  28570. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  28571. /**
  28572. * Gets a string identifying the name of the class
  28573. * @returns "TransformNode" string
  28574. */
  28575. getClassName(): string;
  28576. /**
  28577. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  28578. */
  28579. position: Vector3;
  28580. /**
  28581. * 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)).
  28582. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  28583. */
  28584. rotation: Vector3;
  28585. /**
  28586. * 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)).
  28587. */
  28588. scaling: Vector3;
  28589. /**
  28590. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  28591. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  28592. */
  28593. rotationQuaternion: Nullable<Quaternion>;
  28594. /**
  28595. * The forward direction of that transform in world space.
  28596. */
  28597. readonly forward: Vector3;
  28598. /**
  28599. * The up direction of that transform in world space.
  28600. */
  28601. readonly up: Vector3;
  28602. /**
  28603. * The right direction of that transform in world space.
  28604. */
  28605. readonly right: Vector3;
  28606. /**
  28607. * Copies the parameter passed Matrix into the mesh Pose matrix.
  28608. * @param matrix the matrix to copy the pose from
  28609. * @returns this TransformNode.
  28610. */
  28611. updatePoseMatrix(matrix: Matrix): TransformNode;
  28612. /**
  28613. * Returns the mesh Pose matrix.
  28614. * @returns the pose matrix
  28615. */
  28616. getPoseMatrix(): Matrix;
  28617. /** @hidden */
  28618. _isSynchronized(): boolean;
  28619. /** @hidden */
  28620. _initCache(): void;
  28621. /**
  28622. * Flag the transform node as dirty (Forcing it to update everything)
  28623. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  28624. * @returns this transform node
  28625. */
  28626. markAsDirty(property: string): TransformNode;
  28627. /**
  28628. * Returns the current mesh absolute position.
  28629. * Returns a Vector3.
  28630. */
  28631. readonly absolutePosition: Vector3;
  28632. /**
  28633. * Sets a new matrix to apply before all other transformation
  28634. * @param matrix defines the transform matrix
  28635. * @returns the current TransformNode
  28636. */
  28637. setPreTransformMatrix(matrix: Matrix): TransformNode;
  28638. /**
  28639. * Sets a new pivot matrix to the current node
  28640. * @param matrix defines the new pivot matrix to use
  28641. * @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
  28642. * @returns the current TransformNode
  28643. */
  28644. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  28645. /**
  28646. * Returns the mesh pivot matrix.
  28647. * Default : Identity.
  28648. * @returns the matrix
  28649. */
  28650. getPivotMatrix(): Matrix;
  28651. /**
  28652. * Prevents the World matrix to be computed any longer.
  28653. * @returns the TransformNode.
  28654. */
  28655. freezeWorldMatrix(): TransformNode;
  28656. /**
  28657. * Allows back the World matrix computation.
  28658. * @returns the TransformNode.
  28659. */
  28660. unfreezeWorldMatrix(): this;
  28661. /**
  28662. * True if the World matrix has been frozen.
  28663. */
  28664. readonly isWorldMatrixFrozen: boolean;
  28665. /**
  28666. * Retuns the mesh absolute position in the World.
  28667. * @returns a Vector3.
  28668. */
  28669. getAbsolutePosition(): Vector3;
  28670. /**
  28671. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  28672. * @param absolutePosition the absolute position to set
  28673. * @returns the TransformNode.
  28674. */
  28675. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28676. /**
  28677. * Sets the mesh position in its local space.
  28678. * @param vector3 the position to set in localspace
  28679. * @returns the TransformNode.
  28680. */
  28681. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  28682. /**
  28683. * Returns the mesh position in the local space from the current World matrix values.
  28684. * @returns a new Vector3.
  28685. */
  28686. getPositionExpressedInLocalSpace(): Vector3;
  28687. /**
  28688. * Translates the mesh along the passed Vector3 in its local space.
  28689. * @param vector3 the distance to translate in localspace
  28690. * @returns the TransformNode.
  28691. */
  28692. locallyTranslate(vector3: Vector3): TransformNode;
  28693. private static _lookAtVectorCache;
  28694. /**
  28695. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  28696. * @param targetPoint the position (must be in same space as current mesh) to look at
  28697. * @param yawCor optional yaw (y-axis) correction in radians
  28698. * @param pitchCor optional pitch (x-axis) correction in radians
  28699. * @param rollCor optional roll (z-axis) correction in radians
  28700. * @param space the choosen space of the target
  28701. * @returns the TransformNode.
  28702. */
  28703. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  28704. /**
  28705. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  28706. * This Vector3 is expressed in the World space.
  28707. * @param localAxis axis to rotate
  28708. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  28709. */
  28710. getDirection(localAxis: Vector3): Vector3;
  28711. /**
  28712. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  28713. * localAxis is expressed in the mesh local space.
  28714. * result is computed in the Wordl space from the mesh World matrix.
  28715. * @param localAxis axis to rotate
  28716. * @param result the resulting transformnode
  28717. * @returns this TransformNode.
  28718. */
  28719. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  28720. /**
  28721. * Sets a new pivot point to the current node
  28722. * @param point defines the new pivot point to use
  28723. * @param space defines if the point is in world or local space (local by default)
  28724. * @returns the current TransformNode
  28725. */
  28726. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  28727. /**
  28728. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  28729. * @returns the pivot point
  28730. */
  28731. getPivotPoint(): Vector3;
  28732. /**
  28733. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  28734. * @param result the vector3 to store the result
  28735. * @returns this TransformNode.
  28736. */
  28737. getPivotPointToRef(result: Vector3): TransformNode;
  28738. /**
  28739. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  28740. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  28741. */
  28742. getAbsolutePivotPoint(): Vector3;
  28743. /**
  28744. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  28745. * @param result vector3 to store the result
  28746. * @returns this TransformNode.
  28747. */
  28748. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  28749. /**
  28750. * Defines the passed node as the parent of the current node.
  28751. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  28752. * @param node the node ot set as the parent
  28753. * @returns this TransformNode.
  28754. */
  28755. setParent(node: Nullable<Node>): TransformNode;
  28756. private _nonUniformScaling;
  28757. /**
  28758. * True if the scaling property of this object is non uniform eg. (1,2,1)
  28759. */
  28760. readonly nonUniformScaling: boolean;
  28761. /** @hidden */
  28762. _updateNonUniformScalingState(value: boolean): boolean;
  28763. /**
  28764. * Attach the current TransformNode to another TransformNode associated with a bone
  28765. * @param bone Bone affecting the TransformNode
  28766. * @param affectedTransformNode TransformNode associated with the bone
  28767. * @returns this object
  28768. */
  28769. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  28770. /**
  28771. * Detach the transform node if its associated with a bone
  28772. * @returns this object
  28773. */
  28774. detachFromBone(): TransformNode;
  28775. private static _rotationAxisCache;
  28776. /**
  28777. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  28778. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  28779. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  28780. * The passed axis is also normalized.
  28781. * @param axis the axis to rotate around
  28782. * @param amount the amount to rotate in radians
  28783. * @param space Space to rotate in (Default: local)
  28784. * @returns the TransformNode.
  28785. */
  28786. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28787. /**
  28788. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  28789. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  28790. * The passed axis is also normalized. .
  28791. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  28792. * @param point the point to rotate around
  28793. * @param axis the axis to rotate around
  28794. * @param amount the amount to rotate in radians
  28795. * @returns the TransformNode
  28796. */
  28797. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  28798. /**
  28799. * Translates the mesh along the axis vector for the passed distance in the given space.
  28800. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  28801. * @param axis the axis to translate in
  28802. * @param distance the distance to translate
  28803. * @param space Space to rotate in (Default: local)
  28804. * @returns the TransformNode.
  28805. */
  28806. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28807. /**
  28808. * Adds a rotation step to the mesh current rotation.
  28809. * x, y, z are Euler angles expressed in radians.
  28810. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  28811. * This means this rotation is made in the mesh local space only.
  28812. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  28813. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  28814. * ```javascript
  28815. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  28816. * ```
  28817. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  28818. * 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.
  28819. * @param x Rotation to add
  28820. * @param y Rotation to add
  28821. * @param z Rotation to add
  28822. * @returns the TransformNode.
  28823. */
  28824. addRotation(x: number, y: number, z: number): TransformNode;
  28825. /**
  28826. * Computes the world matrix of the node
  28827. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28828. * @returns the world matrix
  28829. */
  28830. computeWorldMatrix(force?: boolean): Matrix;
  28831. protected _afterComputeWorldMatrix(): void;
  28832. /**
  28833. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  28834. * @param func callback function to add
  28835. *
  28836. * @returns the TransformNode.
  28837. */
  28838. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  28839. /**
  28840. * Removes a registered callback function.
  28841. * @param func callback function to remove
  28842. * @returns the TransformNode.
  28843. */
  28844. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  28845. /**
  28846. * Clone the current transform node
  28847. * @param name Name of the new clone
  28848. * @param newParent New parent for the clone
  28849. * @param doNotCloneChildren Do not clone children hierarchy
  28850. * @returns the new transform node
  28851. */
  28852. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  28853. /**
  28854. * Serializes the objects information.
  28855. * @param currentSerializationObject defines the object to serialize in
  28856. * @returns the serialized object
  28857. */
  28858. serialize(currentSerializationObject?: any): any;
  28859. /**
  28860. * Returns a new TransformNode object parsed from the source provided.
  28861. * @param parsedTransformNode is the source.
  28862. * @param scene the scne the object belongs to
  28863. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  28864. * @returns a new TransformNode object parsed from the source provided.
  28865. */
  28866. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  28867. /**
  28868. * Releases resources associated with this transform node.
  28869. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28870. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28871. */
  28872. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28873. }
  28874. }
  28875. declare module BABYLON {
  28876. /**
  28877. * Specialized buffer used to store vertex data
  28878. */
  28879. class VertexBuffer {
  28880. /** @hidden */
  28881. _buffer: Buffer;
  28882. private _kind;
  28883. private _size;
  28884. private _ownsBuffer;
  28885. private _instanced;
  28886. private _instanceDivisor;
  28887. /**
  28888. * The byte type.
  28889. */
  28890. static readonly BYTE: number;
  28891. /**
  28892. * The unsigned byte type.
  28893. */
  28894. static readonly UNSIGNED_BYTE: number;
  28895. /**
  28896. * The short type.
  28897. */
  28898. static readonly SHORT: number;
  28899. /**
  28900. * The unsigned short type.
  28901. */
  28902. static readonly UNSIGNED_SHORT: number;
  28903. /**
  28904. * The integer type.
  28905. */
  28906. static readonly INT: number;
  28907. /**
  28908. * The unsigned integer type.
  28909. */
  28910. static readonly UNSIGNED_INT: number;
  28911. /**
  28912. * The float type.
  28913. */
  28914. static readonly FLOAT: number;
  28915. /**
  28916. * Gets or sets the instance divisor when in instanced mode
  28917. */
  28918. instanceDivisor: number;
  28919. /**
  28920. * Gets the byte stride.
  28921. */
  28922. readonly byteStride: number;
  28923. /**
  28924. * Gets the byte offset.
  28925. */
  28926. readonly byteOffset: number;
  28927. /**
  28928. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  28929. */
  28930. readonly normalized: boolean;
  28931. /**
  28932. * Gets the data type of each component in the array.
  28933. */
  28934. readonly type: number;
  28935. /**
  28936. * Constructor
  28937. * @param engine the engine
  28938. * @param data the data to use for this vertex buffer
  28939. * @param kind the vertex buffer kind
  28940. * @param updatable whether the data is updatable
  28941. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  28942. * @param stride the stride (optional)
  28943. * @param instanced whether the buffer is instanced (optional)
  28944. * @param offset the offset of the data (optional)
  28945. * @param size the number of components (optional)
  28946. * @param type the type of the component (optional)
  28947. * @param normalized whether the data contains normalized data (optional)
  28948. * @param useBytes set to true if stride and offset are in bytes (optional)
  28949. */
  28950. 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);
  28951. /** @hidden */
  28952. _rebuild(): void;
  28953. /**
  28954. * Returns the kind of the VertexBuffer (string)
  28955. * @returns a string
  28956. */
  28957. getKind(): string;
  28958. /**
  28959. * Gets a boolean indicating if the VertexBuffer is updatable?
  28960. * @returns true if the buffer is updatable
  28961. */
  28962. isUpdatable(): boolean;
  28963. /**
  28964. * Gets current buffer's data
  28965. * @returns a DataArray or null
  28966. */
  28967. getData(): Nullable<DataArray>;
  28968. /**
  28969. * Gets underlying native buffer
  28970. * @returns underlying native buffer
  28971. */
  28972. getBuffer(): Nullable<WebGLBuffer>;
  28973. /**
  28974. * Gets the stride in float32 units (i.e. byte stride / 4).
  28975. * May not be an integer if the byte stride is not divisible by 4.
  28976. * DEPRECATED. Use byteStride instead.
  28977. * @returns the stride in float32 units
  28978. */
  28979. getStrideSize(): number;
  28980. /**
  28981. * Returns the offset as a multiple of the type byte length.
  28982. * DEPRECATED. Use byteOffset instead.
  28983. * @returns the offset in bytes
  28984. */
  28985. getOffset(): number;
  28986. /**
  28987. * Returns the number of components per vertex attribute (integer)
  28988. * @returns the size in float
  28989. */
  28990. getSize(): number;
  28991. /**
  28992. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  28993. * @returns true if this buffer is instanced
  28994. */
  28995. getIsInstanced(): boolean;
  28996. /**
  28997. * Returns the instancing divisor, zero for non-instanced (integer).
  28998. * @returns a number
  28999. */
  29000. getInstanceDivisor(): number;
  29001. /**
  29002. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29003. * @param data defines the data to store
  29004. */
  29005. create(data?: DataArray): void;
  29006. /**
  29007. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29008. * This function will create a new buffer if the current one is not updatable
  29009. * @param data defines the data to store
  29010. */
  29011. update(data: DataArray): void;
  29012. /**
  29013. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29014. * Returns the directly updated WebGLBuffer.
  29015. * @param data the new data
  29016. * @param offset the new offset
  29017. * @param useBytes set to true if the offset is in bytes
  29018. */
  29019. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29020. /**
  29021. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29022. */
  29023. dispose(): void;
  29024. /**
  29025. * Enumerates each value of this vertex buffer as numbers.
  29026. * @param count the number of values to enumerate
  29027. * @param callback the callback function called for each value
  29028. */
  29029. forEach(count: number, callback: (value: number, index: number) => void): void;
  29030. /**
  29031. * Positions
  29032. */
  29033. static readonly PositionKind: string;
  29034. /**
  29035. * Normals
  29036. */
  29037. static readonly NormalKind: string;
  29038. /**
  29039. * Tangents
  29040. */
  29041. static readonly TangentKind: string;
  29042. /**
  29043. * Texture coordinates
  29044. */
  29045. static readonly UVKind: string;
  29046. /**
  29047. * Texture coordinates 2
  29048. */
  29049. static readonly UV2Kind: string;
  29050. /**
  29051. * Texture coordinates 3
  29052. */
  29053. static readonly UV3Kind: string;
  29054. /**
  29055. * Texture coordinates 4
  29056. */
  29057. static readonly UV4Kind: string;
  29058. /**
  29059. * Texture coordinates 5
  29060. */
  29061. static readonly UV5Kind: string;
  29062. /**
  29063. * Texture coordinates 6
  29064. */
  29065. static readonly UV6Kind: string;
  29066. /**
  29067. * Colors
  29068. */
  29069. static readonly ColorKind: string;
  29070. /**
  29071. * Matrix indices (for bones)
  29072. */
  29073. static readonly MatricesIndicesKind: string;
  29074. /**
  29075. * Matrix weights (for bones)
  29076. */
  29077. static readonly MatricesWeightsKind: string;
  29078. /**
  29079. * Additional matrix indices (for bones)
  29080. */
  29081. static readonly MatricesIndicesExtraKind: string;
  29082. /**
  29083. * Additional matrix weights (for bones)
  29084. */
  29085. static readonly MatricesWeightsExtraKind: string;
  29086. /**
  29087. * Deduces the stride given a kind.
  29088. * @param kind The kind string to deduce
  29089. * @returns The deduced stride
  29090. */
  29091. static DeduceStride(kind: string): number;
  29092. /**
  29093. * Gets the byte length of the given type.
  29094. * @param type the type
  29095. * @returns the number of bytes
  29096. */
  29097. static GetTypeByteLength(type: number): number;
  29098. /**
  29099. * Enumerates each value of the given parameters as numbers.
  29100. * @param data the data to enumerate
  29101. * @param byteOffset the byte offset of the data
  29102. * @param byteStride the byte stride of the data
  29103. * @param componentCount the number of components per element
  29104. * @param componentType the type of the component
  29105. * @param count the total number of components
  29106. * @param normalized whether the data is normalized
  29107. * @param callback the callback function called for each value
  29108. */
  29109. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29110. private static _GetFloatValue;
  29111. }
  29112. }
  29113. declare module BABYLON {
  29114. /**
  29115. * Defines a target to use with MorphTargetManager
  29116. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29117. */
  29118. class MorphTarget implements IAnimatable {
  29119. /** defines the name of the target */
  29120. name: string;
  29121. /**
  29122. * Gets or sets the list of animations
  29123. */
  29124. animations: Animation[];
  29125. private _scene;
  29126. private _positions;
  29127. private _normals;
  29128. private _tangents;
  29129. private _influence;
  29130. /**
  29131. * Observable raised when the influence changes
  29132. */
  29133. onInfluenceChanged: Observable<boolean>;
  29134. /**
  29135. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29136. */
  29137. influence: number;
  29138. private _animationPropertiesOverride;
  29139. /**
  29140. * Gets or sets the animation properties override
  29141. */
  29142. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29143. /**
  29144. * Creates a new MorphTarget
  29145. * @param name defines the name of the target
  29146. * @param influence defines the influence to use
  29147. */
  29148. constructor(
  29149. /** defines the name of the target */
  29150. name: string, influence?: number, scene?: Nullable<Scene>);
  29151. /**
  29152. * Gets a boolean defining if the target contains position data
  29153. */
  29154. readonly hasPositions: boolean;
  29155. /**
  29156. * Gets a boolean defining if the target contains normal data
  29157. */
  29158. readonly hasNormals: boolean;
  29159. /**
  29160. * Gets a boolean defining if the target contains tangent data
  29161. */
  29162. readonly hasTangents: boolean;
  29163. /**
  29164. * Affects position data to this target
  29165. * @param data defines the position data to use
  29166. */
  29167. setPositions(data: Nullable<FloatArray>): void;
  29168. /**
  29169. * Gets the position data stored in this target
  29170. * @returns a FloatArray containing the position data (or null if not present)
  29171. */
  29172. getPositions(): Nullable<FloatArray>;
  29173. /**
  29174. * Affects normal data to this target
  29175. * @param data defines the normal data to use
  29176. */
  29177. setNormals(data: Nullable<FloatArray>): void;
  29178. /**
  29179. * Gets the normal data stored in this target
  29180. * @returns a FloatArray containing the normal data (or null if not present)
  29181. */
  29182. getNormals(): Nullable<FloatArray>;
  29183. /**
  29184. * Affects tangent data to this target
  29185. * @param data defines the tangent data to use
  29186. */
  29187. setTangents(data: Nullable<FloatArray>): void;
  29188. /**
  29189. * Gets the tangent data stored in this target
  29190. * @returns a FloatArray containing the tangent data (or null if not present)
  29191. */
  29192. getTangents(): Nullable<FloatArray>;
  29193. /**
  29194. * Serializes the current target into a Serialization object
  29195. * @returns the serialized object
  29196. */
  29197. serialize(): any;
  29198. /**
  29199. * Creates a new target from serialized data
  29200. * @param serializationObject defines the serialized data to use
  29201. * @returns a new MorphTarget
  29202. */
  29203. static Parse(serializationObject: any): MorphTarget;
  29204. /**
  29205. * Creates a MorphTarget from mesh data
  29206. * @param mesh defines the source mesh
  29207. * @param name defines the name to use for the new target
  29208. * @param influence defines the influence to attach to the target
  29209. * @returns a new MorphTarget
  29210. */
  29211. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  29212. }
  29213. }
  29214. declare module BABYLON {
  29215. /**
  29216. * This class is used to deform meshes using morphing between different targets
  29217. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29218. */
  29219. class MorphTargetManager {
  29220. private _targets;
  29221. private _targetObservable;
  29222. private _activeTargets;
  29223. private _scene;
  29224. private _influences;
  29225. private _supportsNormals;
  29226. private _supportsTangents;
  29227. private _vertexCount;
  29228. private _uniqueId;
  29229. private _tempInfluences;
  29230. /**
  29231. * Creates a new MorphTargetManager
  29232. * @param scene defines the current scene
  29233. */
  29234. constructor(scene?: Nullable<Scene>);
  29235. /**
  29236. * Gets the unique ID of this manager
  29237. */
  29238. readonly uniqueId: number;
  29239. /**
  29240. * Gets the number of vertices handled by this manager
  29241. */
  29242. readonly vertexCount: number;
  29243. /**
  29244. * Gets a boolean indicating if this manager supports morphing of normals
  29245. */
  29246. readonly supportsNormals: boolean;
  29247. /**
  29248. * Gets a boolean indicating if this manager supports morphing of tangents
  29249. */
  29250. readonly supportsTangents: boolean;
  29251. /**
  29252. * Gets the number of targets stored in this manager
  29253. */
  29254. readonly numTargets: number;
  29255. /**
  29256. * Gets the number of influencers (ie. the number of targets with influences > 0)
  29257. */
  29258. readonly numInfluencers: number;
  29259. /**
  29260. * Gets the list of influences (one per target)
  29261. */
  29262. readonly influences: Float32Array;
  29263. /**
  29264. * Gets the active target at specified index. An active target is a target with an influence > 0
  29265. * @param index defines the index to check
  29266. * @returns the requested target
  29267. */
  29268. getActiveTarget(index: number): MorphTarget;
  29269. /**
  29270. * Gets the target at specified index
  29271. * @param index defines the index to check
  29272. * @returns the requested target
  29273. */
  29274. getTarget(index: number): MorphTarget;
  29275. /**
  29276. * Add a new target to this manager
  29277. * @param target defines the target to add
  29278. */
  29279. addTarget(target: MorphTarget): void;
  29280. /**
  29281. * Removes a target from the manager
  29282. * @param target defines the target to remove
  29283. */
  29284. removeTarget(target: MorphTarget): void;
  29285. /**
  29286. * Serializes the current manager into a Serialization object
  29287. * @returns the serialized object
  29288. */
  29289. serialize(): any;
  29290. private _syncActiveTargets;
  29291. /**
  29292. * Syncrhonize the targets with all the meshes using this morph target manager
  29293. */
  29294. synchronize(): void;
  29295. /**
  29296. * Creates a new MorphTargetManager from serialized data
  29297. * @param serializationObject defines the serialized data
  29298. * @param scene defines the hosting scene
  29299. * @returns the new MorphTargetManager
  29300. */
  29301. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  29302. }
  29303. }
  29304. declare module BABYLON {
  29305. /**
  29306. * This represents the base class for particle system in Babylon.
  29307. * 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.
  29308. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  29309. * @example https://doc.babylonjs.com/babylon101/particles
  29310. */
  29311. class BaseParticleSystem {
  29312. /**
  29313. * Source color is added to the destination color without alpha affecting the result
  29314. */
  29315. static BLENDMODE_ONEONE: number;
  29316. /**
  29317. * Blend current color and particle color using particle’s alpha
  29318. */
  29319. static BLENDMODE_STANDARD: number;
  29320. /**
  29321. * Add current color and particle color multiplied by particle’s alpha
  29322. */
  29323. static BLENDMODE_ADD: number;
  29324. /**
  29325. * Multiply current color with particle color
  29326. */
  29327. static BLENDMODE_MULTIPLY: number;
  29328. /**
  29329. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  29330. */
  29331. static BLENDMODE_MULTIPLYADD: number;
  29332. /**
  29333. * List of animations used by the particle system.
  29334. */
  29335. animations: Animation[];
  29336. /**
  29337. * The id of the Particle system.
  29338. */
  29339. id: string;
  29340. /**
  29341. * The friendly name of the Particle system.
  29342. */
  29343. name: string;
  29344. /**
  29345. * The rendering group used by the Particle system to chose when to render.
  29346. */
  29347. renderingGroupId: number;
  29348. /**
  29349. * The emitter represents the Mesh or position we are attaching the particle system to.
  29350. */
  29351. emitter: Nullable<AbstractMesh | Vector3>;
  29352. /**
  29353. * The maximum number of particles to emit per frame
  29354. */
  29355. emitRate: number;
  29356. /**
  29357. * If you want to launch only a few particles at once, that can be done, as well.
  29358. */
  29359. manualEmitCount: number;
  29360. /**
  29361. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  29362. */
  29363. updateSpeed: number;
  29364. /**
  29365. * The amount of time the particle system is running (depends of the overall update speed).
  29366. */
  29367. targetStopDuration: number;
  29368. /**
  29369. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  29370. */
  29371. disposeOnStop: boolean;
  29372. /**
  29373. * Minimum power of emitting particles.
  29374. */
  29375. minEmitPower: number;
  29376. /**
  29377. * Maximum power of emitting particles.
  29378. */
  29379. maxEmitPower: number;
  29380. /**
  29381. * Minimum life time of emitting particles.
  29382. */
  29383. minLifeTime: number;
  29384. /**
  29385. * Maximum life time of emitting particles.
  29386. */
  29387. maxLifeTime: number;
  29388. /**
  29389. * Minimum Size of emitting particles.
  29390. */
  29391. minSize: number;
  29392. /**
  29393. * Maximum Size of emitting particles.
  29394. */
  29395. maxSize: number;
  29396. /**
  29397. * Minimum scale of emitting particles on X axis.
  29398. */
  29399. minScaleX: number;
  29400. /**
  29401. * Maximum scale of emitting particles on X axis.
  29402. */
  29403. maxScaleX: number;
  29404. /**
  29405. * Minimum scale of emitting particles on Y axis.
  29406. */
  29407. minScaleY: number;
  29408. /**
  29409. * Maximum scale of emitting particles on Y axis.
  29410. */
  29411. maxScaleY: number;
  29412. /**
  29413. * Gets or sets the minimal initial rotation in radians.
  29414. */
  29415. minInitialRotation: number;
  29416. /**
  29417. * Gets or sets the maximal initial rotation in radians.
  29418. */
  29419. maxInitialRotation: number;
  29420. /**
  29421. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  29422. */
  29423. minAngularSpeed: number;
  29424. /**
  29425. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  29426. */
  29427. maxAngularSpeed: number;
  29428. /**
  29429. * The texture used to render each particle. (this can be a spritesheet)
  29430. */
  29431. particleTexture: Nullable<Texture>;
  29432. /**
  29433. * The layer mask we are rendering the particles through.
  29434. */
  29435. layerMask: number;
  29436. /**
  29437. * This can help using your own shader to render the particle system.
  29438. * The according effect will be created
  29439. */
  29440. customShader: any;
  29441. /**
  29442. * By default particle system starts as soon as they are created. This prevents the
  29443. * automatic start to happen and let you decide when to start emitting particles.
  29444. */
  29445. preventAutoStart: boolean;
  29446. /**
  29447. * Gets or sets a texture used to add random noise to particle positions
  29448. */
  29449. noiseTexture: Nullable<ProceduralTexture>;
  29450. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  29451. noiseStrength: Vector3;
  29452. /**
  29453. * Callback triggered when the particle animation is ending.
  29454. */
  29455. onAnimationEnd: Nullable<() => void>;
  29456. /**
  29457. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  29458. */
  29459. blendMode: number;
  29460. /**
  29461. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  29462. * to override the particles.
  29463. */
  29464. forceDepthWrite: boolean;
  29465. /** 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 */
  29466. preWarmCycles: number;
  29467. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  29468. preWarmStepOffset: number;
  29469. /**
  29470. * 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)
  29471. */
  29472. spriteCellChangeSpeed: number;
  29473. /**
  29474. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  29475. */
  29476. startSpriteCellID: number;
  29477. /**
  29478. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  29479. */
  29480. endSpriteCellID: number;
  29481. /**
  29482. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  29483. */
  29484. spriteCellWidth: number;
  29485. /**
  29486. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  29487. */
  29488. spriteCellHeight: number;
  29489. /**
  29490. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  29491. */
  29492. spriteRandomStartCell: boolean;
  29493. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  29494. translationPivot: Vector2;
  29495. /** @hidden */
  29496. protected _isAnimationSheetEnabled: boolean;
  29497. /**
  29498. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  29499. */
  29500. beginAnimationOnStart: boolean;
  29501. /**
  29502. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  29503. */
  29504. beginAnimationFrom: number;
  29505. /**
  29506. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  29507. */
  29508. beginAnimationTo: number;
  29509. /**
  29510. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  29511. */
  29512. beginAnimationLoop: boolean;
  29513. /**
  29514. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  29515. */
  29516. isAnimationSheetEnabled: boolean;
  29517. /**
  29518. * Get hosting scene
  29519. * @returns the scene
  29520. */
  29521. getScene(): Scene;
  29522. /**
  29523. * You can use gravity if you want to give an orientation to your particles.
  29524. */
  29525. gravity: Vector3;
  29526. protected _colorGradients: Nullable<Array<ColorGradient>>;
  29527. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  29528. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  29529. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  29530. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  29531. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  29532. protected _dragGradients: Nullable<Array<FactorGradient>>;
  29533. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  29534. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  29535. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  29536. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  29537. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  29538. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  29539. /**
  29540. * Defines the delay in milliseconds before starting the system (0 by default)
  29541. */
  29542. startDelay: number;
  29543. /**
  29544. * Gets the current list of drag gradients.
  29545. * You must use addDragGradient and removeDragGradient to udpate this list
  29546. * @returns the list of drag gradients
  29547. */
  29548. getDragGradients(): Nullable<Array<FactorGradient>>;
  29549. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  29550. limitVelocityDamping: number;
  29551. /**
  29552. * Gets the current list of limit velocity gradients.
  29553. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  29554. * @returns the list of limit velocity gradients
  29555. */
  29556. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  29557. /**
  29558. * Gets the current list of color gradients.
  29559. * You must use addColorGradient and removeColorGradient to udpate this list
  29560. * @returns the list of color gradients
  29561. */
  29562. getColorGradients(): Nullable<Array<ColorGradient>>;
  29563. /**
  29564. * Gets the current list of size gradients.
  29565. * You must use addSizeGradient and removeSizeGradient to udpate this list
  29566. * @returns the list of size gradients
  29567. */
  29568. getSizeGradients(): Nullable<Array<FactorGradient>>;
  29569. /**
  29570. * Gets the current list of color remap gradients.
  29571. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  29572. * @returns the list of color remap gradients
  29573. */
  29574. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  29575. /**
  29576. * Gets the current list of alpha remap gradients.
  29577. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  29578. * @returns the list of alpha remap gradients
  29579. */
  29580. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  29581. /**
  29582. * Gets the current list of life time gradients.
  29583. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  29584. * @returns the list of life time gradients
  29585. */
  29586. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  29587. /**
  29588. * Gets the current list of angular speed gradients.
  29589. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  29590. * @returns the list of angular speed gradients
  29591. */
  29592. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  29593. /**
  29594. * Gets the current list of velocity gradients.
  29595. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  29596. * @returns the list of velocity gradients
  29597. */
  29598. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  29599. /**
  29600. * Gets the current list of start size gradients.
  29601. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  29602. * @returns the list of start size gradients
  29603. */
  29604. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  29605. /**
  29606. * Gets the current list of emit rate gradients.
  29607. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  29608. * @returns the list of emit rate gradients
  29609. */
  29610. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  29611. /**
  29612. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  29613. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29614. */
  29615. direction1: Vector3;
  29616. /**
  29617. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  29618. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29619. */
  29620. direction2: Vector3;
  29621. /**
  29622. * 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.
  29623. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29624. */
  29625. minEmitBox: Vector3;
  29626. /**
  29627. * 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.
  29628. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29629. */
  29630. maxEmitBox: Vector3;
  29631. /**
  29632. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  29633. */
  29634. color1: Color4;
  29635. /**
  29636. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  29637. */
  29638. color2: Color4;
  29639. /**
  29640. * Color the particle will have at the end of its lifetime
  29641. */
  29642. colorDead: Color4;
  29643. /**
  29644. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  29645. */
  29646. textureMask: Color4;
  29647. /**
  29648. * The particle emitter type defines the emitter used by the particle system.
  29649. * It can be for example box, sphere, or cone...
  29650. */
  29651. particleEmitterType: IParticleEmitterType;
  29652. /** @hidden */
  29653. _isSubEmitter: boolean;
  29654. /**
  29655. * Gets or sets the billboard mode to use when isBillboardBased = true.
  29656. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  29657. */
  29658. billboardMode: number;
  29659. protected _isBillboardBased: boolean;
  29660. /**
  29661. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  29662. */
  29663. isBillboardBased: boolean;
  29664. /**
  29665. * The scene the particle system belongs to.
  29666. */
  29667. protected _scene: Scene;
  29668. /**
  29669. * Local cache of defines for image processing.
  29670. */
  29671. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  29672. /**
  29673. * Default configuration related to image processing available in the standard Material.
  29674. */
  29675. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29676. /**
  29677. * Gets the image processing configuration used either in this material.
  29678. */
  29679. /**
  29680. * Sets the Default image processing configuration used either in the this material.
  29681. *
  29682. * If sets to null, the scene one is in use.
  29683. */
  29684. imageProcessingConfiguration: ImageProcessingConfiguration;
  29685. /**
  29686. * Attaches a new image processing configuration to the Standard Material.
  29687. * @param configuration
  29688. */
  29689. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29690. /** @hidden */
  29691. protected _reset(): void;
  29692. /** @hidden */
  29693. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  29694. /**
  29695. * Instantiates a particle system.
  29696. * 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.
  29697. * @param name The name of the particle system
  29698. */
  29699. constructor(name: string);
  29700. /**
  29701. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  29702. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  29703. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  29704. * @returns the emitter
  29705. */
  29706. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  29707. /**
  29708. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  29709. * @param radius The radius of the hemisphere to emit from
  29710. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  29711. * @returns the emitter
  29712. */
  29713. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  29714. /**
  29715. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  29716. * @param radius The radius of the sphere to emit from
  29717. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  29718. * @returns the emitter
  29719. */
  29720. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  29721. /**
  29722. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  29723. * @param radius The radius of the sphere to emit from
  29724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  29725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  29726. * @returns the emitter
  29727. */
  29728. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  29729. /**
  29730. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  29731. * @param radius The radius of the emission cylinder
  29732. * @param height The height of the emission cylinder
  29733. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  29734. * @param directionRandomizer How much to randomize the particle direction [0-1]
  29735. * @returns the emitter
  29736. */
  29737. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  29738. /**
  29739. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  29740. * @param radius The radius of the cylinder to emit from
  29741. * @param height The height of the emission cylinder
  29742. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  29743. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  29744. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  29745. * @returns the emitter
  29746. */
  29747. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  29748. /**
  29749. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  29750. * @param radius The radius of the cone to emit from
  29751. * @param angle The base angle of the cone
  29752. * @returns the emitter
  29753. */
  29754. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  29755. /**
  29756. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  29757. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  29758. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  29759. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  29760. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  29761. * @returns the emitter
  29762. */
  29763. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  29764. }
  29765. }
  29766. declare module BABYLON {
  29767. /**
  29768. * This represents a GPU particle system in Babylon
  29769. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  29770. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  29771. */
  29772. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  29773. /**
  29774. * The layer mask we are rendering the particles through.
  29775. */
  29776. layerMask: number;
  29777. private _capacity;
  29778. private _activeCount;
  29779. private _currentActiveCount;
  29780. private _accumulatedCount;
  29781. private _renderEffect;
  29782. private _updateEffect;
  29783. private _buffer0;
  29784. private _buffer1;
  29785. private _spriteBuffer;
  29786. private _updateVAO;
  29787. private _renderVAO;
  29788. private _targetIndex;
  29789. private _sourceBuffer;
  29790. private _targetBuffer;
  29791. private _engine;
  29792. private _currentRenderId;
  29793. private _started;
  29794. private _stopped;
  29795. private _timeDelta;
  29796. private _randomTexture;
  29797. private _randomTexture2;
  29798. private _attributesStrideSize;
  29799. private _updateEffectOptions;
  29800. private _randomTextureSize;
  29801. private _actualFrame;
  29802. private readonly _rawTextureWidth;
  29803. /**
  29804. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  29805. */
  29806. static readonly IsSupported: boolean;
  29807. /**
  29808. * An event triggered when the system is disposed.
  29809. */
  29810. onDisposeObservable: Observable<GPUParticleSystem>;
  29811. /**
  29812. * Gets the maximum number of particles active at the same time.
  29813. * @returns The max number of active particles.
  29814. */
  29815. getCapacity(): number;
  29816. /**
  29817. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  29818. * to override the particles.
  29819. */
  29820. forceDepthWrite: boolean;
  29821. /**
  29822. * Gets or set the number of active particles
  29823. */
  29824. activeParticleCount: number;
  29825. private _preWarmDone;
  29826. /**
  29827. * Is this system ready to be used/rendered
  29828. * @return true if the system is ready
  29829. */
  29830. isReady(): boolean;
  29831. /**
  29832. * Gets if the system has been started. (Note: this will still be true after stop is called)
  29833. * @returns True if it has been started, otherwise false.
  29834. */
  29835. isStarted(): boolean;
  29836. /**
  29837. * Starts the particle system and begins to emit
  29838. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  29839. */
  29840. start(delay?: number): void;
  29841. /**
  29842. * Stops the particle system.
  29843. */
  29844. stop(): void;
  29845. /**
  29846. * Remove all active particles
  29847. */
  29848. reset(): void;
  29849. /**
  29850. * Returns the string "GPUParticleSystem"
  29851. * @returns a string containing the class name
  29852. */
  29853. getClassName(): string;
  29854. private _colorGradientsTexture;
  29855. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  29856. /**
  29857. * Adds a new color gradient
  29858. * @param gradient defines the gradient to use (between 0 and 1)
  29859. * @param color1 defines the color to affect to the specified gradient
  29860. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  29861. * @returns the current particle system
  29862. */
  29863. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  29864. /**
  29865. * Remove a specific color gradient
  29866. * @param gradient defines the gradient to remove
  29867. * @returns the current particle system
  29868. */
  29869. removeColorGradient(gradient: number): GPUParticleSystem;
  29870. private _angularSpeedGradientsTexture;
  29871. private _sizeGradientsTexture;
  29872. private _velocityGradientsTexture;
  29873. private _limitVelocityGradientsTexture;
  29874. private _dragGradientsTexture;
  29875. private _addFactorGradient;
  29876. /**
  29877. * Adds a new size gradient
  29878. * @param gradient defines the gradient to use (between 0 and 1)
  29879. * @param factor defines the size factor to affect to the specified gradient
  29880. * @returns the current particle system
  29881. */
  29882. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  29883. /**
  29884. * Remove a specific size gradient
  29885. * @param gradient defines the gradient to remove
  29886. * @returns the current particle system
  29887. */
  29888. removeSizeGradient(gradient: number): GPUParticleSystem;
  29889. /**
  29890. * Adds a new angular speed gradient
  29891. * @param gradient defines the gradient to use (between 0 and 1)
  29892. * @param factor defines the angular speed to affect to the specified gradient
  29893. * @returns the current particle system
  29894. */
  29895. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  29896. /**
  29897. * Remove a specific angular speed gradient
  29898. * @param gradient defines the gradient to remove
  29899. * @returns the current particle system
  29900. */
  29901. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  29902. /**
  29903. * Adds a new velocity gradient
  29904. * @param gradient defines the gradient to use (between 0 and 1)
  29905. * @param factor defines the velocity to affect to the specified gradient
  29906. * @returns the current particle system
  29907. */
  29908. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  29909. /**
  29910. * Remove a specific velocity gradient
  29911. * @param gradient defines the gradient to remove
  29912. * @returns the current particle system
  29913. */
  29914. removeVelocityGradient(gradient: number): GPUParticleSystem;
  29915. /**
  29916. * Adds a new limit velocity gradient
  29917. * @param gradient defines the gradient to use (between 0 and 1)
  29918. * @param factor defines the limit velocity value to affect to the specified gradient
  29919. * @returns the current particle system
  29920. */
  29921. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  29922. /**
  29923. * Remove a specific limit velocity gradient
  29924. * @param gradient defines the gradient to remove
  29925. * @returns the current particle system
  29926. */
  29927. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  29928. /**
  29929. * Adds a new drag gradient
  29930. * @param gradient defines the gradient to use (between 0 and 1)
  29931. * @param factor defines the drag value to affect to the specified gradient
  29932. * @returns the current particle system
  29933. */
  29934. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  29935. /**
  29936. * Remove a specific drag gradient
  29937. * @param gradient defines the gradient to remove
  29938. * @returns the current particle system
  29939. */
  29940. removeDragGradient(gradient: number): GPUParticleSystem;
  29941. /**
  29942. * Not supported by GPUParticleSystem
  29943. * @param gradient defines the gradient to use (between 0 and 1)
  29944. * @param factor defines the emit rate value to affect to the specified gradient
  29945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29946. * @returns the current particle system
  29947. */
  29948. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29949. /**
  29950. * Not supported by GPUParticleSystem
  29951. * @param gradient defines the gradient to remove
  29952. * @returns the current particle system
  29953. */
  29954. removeEmitRateGradient(gradient: number): IParticleSystem;
  29955. /**
  29956. * Not supported by GPUParticleSystem
  29957. * @param gradient defines the gradient to use (between 0 and 1)
  29958. * @param factor defines the start size value to affect to the specified gradient
  29959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29960. * @returns the current particle system
  29961. */
  29962. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29963. /**
  29964. * Not supported by GPUParticleSystem
  29965. * @param gradient defines the gradient to remove
  29966. * @returns the current particle system
  29967. */
  29968. removeStartSizeGradient(gradient: number): IParticleSystem;
  29969. /**
  29970. * Not supported by GPUParticleSystem
  29971. * @param gradient defines the gradient to use (between 0 and 1)
  29972. * @param min defines the color remap minimal range
  29973. * @param max defines the color remap maximal range
  29974. * @returns the current particle system
  29975. */
  29976. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  29977. /**
  29978. * Not supported by GPUParticleSystem
  29979. * @param gradient defines the gradient to remove
  29980. * @returns the current particle system
  29981. */
  29982. removeColorRemapGradient(gradient: number): IParticleSystem;
  29983. /**
  29984. * Not supported by GPUParticleSystem
  29985. * @param gradient defines the gradient to use (between 0 and 1)
  29986. * @param min defines the alpha remap minimal range
  29987. * @param max defines the alpha remap maximal range
  29988. * @returns the current particle system
  29989. */
  29990. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  29991. /**
  29992. * Not supported by GPUParticleSystem
  29993. * @param gradient defines the gradient to remove
  29994. * @returns the current particle system
  29995. */
  29996. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  29997. /**
  29998. * Not supported by GPUParticleSystem
  29999. * @param gradient defines the gradient to use (between 0 and 1)
  30000. * @param color defines the color to affect to the specified gradient
  30001. * @returns the current particle system
  30002. */
  30003. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30004. /**
  30005. * Not supported by GPUParticleSystem
  30006. * @param gradient defines the gradient to remove
  30007. * @returns the current particle system
  30008. */
  30009. removeRampGradient(gradient: number): IParticleSystem;
  30010. /**
  30011. * Not supported by GPUParticleSystem
  30012. * @returns the list of ramp gradients
  30013. */
  30014. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30015. /**
  30016. * Not supported by GPUParticleSystem
  30017. * Gets or sets a boolean indicating that ramp gradients must be used
  30018. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30019. */
  30020. useRampGradients: boolean;
  30021. /**
  30022. * Not supported by GPUParticleSystem
  30023. * @param gradient defines the gradient to use (between 0 and 1)
  30024. * @param factor defines the life time factor to affect to the specified gradient
  30025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30026. * @returns the current particle system
  30027. */
  30028. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30029. /**
  30030. * Not supported by GPUParticleSystem
  30031. * @param gradient defines the gradient to remove
  30032. * @returns the current particle system
  30033. */
  30034. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30035. /**
  30036. * Instantiates a GPU particle system.
  30037. * 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.
  30038. * @param name The name of the particle system
  30039. * @param options The options used to create the system
  30040. * @param scene The scene the particle system belongs to
  30041. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30042. */
  30043. constructor(name: string, options: Partial<{
  30044. capacity: number;
  30045. randomTextureSize: number;
  30046. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  30047. protected _reset(): void;
  30048. private _createUpdateVAO;
  30049. private _createRenderVAO;
  30050. private _initialize;
  30051. /** @hidden */
  30052. _recreateUpdateEffect(): void;
  30053. /** @hidden */
  30054. _recreateRenderEffect(): void;
  30055. /**
  30056. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  30057. * @param preWarm defines if we are in the pre-warmimg phase
  30058. */
  30059. animate(preWarm?: boolean): void;
  30060. private _createFactorGradientTexture;
  30061. private _createSizeGradientTexture;
  30062. private _createAngularSpeedGradientTexture;
  30063. private _createVelocityGradientTexture;
  30064. private _createLimitVelocityGradientTexture;
  30065. private _createDragGradientTexture;
  30066. private _createColorGradientTexture;
  30067. /**
  30068. * Renders the particle system in its current state
  30069. * @param preWarm defines if the system should only update the particles but not render them
  30070. * @returns the current number of particles
  30071. */
  30072. render(preWarm?: boolean): number;
  30073. /**
  30074. * Rebuilds the particle system
  30075. */
  30076. rebuild(): void;
  30077. private _releaseBuffers;
  30078. private _releaseVAOs;
  30079. /**
  30080. * Disposes the particle system and free the associated resources
  30081. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30082. */
  30083. dispose(disposeTexture?: boolean): void;
  30084. /**
  30085. * Clones the particle system.
  30086. * @param name The name of the cloned object
  30087. * @param newEmitter The new emitter to use
  30088. * @returns the cloned particle system
  30089. */
  30090. clone(name: string, newEmitter: any): GPUParticleSystem;
  30091. /**
  30092. * Serializes the particle system to a JSON object.
  30093. * @returns the JSON object
  30094. */
  30095. serialize(): any;
  30096. /**
  30097. * Parses a JSON object to create a GPU particle system.
  30098. * @param parsedParticleSystem The JSON object to parse
  30099. * @param scene The scene to create the particle system in
  30100. * @param rootUrl The root url to use to load external dependencies like texture
  30101. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  30102. * @returns the parsed GPU particle system
  30103. */
  30104. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  30105. }
  30106. }
  30107. declare module BABYLON {
  30108. /**
  30109. * Interface representing a particle system in Babylon.js.
  30110. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  30111. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  30112. */
  30113. interface IParticleSystem {
  30114. /**
  30115. * List of animations used by the particle system.
  30116. */
  30117. animations: Animation[];
  30118. /**
  30119. * The id of the Particle system.
  30120. */
  30121. id: string;
  30122. /**
  30123. * The name of the Particle system.
  30124. */
  30125. name: string;
  30126. /**
  30127. * The emitter represents the Mesh or position we are attaching the particle system to.
  30128. */
  30129. emitter: Nullable<AbstractMesh | Vector3>;
  30130. /**
  30131. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30132. */
  30133. isBillboardBased: boolean;
  30134. /**
  30135. * The rendering group used by the Particle system to chose when to render.
  30136. */
  30137. renderingGroupId: number;
  30138. /**
  30139. * The layer mask we are rendering the particles through.
  30140. */
  30141. layerMask: number;
  30142. /**
  30143. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30144. */
  30145. updateSpeed: number;
  30146. /**
  30147. * The amount of time the particle system is running (depends of the overall update speed).
  30148. */
  30149. targetStopDuration: number;
  30150. /**
  30151. * The texture used to render each particle. (this can be a spritesheet)
  30152. */
  30153. particleTexture: Nullable<Texture>;
  30154. /**
  30155. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  30156. */
  30157. blendMode: number;
  30158. /**
  30159. * Minimum life time of emitting particles.
  30160. */
  30161. minLifeTime: number;
  30162. /**
  30163. * Maximum life time of emitting particles.
  30164. */
  30165. maxLifeTime: number;
  30166. /**
  30167. * Minimum Size of emitting particles.
  30168. */
  30169. minSize: number;
  30170. /**
  30171. * Maximum Size of emitting particles.
  30172. */
  30173. maxSize: number;
  30174. /**
  30175. * Minimum scale of emitting particles on X axis.
  30176. */
  30177. minScaleX: number;
  30178. /**
  30179. * Maximum scale of emitting particles on X axis.
  30180. */
  30181. maxScaleX: number;
  30182. /**
  30183. * Minimum scale of emitting particles on Y axis.
  30184. */
  30185. minScaleY: number;
  30186. /**
  30187. * Maximum scale of emitting particles on Y axis.
  30188. */
  30189. maxScaleY: number;
  30190. /**
  30191. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  30192. */
  30193. color1: Color4;
  30194. /**
  30195. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  30196. */
  30197. color2: Color4;
  30198. /**
  30199. * Color the particle will have at the end of its lifetime.
  30200. */
  30201. colorDead: Color4;
  30202. /**
  30203. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  30204. */
  30205. emitRate: number;
  30206. /**
  30207. * You can use gravity if you want to give an orientation to your particles.
  30208. */
  30209. gravity: Vector3;
  30210. /**
  30211. * Minimum power of emitting particles.
  30212. */
  30213. minEmitPower: number;
  30214. /**
  30215. * Maximum power of emitting particles.
  30216. */
  30217. maxEmitPower: number;
  30218. /**
  30219. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30220. */
  30221. minAngularSpeed: number;
  30222. /**
  30223. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30224. */
  30225. maxAngularSpeed: number;
  30226. /**
  30227. * Gets or sets the minimal initial rotation in radians.
  30228. */
  30229. minInitialRotation: number;
  30230. /**
  30231. * Gets or sets the maximal initial rotation in radians.
  30232. */
  30233. maxInitialRotation: number;
  30234. /**
  30235. * The particle emitter type defines the emitter used by the particle system.
  30236. * It can be for example box, sphere, or cone...
  30237. */
  30238. particleEmitterType: Nullable<IParticleEmitterType>;
  30239. /**
  30240. * Defines the delay in milliseconds before starting the system (0 by default)
  30241. */
  30242. startDelay: number;
  30243. /**
  30244. * 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
  30245. */
  30246. preWarmCycles: number;
  30247. /**
  30248. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  30249. */
  30250. preWarmStepOffset: number;
  30251. /**
  30252. * 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)
  30253. */
  30254. spriteCellChangeSpeed: number;
  30255. /**
  30256. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30257. */
  30258. startSpriteCellID: number;
  30259. /**
  30260. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30261. */
  30262. endSpriteCellID: number;
  30263. /**
  30264. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30265. */
  30266. spriteCellWidth: number;
  30267. /**
  30268. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30269. */
  30270. spriteCellHeight: number;
  30271. /**
  30272. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30273. */
  30274. spriteRandomStartCell: boolean;
  30275. /**
  30276. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  30277. */
  30278. isAnimationSheetEnabled: boolean;
  30279. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30280. translationPivot: Vector2;
  30281. /**
  30282. * Gets or sets a texture used to add random noise to particle positions
  30283. */
  30284. noiseTexture: Nullable<BaseTexture>;
  30285. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30286. noiseStrength: Vector3;
  30287. /**
  30288. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30289. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30290. */
  30291. billboardMode: number;
  30292. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30293. limitVelocityDamping: number;
  30294. /**
  30295. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30296. */
  30297. beginAnimationOnStart: boolean;
  30298. /**
  30299. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30300. */
  30301. beginAnimationFrom: number;
  30302. /**
  30303. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30304. */
  30305. beginAnimationTo: number;
  30306. /**
  30307. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30308. */
  30309. beginAnimationLoop: boolean;
  30310. /**
  30311. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30312. */
  30313. disposeOnStop: boolean;
  30314. /**
  30315. * Gets the maximum number of particles active at the same time.
  30316. * @returns The max number of active particles.
  30317. */
  30318. getCapacity(): number;
  30319. /**
  30320. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30321. * @returns True if it has been started, otherwise false.
  30322. */
  30323. isStarted(): boolean;
  30324. /**
  30325. * Animates the particle system for this frame.
  30326. */
  30327. animate(): void;
  30328. /**
  30329. * Renders the particle system in its current state.
  30330. * @returns the current number of particles
  30331. */
  30332. render(): number;
  30333. /**
  30334. * Dispose the particle system and frees its associated resources.
  30335. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30336. */
  30337. dispose(disposeTexture?: boolean): void;
  30338. /**
  30339. * Clones the particle system.
  30340. * @param name The name of the cloned object
  30341. * @param newEmitter The new emitter to use
  30342. * @returns the cloned particle system
  30343. */
  30344. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  30345. /**
  30346. * Serializes the particle system to a JSON object.
  30347. * @returns the JSON object
  30348. */
  30349. serialize(): any;
  30350. /**
  30351. * Rebuild the particle system
  30352. */
  30353. rebuild(): void;
  30354. /**
  30355. * Starts the particle system and begins to emit
  30356. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  30357. */
  30358. start(delay?: number): void;
  30359. /**
  30360. * Stops the particle system.
  30361. */
  30362. stop(): void;
  30363. /**
  30364. * Remove all active particles
  30365. */
  30366. reset(): void;
  30367. /**
  30368. * Is this system ready to be used/rendered
  30369. * @return true if the system is ready
  30370. */
  30371. isReady(): boolean;
  30372. /**
  30373. * Adds a new color gradient
  30374. * @param gradient defines the gradient to use (between 0 and 1)
  30375. * @param color1 defines the color to affect to the specified gradient
  30376. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30377. * @returns the current particle system
  30378. */
  30379. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  30380. /**
  30381. * Remove a specific color gradient
  30382. * @param gradient defines the gradient to remove
  30383. * @returns the current particle system
  30384. */
  30385. removeColorGradient(gradient: number): IParticleSystem;
  30386. /**
  30387. * Adds a new size gradient
  30388. * @param gradient defines the gradient to use (between 0 and 1)
  30389. * @param factor defines the size factor to affect to the specified gradient
  30390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30391. * @returns the current particle system
  30392. */
  30393. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30394. /**
  30395. * Remove a specific size gradient
  30396. * @param gradient defines the gradient to remove
  30397. * @returns the current particle system
  30398. */
  30399. removeSizeGradient(gradient: number): IParticleSystem;
  30400. /**
  30401. * Gets the current list of color gradients.
  30402. * You must use addColorGradient and removeColorGradient to udpate this list
  30403. * @returns the list of color gradients
  30404. */
  30405. getColorGradients(): Nullable<Array<ColorGradient>>;
  30406. /**
  30407. * Gets the current list of size gradients.
  30408. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30409. * @returns the list of size gradients
  30410. */
  30411. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30412. /**
  30413. * Gets the current list of angular speed gradients.
  30414. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30415. * @returns the list of angular speed gradients
  30416. */
  30417. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30418. /**
  30419. * Adds a new angular speed gradient
  30420. * @param gradient defines the gradient to use (between 0 and 1)
  30421. * @param factor defines the angular speed to affect to the specified gradient
  30422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30423. * @returns the current particle system
  30424. */
  30425. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30426. /**
  30427. * Remove a specific angular speed gradient
  30428. * @param gradient defines the gradient to remove
  30429. * @returns the current particle system
  30430. */
  30431. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  30432. /**
  30433. * Gets the current list of velocity gradients.
  30434. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30435. * @returns the list of velocity gradients
  30436. */
  30437. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30438. /**
  30439. * Adds a new velocity gradient
  30440. * @param gradient defines the gradient to use (between 0 and 1)
  30441. * @param factor defines the velocity to affect to the specified gradient
  30442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30443. * @returns the current particle system
  30444. */
  30445. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30446. /**
  30447. * Remove a specific velocity gradient
  30448. * @param gradient defines the gradient to remove
  30449. * @returns the current particle system
  30450. */
  30451. removeVelocityGradient(gradient: number): IParticleSystem;
  30452. /**
  30453. * Gets the current list of limit velocity gradients.
  30454. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30455. * @returns the list of limit velocity gradients
  30456. */
  30457. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30458. /**
  30459. * Adds a new limit velocity gradient
  30460. * @param gradient defines the gradient to use (between 0 and 1)
  30461. * @param factor defines the limit velocity to affect to the specified gradient
  30462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30463. * @returns the current particle system
  30464. */
  30465. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30466. /**
  30467. * Remove a specific limit velocity gradient
  30468. * @param gradient defines the gradient to remove
  30469. * @returns the current particle system
  30470. */
  30471. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  30472. /**
  30473. * Adds a new drag gradient
  30474. * @param gradient defines the gradient to use (between 0 and 1)
  30475. * @param factor defines the drag to affect to the specified gradient
  30476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30477. * @returns the current particle system
  30478. */
  30479. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30480. /**
  30481. * Remove a specific drag gradient
  30482. * @param gradient defines the gradient to remove
  30483. * @returns the current particle system
  30484. */
  30485. removeDragGradient(gradient: number): IParticleSystem;
  30486. /**
  30487. * Gets the current list of drag gradients.
  30488. * You must use addDragGradient and removeDragGradient to udpate this list
  30489. * @returns the list of drag gradients
  30490. */
  30491. getDragGradients(): Nullable<Array<FactorGradient>>;
  30492. /**
  30493. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  30494. * @param gradient defines the gradient to use (between 0 and 1)
  30495. * @param factor defines the emit rate to affect to the specified gradient
  30496. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30497. * @returns the current particle system
  30498. */
  30499. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30500. /**
  30501. * Remove a specific emit rate gradient
  30502. * @param gradient defines the gradient to remove
  30503. * @returns the current particle system
  30504. */
  30505. removeEmitRateGradient(gradient: number): IParticleSystem;
  30506. /**
  30507. * Gets the current list of emit rate gradients.
  30508. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30509. * @returns the list of emit rate gradients
  30510. */
  30511. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30512. /**
  30513. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  30514. * @param gradient defines the gradient to use (between 0 and 1)
  30515. * @param factor defines the start size to affect to the specified gradient
  30516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30517. * @returns the current particle system
  30518. */
  30519. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30520. /**
  30521. * Remove a specific start size gradient
  30522. * @param gradient defines the gradient to remove
  30523. * @returns the current particle system
  30524. */
  30525. removeStartSizeGradient(gradient: number): IParticleSystem;
  30526. /**
  30527. * Gets the current list of start size gradients.
  30528. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30529. * @returns the list of start size gradients
  30530. */
  30531. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30532. /**
  30533. * Adds a new life time gradient
  30534. * @param gradient defines the gradient to use (between 0 and 1)
  30535. * @param factor defines the life time factor to affect to the specified gradient
  30536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30537. * @returns the current particle system
  30538. */
  30539. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30540. /**
  30541. * Remove a specific life time gradient
  30542. * @param gradient defines the gradient to remove
  30543. * @returns the current particle system
  30544. */
  30545. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30546. /**
  30547. * Gets the current list of life time gradients.
  30548. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30549. * @returns the list of life time gradients
  30550. */
  30551. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30552. /**
  30553. * Gets the current list of color gradients.
  30554. * You must use addColorGradient and removeColorGradient to udpate this list
  30555. * @returns the list of color gradients
  30556. */
  30557. getColorGradients(): Nullable<Array<ColorGradient>>;
  30558. /**
  30559. * Adds a new ramp gradient used to remap particle colors
  30560. * @param gradient defines the gradient to use (between 0 and 1)
  30561. * @param color defines the color to affect to the specified gradient
  30562. * @returns the current particle system
  30563. */
  30564. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30565. /**
  30566. * Gets the current list of ramp gradients.
  30567. * You must use addRampGradient and removeRampGradient to udpate this list
  30568. * @returns the list of ramp gradients
  30569. */
  30570. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30571. /** Gets or sets a boolean indicating that ramp gradients must be used
  30572. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30573. */
  30574. useRampGradients: boolean;
  30575. /**
  30576. * Adds a new color remap gradient
  30577. * @param gradient defines the gradient to use (between 0 and 1)
  30578. * @param min defines the color remap minimal range
  30579. * @param max defines the color remap maximal range
  30580. * @returns the current particle system
  30581. */
  30582. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30583. /**
  30584. * Gets the current list of color remap gradients.
  30585. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30586. * @returns the list of color remap gradients
  30587. */
  30588. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30589. /**
  30590. * Adds a new alpha remap gradient
  30591. * @param gradient defines the gradient to use (between 0 and 1)
  30592. * @param min defines the alpha remap minimal range
  30593. * @param max defines the alpha remap maximal range
  30594. * @returns the current particle system
  30595. */
  30596. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30597. /**
  30598. * Gets the current list of alpha remap gradients.
  30599. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30600. * @returns the list of alpha remap gradients
  30601. */
  30602. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30603. /**
  30604. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30605. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30606. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30607. * @returns the emitter
  30608. */
  30609. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30610. /**
  30611. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30612. * @param radius The radius of the hemisphere to emit from
  30613. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30614. * @returns the emitter
  30615. */
  30616. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  30617. /**
  30618. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30619. * @param radius The radius of the sphere to emit from
  30620. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30621. * @returns the emitter
  30622. */
  30623. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  30624. /**
  30625. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30626. * @param radius The radius of the sphere to emit from
  30627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30629. * @returns the emitter
  30630. */
  30631. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  30632. /**
  30633. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30634. * @param radius The radius of the emission cylinder
  30635. * @param height The height of the emission cylinder
  30636. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30637. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30638. * @returns the emitter
  30639. */
  30640. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  30641. /**
  30642. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30643. * @param radius The radius of the cylinder to emit from
  30644. * @param height The height of the emission cylinder
  30645. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30646. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30647. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30648. * @returns the emitter
  30649. */
  30650. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  30651. /**
  30652. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30653. * @param radius The radius of the cone to emit from
  30654. * @param angle The base angle of the cone
  30655. * @returns the emitter
  30656. */
  30657. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  30658. /**
  30659. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30660. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30661. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30662. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30663. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30664. * @returns the emitter
  30665. */
  30666. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30667. /**
  30668. * Get hosting scene
  30669. * @returns the scene
  30670. */
  30671. getScene(): Scene;
  30672. }
  30673. }
  30674. declare module BABYLON {
  30675. /**
  30676. * A particle represents one of the element emitted by a particle system.
  30677. * This is mainly define by its coordinates, direction, velocity and age.
  30678. */
  30679. class Particle {
  30680. /**
  30681. * The particle system the particle belongs to.
  30682. */
  30683. particleSystem: ParticleSystem;
  30684. private static _Count;
  30685. /**
  30686. * Unique ID of the particle
  30687. */
  30688. id: number;
  30689. /**
  30690. * The world position of the particle in the scene.
  30691. */
  30692. position: Vector3;
  30693. /**
  30694. * The world direction of the particle in the scene.
  30695. */
  30696. direction: Vector3;
  30697. /**
  30698. * The color of the particle.
  30699. */
  30700. color: Color4;
  30701. /**
  30702. * The color change of the particle per step.
  30703. */
  30704. colorStep: Color4;
  30705. /**
  30706. * Defines how long will the life of the particle be.
  30707. */
  30708. lifeTime: number;
  30709. /**
  30710. * The current age of the particle.
  30711. */
  30712. age: number;
  30713. /**
  30714. * The current size of the particle.
  30715. */
  30716. size: number;
  30717. /**
  30718. * The current scale of the particle.
  30719. */
  30720. scale: Vector2;
  30721. /**
  30722. * The current angle of the particle.
  30723. */
  30724. angle: number;
  30725. /**
  30726. * Defines how fast is the angle changing.
  30727. */
  30728. angularSpeed: number;
  30729. /**
  30730. * Defines the cell index used by the particle to be rendered from a sprite.
  30731. */
  30732. cellIndex: number;
  30733. /**
  30734. * The information required to support color remapping
  30735. */
  30736. remapData: Vector4;
  30737. /** @hidden */
  30738. _randomCellOffset?: number;
  30739. /** @hidden */
  30740. _initialDirection: Nullable<Vector3>;
  30741. /** @hidden */
  30742. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  30743. /** @hidden */
  30744. _initialStartSpriteCellID: number;
  30745. /** @hidden */
  30746. _initialEndSpriteCellID: number;
  30747. /** @hidden */
  30748. _currentColorGradient: Nullable<ColorGradient>;
  30749. /** @hidden */
  30750. _currentColor1: Color4;
  30751. /** @hidden */
  30752. _currentColor2: Color4;
  30753. /** @hidden */
  30754. _currentSizeGradient: Nullable<FactorGradient>;
  30755. /** @hidden */
  30756. _currentSize1: number;
  30757. /** @hidden */
  30758. _currentSize2: number;
  30759. /** @hidden */
  30760. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  30761. /** @hidden */
  30762. _currentAngularSpeed1: number;
  30763. /** @hidden */
  30764. _currentAngularSpeed2: number;
  30765. /** @hidden */
  30766. _currentVelocityGradient: Nullable<FactorGradient>;
  30767. /** @hidden */
  30768. _currentVelocity1: number;
  30769. /** @hidden */
  30770. _currentVelocity2: number;
  30771. /** @hidden */
  30772. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  30773. /** @hidden */
  30774. _currentLimitVelocity1: number;
  30775. /** @hidden */
  30776. _currentLimitVelocity2: number;
  30777. /** @hidden */
  30778. _currentDragGradient: Nullable<FactorGradient>;
  30779. /** @hidden */
  30780. _currentDrag1: number;
  30781. /** @hidden */
  30782. _currentDrag2: number;
  30783. /** @hidden */
  30784. _randomNoiseCoordinates1: Vector3;
  30785. /** @hidden */
  30786. _randomNoiseCoordinates2: Vector3;
  30787. /**
  30788. * Creates a new instance Particle
  30789. * @param particleSystem the particle system the particle belongs to
  30790. */
  30791. constructor(
  30792. /**
  30793. * The particle system the particle belongs to.
  30794. */
  30795. particleSystem: ParticleSystem);
  30796. private updateCellInfoFromSystem;
  30797. /**
  30798. * Defines how the sprite cell index is updated for the particle
  30799. */
  30800. updateCellIndex(): void;
  30801. /** @hidden */
  30802. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  30803. /** @hidden */
  30804. _inheritParticleInfoToSubEmitters(): void;
  30805. /** @hidden */
  30806. _reset(): void;
  30807. /**
  30808. * Copy the properties of particle to another one.
  30809. * @param other the particle to copy the information to.
  30810. */
  30811. copyTo(other: Particle): void;
  30812. }
  30813. }
  30814. declare module BABYLON {
  30815. /**
  30816. * This class is made for on one-liner static method to help creating particle system set.
  30817. */
  30818. class ParticleHelper {
  30819. /**
  30820. * Gets or sets base Assets URL
  30821. */
  30822. static BaseAssetsUrl: string;
  30823. /**
  30824. * Create a default particle system that you can tweak
  30825. * @param emitter defines the emitter to use
  30826. * @param capacity defines the system capacity (default is 500 particles)
  30827. * @param scene defines the hosting scene
  30828. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  30829. * @returns the new Particle system
  30830. */
  30831. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  30832. /**
  30833. * This is the main static method (one-liner) of this helper to create different particle systems
  30834. * @param type This string represents the type to the particle system to create
  30835. * @param scene The scene where the particle system should live
  30836. * @param gpu If the system will use gpu
  30837. * @returns the ParticleSystemSet created
  30838. */
  30839. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  30840. /**
  30841. * Static function used to export a particle system to a ParticleSystemSet variable.
  30842. * Please note that the emitter shape is not exported
  30843. * @param systems defines the particle systems to export
  30844. * @returns the created particle system set
  30845. */
  30846. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  30847. }
  30848. }
  30849. declare module BABYLON {
  30850. /**
  30851. * This represents a particle system in Babylon.
  30852. * 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.
  30853. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30854. * @example https://doc.babylonjs.com/babylon101/particles
  30855. */
  30856. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  30857. /**
  30858. * Billboard mode will only apply to Y axis
  30859. */
  30860. static readonly BILLBOARDMODE_Y: number;
  30861. /**
  30862. * Billboard mode will apply to all axes
  30863. */
  30864. static readonly BILLBOARDMODE_ALL: number;
  30865. /**
  30866. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  30867. */
  30868. static readonly BILLBOARDMODE_STRETCHED: number;
  30869. /**
  30870. * This function can be defined to provide custom update for active particles.
  30871. * This function will be called instead of regular update (age, position, color, etc.).
  30872. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  30873. */
  30874. updateFunction: (particles: Particle[]) => void;
  30875. private _emitterWorldMatrix;
  30876. /**
  30877. * This function can be defined to specify initial direction for every new particle.
  30878. * It by default use the emitterType defined function
  30879. */
  30880. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  30881. /**
  30882. * This function can be defined to specify initial position for every new particle.
  30883. * It by default use the emitterType defined function
  30884. */
  30885. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  30886. /**
  30887. * @hidden
  30888. */
  30889. _inheritedVelocityOffset: Vector3;
  30890. /**
  30891. * An event triggered when the system is disposed
  30892. */
  30893. onDisposeObservable: Observable<ParticleSystem>;
  30894. private _onDisposeObserver;
  30895. /**
  30896. * Sets a callback that will be triggered when the system is disposed
  30897. */
  30898. onDispose: () => void;
  30899. private _particles;
  30900. private _epsilon;
  30901. private _capacity;
  30902. private _stockParticles;
  30903. private _newPartsExcess;
  30904. private _vertexData;
  30905. private _vertexBuffer;
  30906. private _vertexBuffers;
  30907. private _spriteBuffer;
  30908. private _indexBuffer;
  30909. private _effect;
  30910. private _customEffect;
  30911. private _cachedDefines;
  30912. private _scaledColorStep;
  30913. private _colorDiff;
  30914. private _scaledDirection;
  30915. private _scaledGravity;
  30916. private _currentRenderId;
  30917. private _alive;
  30918. private _useInstancing;
  30919. private _started;
  30920. private _stopped;
  30921. private _actualFrame;
  30922. private _scaledUpdateSpeed;
  30923. private _vertexBufferSize;
  30924. /** @hidden */
  30925. _currentEmitRateGradient: Nullable<FactorGradient>;
  30926. /** @hidden */
  30927. _currentEmitRate1: number;
  30928. /** @hidden */
  30929. _currentEmitRate2: number;
  30930. /** @hidden */
  30931. _currentStartSizeGradient: Nullable<FactorGradient>;
  30932. /** @hidden */
  30933. _currentStartSize1: number;
  30934. /** @hidden */
  30935. _currentStartSize2: number;
  30936. private readonly _rawTextureWidth;
  30937. private _rampGradientsTexture;
  30938. private _useRampGradients;
  30939. /** Gets or sets a boolean indicating that ramp gradients must be used
  30940. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30941. */
  30942. useRampGradients: boolean;
  30943. /**
  30944. * 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.
  30945. * 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: [])
  30946. */
  30947. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  30948. private _subEmitters;
  30949. /**
  30950. * @hidden
  30951. * If the particle systems emitter should be disposed when the particle system is disposed
  30952. */
  30953. _disposeEmitterOnDispose: boolean;
  30954. /**
  30955. * The current active Sub-systems, this property is used by the root particle system only.
  30956. */
  30957. activeSubSystems: Array<ParticleSystem>;
  30958. private _rootParticleSystem;
  30959. /**
  30960. * Gets the current list of active particles
  30961. */
  30962. readonly particles: Particle[];
  30963. /**
  30964. * Returns the string "ParticleSystem"
  30965. * @returns a string containing the class name
  30966. */
  30967. getClassName(): string;
  30968. /**
  30969. * Instantiates a particle system.
  30970. * 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.
  30971. * @param name The name of the particle system
  30972. * @param capacity The max number of particles alive at the same time
  30973. * @param scene The scene the particle system belongs to
  30974. * @param customEffect a custom effect used to change the way particles are rendered by default
  30975. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30976. * @param epsilon Offset used to render the particles
  30977. */
  30978. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  30979. private _addFactorGradient;
  30980. private _removeFactorGradient;
  30981. /**
  30982. * Adds a new life time gradient
  30983. * @param gradient defines the gradient to use (between 0 and 1)
  30984. * @param factor defines the life time factor to affect to the specified gradient
  30985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30986. * @returns the current particle system
  30987. */
  30988. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30989. /**
  30990. * Remove a specific life time gradient
  30991. * @param gradient defines the gradient to remove
  30992. * @returns the current particle system
  30993. */
  30994. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30995. /**
  30996. * Adds a new size gradient
  30997. * @param gradient defines the gradient to use (between 0 and 1)
  30998. * @param factor defines the size factor to affect to the specified gradient
  30999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31000. * @returns the current particle system
  31001. */
  31002. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31003. /**
  31004. * Remove a specific size gradient
  31005. * @param gradient defines the gradient to remove
  31006. * @returns the current particle system
  31007. */
  31008. removeSizeGradient(gradient: number): IParticleSystem;
  31009. /**
  31010. * Adds a new color remap gradient
  31011. * @param gradient defines the gradient to use (between 0 and 1)
  31012. * @param min defines the color remap minimal range
  31013. * @param max defines the color remap maximal range
  31014. * @returns the current particle system
  31015. */
  31016. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31017. /**
  31018. * Remove a specific color remap gradient
  31019. * @param gradient defines the gradient to remove
  31020. * @returns the current particle system
  31021. */
  31022. removeColorRemapGradient(gradient: number): IParticleSystem;
  31023. /**
  31024. * Adds a new alpha remap gradient
  31025. * @param gradient defines the gradient to use (between 0 and 1)
  31026. * @param min defines the alpha remap minimal range
  31027. * @param max defines the alpha remap maximal range
  31028. * @returns the current particle system
  31029. */
  31030. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31031. /**
  31032. * Remove a specific alpha remap gradient
  31033. * @param gradient defines the gradient to remove
  31034. * @returns the current particle system
  31035. */
  31036. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31037. /**
  31038. * Adds a new angular speed gradient
  31039. * @param gradient defines the gradient to use (between 0 and 1)
  31040. * @param factor defines the angular speed to affect to the specified gradient
  31041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31042. * @returns the current particle system
  31043. */
  31044. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31045. /**
  31046. * Remove a specific angular speed gradient
  31047. * @param gradient defines the gradient to remove
  31048. * @returns the current particle system
  31049. */
  31050. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31051. /**
  31052. * Adds a new velocity gradient
  31053. * @param gradient defines the gradient to use (between 0 and 1)
  31054. * @param factor defines the velocity to affect to the specified gradient
  31055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31056. * @returns the current particle system
  31057. */
  31058. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31059. /**
  31060. * Remove a specific velocity gradient
  31061. * @param gradient defines the gradient to remove
  31062. * @returns the current particle system
  31063. */
  31064. removeVelocityGradient(gradient: number): IParticleSystem;
  31065. /**
  31066. * Adds a new limit velocity gradient
  31067. * @param gradient defines the gradient to use (between 0 and 1)
  31068. * @param factor defines the limit velocity value to affect to the specified gradient
  31069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31070. * @returns the current particle system
  31071. */
  31072. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31073. /**
  31074. * Remove a specific limit velocity gradient
  31075. * @param gradient defines the gradient to remove
  31076. * @returns the current particle system
  31077. */
  31078. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31079. /**
  31080. * Adds a new drag gradient
  31081. * @param gradient defines the gradient to use (between 0 and 1)
  31082. * @param factor defines the drag value to affect to the specified gradient
  31083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31084. * @returns the current particle system
  31085. */
  31086. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31087. /**
  31088. * Remove a specific drag gradient
  31089. * @param gradient defines the gradient to remove
  31090. * @returns the current particle system
  31091. */
  31092. removeDragGradient(gradient: number): IParticleSystem;
  31093. /**
  31094. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31095. * @param gradient defines the gradient to use (between 0 and 1)
  31096. * @param factor defines the emit rate value to affect to the specified gradient
  31097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31098. * @returns the current particle system
  31099. */
  31100. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31101. /**
  31102. * Remove a specific emit rate gradient
  31103. * @param gradient defines the gradient to remove
  31104. * @returns the current particle system
  31105. */
  31106. removeEmitRateGradient(gradient: number): IParticleSystem;
  31107. /**
  31108. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31109. * @param gradient defines the gradient to use (between 0 and 1)
  31110. * @param factor defines the start size value to affect to the specified gradient
  31111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31112. * @returns the current particle system
  31113. */
  31114. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31115. /**
  31116. * Remove a specific start size gradient
  31117. * @param gradient defines the gradient to remove
  31118. * @returns the current particle system
  31119. */
  31120. removeStartSizeGradient(gradient: number): IParticleSystem;
  31121. private _createRampGradientTexture;
  31122. /**
  31123. * Gets the current list of ramp gradients.
  31124. * You must use addRampGradient and removeRampGradient to udpate this list
  31125. * @returns the list of ramp gradients
  31126. */
  31127. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31128. /**
  31129. * Adds a new ramp gradient used to remap particle colors
  31130. * @param gradient defines the gradient to use (between 0 and 1)
  31131. * @param color defines the color to affect to the specified gradient
  31132. * @returns the current particle system
  31133. */
  31134. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  31135. /**
  31136. * Remove a specific ramp gradient
  31137. * @param gradient defines the gradient to remove
  31138. * @returns the current particle system
  31139. */
  31140. removeRampGradient(gradient: number): ParticleSystem;
  31141. /**
  31142. * Adds a new color gradient
  31143. * @param gradient defines the gradient to use (between 0 and 1)
  31144. * @param color1 defines the color to affect to the specified gradient
  31145. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31146. * @returns this particle system
  31147. */
  31148. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31149. /**
  31150. * Remove a specific color gradient
  31151. * @param gradient defines the gradient to remove
  31152. * @returns this particle system
  31153. */
  31154. removeColorGradient(gradient: number): IParticleSystem;
  31155. private _fetchR;
  31156. protected _reset(): void;
  31157. private _resetEffect;
  31158. private _createVertexBuffers;
  31159. private _createIndexBuffer;
  31160. /**
  31161. * Gets the maximum number of particles active at the same time.
  31162. * @returns The max number of active particles.
  31163. */
  31164. getCapacity(): number;
  31165. /**
  31166. * Gets whether there are still active particles in the system.
  31167. * @returns True if it is alive, otherwise false.
  31168. */
  31169. isAlive(): boolean;
  31170. /**
  31171. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31172. * @returns True if it has been started, otherwise false.
  31173. */
  31174. isStarted(): boolean;
  31175. private _prepareSubEmitterInternalArray;
  31176. /**
  31177. * Starts the particle system and begins to emit
  31178. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  31179. */
  31180. start(delay?: number): void;
  31181. /**
  31182. * Stops the particle system.
  31183. * @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.
  31184. */
  31185. stop(stopSubEmitters?: boolean): void;
  31186. /**
  31187. * Remove all active particles
  31188. */
  31189. reset(): void;
  31190. /**
  31191. * @hidden (for internal use only)
  31192. */
  31193. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  31194. /**
  31195. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  31196. * Its lifetime will start back at 0.
  31197. */
  31198. recycleParticle: (particle: Particle) => void;
  31199. private _stopSubEmitters;
  31200. private _createParticle;
  31201. private _removeFromRoot;
  31202. private _emitFromParticle;
  31203. private _update;
  31204. /** @hidden */
  31205. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  31206. /** @hidden */
  31207. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  31208. /** @hidden */
  31209. private _getEffect;
  31210. /**
  31211. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31212. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  31213. */
  31214. animate(preWarmOnly?: boolean): void;
  31215. private _appendParticleVertices;
  31216. /**
  31217. * Rebuilds the particle system.
  31218. */
  31219. rebuild(): void;
  31220. /**
  31221. * Is this system ready to be used/rendered
  31222. * @return true if the system is ready
  31223. */
  31224. isReady(): boolean;
  31225. private _render;
  31226. /**
  31227. * Renders the particle system in its current state.
  31228. * @returns the current number of particles
  31229. */
  31230. render(): number;
  31231. /**
  31232. * Disposes the particle system and free the associated resources
  31233. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31234. */
  31235. dispose(disposeTexture?: boolean): void;
  31236. /**
  31237. * Clones the particle system.
  31238. * @param name The name of the cloned object
  31239. * @param newEmitter The new emitter to use
  31240. * @returns the cloned particle system
  31241. */
  31242. clone(name: string, newEmitter: any): ParticleSystem;
  31243. /**
  31244. * Serializes the particle system to a JSON object.
  31245. * @returns the JSON object
  31246. */
  31247. serialize(): any;
  31248. /** @hidden */
  31249. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  31250. /** @hidden */
  31251. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  31252. /**
  31253. * Parses a JSON object to create a particle system.
  31254. * @param parsedParticleSystem The JSON object to parse
  31255. * @param scene The scene to create the particle system in
  31256. * @param rootUrl The root url to use to load external dependencies like texture
  31257. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31258. * @returns the Parsed particle system
  31259. */
  31260. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  31261. }
  31262. }
  31263. declare module BABYLON {
  31264. interface Engine {
  31265. /**
  31266. * Create an effect to use with particle systems.
  31267. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  31268. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  31269. * @param uniformsNames defines a list of attribute names
  31270. * @param samplers defines an array of string used to represent textures
  31271. * @param defines defines the string containing the defines to use to compile the shaders
  31272. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31273. * @param onCompiled defines a function to call when the effect creation is successful
  31274. * @param onError defines a function to call when the effect creation has failed
  31275. * @returns the new Effect
  31276. */
  31277. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  31278. }
  31279. interface Mesh {
  31280. /**
  31281. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  31282. * @returns an array of IParticleSystem
  31283. */
  31284. getEmittedParticleSystems(): IParticleSystem[];
  31285. /**
  31286. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  31287. * @returns an array of IParticleSystem
  31288. */
  31289. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  31290. }
  31291. }
  31292. declare module BABYLON {
  31293. /**
  31294. * Represents a set of particle systems working together to create a specific effect
  31295. */
  31296. class ParticleSystemSet implements IDisposable {
  31297. private _emitterCreationOptions;
  31298. private _emitterNode;
  31299. /**
  31300. * Gets the particle system list
  31301. */
  31302. systems: IParticleSystem[];
  31303. /**
  31304. * Gets the emitter node used with this set
  31305. */
  31306. readonly emitterNode: Nullable<TransformNode>;
  31307. /**
  31308. * Creates a new emitter mesh as a sphere
  31309. * @param options defines the options used to create the sphere
  31310. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  31311. * @param scene defines the hosting scene
  31312. */
  31313. setEmitterAsSphere(options: {
  31314. diameter: number;
  31315. segments: number;
  31316. color: Color3;
  31317. }, renderingGroupId: number, scene: Scene): void;
  31318. /**
  31319. * Starts all particle systems of the set
  31320. * @param emitter defines an optional mesh to use as emitter for the particle systems
  31321. */
  31322. start(emitter?: AbstractMesh): void;
  31323. /**
  31324. * Release all associated resources
  31325. */
  31326. dispose(): void;
  31327. /**
  31328. * Serialize the set into a JSON compatible object
  31329. * @returns a JSON compatible representation of the set
  31330. */
  31331. serialize(): any;
  31332. /**
  31333. * Parse a new ParticleSystemSet from a serialized source
  31334. * @param data defines a JSON compatible representation of the set
  31335. * @param scene defines the hosting scene
  31336. * @param gpu defines if we want GPU particles or CPU particles
  31337. * @returns a new ParticleSystemSet
  31338. */
  31339. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  31340. }
  31341. }
  31342. declare module BABYLON {
  31343. /**
  31344. * Represents one particle of a solid particle system.
  31345. */
  31346. class SolidParticle {
  31347. /**
  31348. * particle global index
  31349. */
  31350. idx: number;
  31351. /**
  31352. * The color of the particle
  31353. */
  31354. color: Nullable<Color4>;
  31355. /**
  31356. * The world space position of the particle.
  31357. */
  31358. position: Vector3;
  31359. /**
  31360. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31361. */
  31362. rotation: Vector3;
  31363. /**
  31364. * The world space rotation quaternion of the particle.
  31365. */
  31366. rotationQuaternion: Nullable<Quaternion>;
  31367. /**
  31368. * The scaling of the particle.
  31369. */
  31370. scaling: Vector3;
  31371. /**
  31372. * The uvs of the particle.
  31373. */
  31374. uvs: Vector4;
  31375. /**
  31376. * The current speed of the particle.
  31377. */
  31378. velocity: Vector3;
  31379. /**
  31380. * The pivot point in the particle local space.
  31381. */
  31382. pivot: Vector3;
  31383. /**
  31384. * Must the particle be translated from its pivot point in its local space ?
  31385. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31386. * Default : false
  31387. */
  31388. translateFromPivot: boolean;
  31389. /**
  31390. * Is the particle active or not ?
  31391. */
  31392. alive: boolean;
  31393. /**
  31394. * Is the particle visible or not ?
  31395. */
  31396. isVisible: boolean;
  31397. /**
  31398. * Index of this particle in the global "positions" array (Internal use)
  31399. * @hidden
  31400. */
  31401. _pos: number;
  31402. /**
  31403. * @hidden Index of this particle in the global "indices" array (Internal use)
  31404. */
  31405. _ind: number;
  31406. /**
  31407. * @hidden ModelShape of this particle (Internal use)
  31408. */
  31409. _model: ModelShape;
  31410. /**
  31411. * ModelShape id of this particle
  31412. */
  31413. shapeId: number;
  31414. /**
  31415. * Index of the particle in its shape id (Internal use)
  31416. */
  31417. idxInShape: number;
  31418. /**
  31419. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31420. */
  31421. _modelBoundingInfo: BoundingInfo;
  31422. /**
  31423. * @hidden Particle BoundingInfo object (Internal use)
  31424. */
  31425. _boundingInfo: BoundingInfo;
  31426. /**
  31427. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31428. */
  31429. _sps: SolidParticleSystem;
  31430. /**
  31431. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31432. */
  31433. _stillInvisible: boolean;
  31434. /**
  31435. * @hidden Last computed particle rotation matrix
  31436. */
  31437. _rotationMatrix: number[];
  31438. /**
  31439. * Parent particle Id, if any.
  31440. * Default null.
  31441. */
  31442. parentId: Nullable<number>;
  31443. /**
  31444. * @hidden Internal global position in the SPS.
  31445. */
  31446. _globalPosition: Vector3;
  31447. /**
  31448. * Creates a Solid Particle object.
  31449. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31450. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  31451. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31452. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31453. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31454. * @param shapeId (integer) is the model shape identifier in the SPS.
  31455. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31456. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31457. */
  31458. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  31459. /**
  31460. * Legacy support, changed scale to scaling
  31461. */
  31462. /**
  31463. * Legacy support, changed scale to scaling
  31464. */
  31465. scale: Vector3;
  31466. /**
  31467. * Legacy support, changed quaternion to rotationQuaternion
  31468. */
  31469. /**
  31470. * Legacy support, changed quaternion to rotationQuaternion
  31471. */
  31472. quaternion: Nullable<Quaternion>;
  31473. /**
  31474. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31475. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31476. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31477. * @returns true if it intersects
  31478. */
  31479. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31480. }
  31481. /**
  31482. * Represents the shape of the model used by one particle of a solid particle system.
  31483. * SPS internal tool, don't use it manually.
  31484. */
  31485. class ModelShape {
  31486. /**
  31487. * The shape id
  31488. * @hidden
  31489. */
  31490. shapeID: number;
  31491. /**
  31492. * flat array of model positions (internal use)
  31493. * @hidden
  31494. */
  31495. _shape: Vector3[];
  31496. /**
  31497. * flat array of model UVs (internal use)
  31498. * @hidden
  31499. */
  31500. _shapeUV: number[];
  31501. /**
  31502. * length of the shape in the model indices array (internal use)
  31503. * @hidden
  31504. */
  31505. _indicesLength: number;
  31506. /**
  31507. * Custom position function (internal use)
  31508. * @hidden
  31509. */
  31510. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31511. /**
  31512. * Custom vertex function (internal use)
  31513. * @hidden
  31514. */
  31515. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31516. /**
  31517. * 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.
  31518. * SPS internal tool, don't use it manually.
  31519. * @hidden
  31520. */
  31521. 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>);
  31522. }
  31523. /**
  31524. * Represents a Depth Sorted Particle in the solid particle system.
  31525. */
  31526. class DepthSortedParticle {
  31527. /**
  31528. * Index of the particle in the "indices" array
  31529. */
  31530. ind: number;
  31531. /**
  31532. * Length of the particle shape in the "indices" array
  31533. */
  31534. indicesLength: number;
  31535. /**
  31536. * Squared distance from the particle to the camera
  31537. */
  31538. sqDistance: number;
  31539. }
  31540. }
  31541. declare module BABYLON {
  31542. /**
  31543. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31544. *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.
  31545. * The SPS is also a particle system. It provides some methods to manage the particles.
  31546. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31547. *
  31548. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  31549. */
  31550. class SolidParticleSystem implements IDisposable {
  31551. /**
  31552. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31553. * Example : var p = SPS.particles[i];
  31554. */
  31555. particles: SolidParticle[];
  31556. /**
  31557. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31558. */
  31559. nbParticles: number;
  31560. /**
  31561. * If the particles must ever face the camera (default false). Useful for planar particles.
  31562. */
  31563. billboard: boolean;
  31564. /**
  31565. * Recompute normals when adding a shape
  31566. */
  31567. recomputeNormals: boolean;
  31568. /**
  31569. * This a counter ofr your own usage. It's not set by any SPS functions.
  31570. */
  31571. counter: number;
  31572. /**
  31573. * The SPS name. This name is also given to the underlying mesh.
  31574. */
  31575. name: string;
  31576. /**
  31577. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31578. */
  31579. mesh: Mesh;
  31580. /**
  31581. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31582. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  31583. */
  31584. vars: any;
  31585. /**
  31586. * This array is populated when the SPS is set as 'pickable'.
  31587. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31588. * Each element of this array is an object `{idx: int, faceId: int}`.
  31589. * `idx` is the picked particle index in the `SPS.particles` array
  31590. * `faceId` is the picked face index counted within this particle.
  31591. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  31592. */
  31593. pickedParticles: {
  31594. idx: number;
  31595. faceId: number;
  31596. }[];
  31597. /**
  31598. * This array is populated when `enableDepthSort` is set to true.
  31599. * Each element of this array is an instance of the class DepthSortedParticle.
  31600. */
  31601. depthSortedParticles: DepthSortedParticle[];
  31602. /**
  31603. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31604. * @hidden
  31605. */
  31606. _bSphereOnly: boolean;
  31607. /**
  31608. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31609. * @hidden
  31610. */
  31611. _bSphereRadiusFactor: number;
  31612. private _scene;
  31613. private _positions;
  31614. private _indices;
  31615. private _normals;
  31616. private _colors;
  31617. private _uvs;
  31618. private _indices32;
  31619. private _positions32;
  31620. private _normals32;
  31621. private _fixedNormal32;
  31622. private _colors32;
  31623. private _uvs32;
  31624. private _index;
  31625. private _updatable;
  31626. private _pickable;
  31627. private _isVisibilityBoxLocked;
  31628. private _alwaysVisible;
  31629. private _depthSort;
  31630. private _shapeCounter;
  31631. private _copy;
  31632. private _shape;
  31633. private _shapeUV;
  31634. private _color;
  31635. private _computeParticleColor;
  31636. private _computeParticleTexture;
  31637. private _computeParticleRotation;
  31638. private _computeParticleVertex;
  31639. private _computeBoundingBox;
  31640. private _depthSortParticles;
  31641. private _cam_axisZ;
  31642. private _cam_axisY;
  31643. private _cam_axisX;
  31644. private _axisZ;
  31645. private _camera;
  31646. private _particle;
  31647. private _camDir;
  31648. private _camInvertedPosition;
  31649. private _rotMatrix;
  31650. private _invertMatrix;
  31651. private _rotated;
  31652. private _quaternion;
  31653. private _vertex;
  31654. private _normal;
  31655. private _yaw;
  31656. private _pitch;
  31657. private _roll;
  31658. private _halfroll;
  31659. private _halfpitch;
  31660. private _halfyaw;
  31661. private _sinRoll;
  31662. private _cosRoll;
  31663. private _sinPitch;
  31664. private _cosPitch;
  31665. private _sinYaw;
  31666. private _cosYaw;
  31667. private _mustUnrotateFixedNormals;
  31668. private _minimum;
  31669. private _maximum;
  31670. private _minBbox;
  31671. private _maxBbox;
  31672. private _particlesIntersect;
  31673. private _depthSortFunction;
  31674. private _needs32Bits;
  31675. private _pivotBackTranslation;
  31676. private _scaledPivot;
  31677. private _particleHasParent;
  31678. private _parent;
  31679. /**
  31680. * Creates a SPS (Solid Particle System) object.
  31681. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31682. * @param scene (Scene) is the scene in which the SPS is added.
  31683. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31684. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31685. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31686. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31687. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31688. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31689. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31690. */
  31691. constructor(name: string, scene: Scene, options?: {
  31692. updatable?: boolean;
  31693. isPickable?: boolean;
  31694. enableDepthSort?: boolean;
  31695. particleIntersection?: boolean;
  31696. boundingSphereOnly?: boolean;
  31697. bSphereRadiusFactor?: number;
  31698. });
  31699. /**
  31700. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31701. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31702. * @returns the created mesh
  31703. */
  31704. buildMesh(): Mesh;
  31705. /**
  31706. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31707. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31708. * Thus the particles generated from `digest()` have their property `position` set yet.
  31709. * @param mesh ( Mesh ) is the mesh to be digested
  31710. * @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
  31711. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31712. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31713. * @returns the current SPS
  31714. */
  31715. digest(mesh: Mesh, options?: {
  31716. facetNb?: number;
  31717. number?: number;
  31718. delta?: number;
  31719. }): SolidParticleSystem;
  31720. private _unrotateFixedNormals;
  31721. private _resetCopy;
  31722. private _meshBuilder;
  31723. private _posToShape;
  31724. private _uvsToShapeUV;
  31725. private _addParticle;
  31726. /**
  31727. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31728. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  31729. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31730. * @param nb (positive integer) the number of particles to be created from this model
  31731. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31732. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31733. * @returns the number of shapes in the system
  31734. */
  31735. addShape(mesh: Mesh, nb: number, options?: {
  31736. positionFunction?: any;
  31737. vertexFunction?: any;
  31738. }): number;
  31739. private _rebuildParticle;
  31740. /**
  31741. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31742. * @returns the SPS.
  31743. */
  31744. rebuildMesh(): SolidParticleSystem;
  31745. /**
  31746. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31747. * This method calls `updateParticle()` for each particle of the SPS.
  31748. * For an animated SPS, it is usually called within the render loop.
  31749. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31750. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31751. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31752. * @returns the SPS.
  31753. */
  31754. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31755. private _quaternionRotationYPR;
  31756. private _quaternionToRotationMatrix;
  31757. /**
  31758. * Disposes the SPS.
  31759. */
  31760. dispose(): void;
  31761. /**
  31762. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31763. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31764. * @returns the SPS.
  31765. */
  31766. refreshVisibleSize(): SolidParticleSystem;
  31767. /**
  31768. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31769. * @param size the size (float) of the visibility box
  31770. * note : this doesn't lock the SPS mesh bounding box.
  31771. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31772. */
  31773. setVisibilityBox(size: number): void;
  31774. /**
  31775. * Gets whether the SPS as always visible or not
  31776. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31777. */
  31778. /**
  31779. * Sets the SPS as always visible or not
  31780. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31781. */
  31782. isAlwaysVisible: boolean;
  31783. /**
  31784. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31785. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31786. */
  31787. /**
  31788. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31789. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31790. */
  31791. isVisibilityBoxLocked: boolean;
  31792. /**
  31793. * Tells to `setParticles()` to compute the particle rotations or not.
  31794. * Default value : true. The SPS is faster when it's set to false.
  31795. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31796. */
  31797. /**
  31798. * Gets if `setParticles()` computes the particle rotations or not.
  31799. * Default value : true. The SPS is faster when it's set to false.
  31800. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31801. */
  31802. computeParticleRotation: boolean;
  31803. /**
  31804. * Tells to `setParticles()` to compute the particle colors or not.
  31805. * Default value : true. The SPS is faster when it's set to false.
  31806. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31807. */
  31808. /**
  31809. * Gets if `setParticles()` computes the particle colors or not.
  31810. * Default value : true. The SPS is faster when it's set to false.
  31811. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31812. */
  31813. computeParticleColor: boolean;
  31814. /**
  31815. * Gets if `setParticles()` computes the particle textures or not.
  31816. * Default value : true. The SPS is faster when it's set to false.
  31817. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31818. */
  31819. computeParticleTexture: boolean;
  31820. /**
  31821. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31822. * Default value : false. The SPS is faster when it's set to false.
  31823. * Note : the particle custom vertex positions aren't stored values.
  31824. */
  31825. /**
  31826. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31827. * Default value : false. The SPS is faster when it's set to false.
  31828. * Note : the particle custom vertex positions aren't stored values.
  31829. */
  31830. computeParticleVertex: boolean;
  31831. /**
  31832. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31833. */
  31834. /**
  31835. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31836. */
  31837. computeBoundingBox: boolean;
  31838. /**
  31839. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31840. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31841. * Default : `true`
  31842. */
  31843. /**
  31844. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31845. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31846. * Default : `true`
  31847. */
  31848. depthSortParticles: boolean;
  31849. /**
  31850. * This function does nothing. It may be overwritten to set all the particle first values.
  31851. * The SPS doesn't call this function, you may have to call it by your own.
  31852. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  31853. */
  31854. initParticles(): void;
  31855. /**
  31856. * This function does nothing. It may be overwritten to recycle a particle.
  31857. * The SPS doesn't call this function, you may have to call it by your own.
  31858. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  31859. * @param particle The particle to recycle
  31860. * @returns the recycled particle
  31861. */
  31862. recycleParticle(particle: SolidParticle): SolidParticle;
  31863. /**
  31864. * Updates a particle : this function should be overwritten by the user.
  31865. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31866. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  31867. * @example : just set a particle position or velocity and recycle conditions
  31868. * @param particle The particle to update
  31869. * @returns the updated particle
  31870. */
  31871. updateParticle(particle: SolidParticle): SolidParticle;
  31872. /**
  31873. * Updates a vertex of a particle : it can be overwritten by the user.
  31874. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31875. * @param particle the current particle
  31876. * @param vertex the current index of the current particle
  31877. * @param pt the index of the current vertex in the particle shape
  31878. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  31879. * @example : just set a vertex particle position
  31880. * @returns the updated vertex
  31881. */
  31882. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  31883. /**
  31884. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31885. * This does nothing and may be overwritten by the user.
  31886. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31887. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31888. * @param update the boolean update value actually passed to setParticles()
  31889. */
  31890. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31891. /**
  31892. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31893. * This will be passed three parameters.
  31894. * This does nothing and may be overwritten by the user.
  31895. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31896. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31897. * @param update the boolean update value actually passed to setParticles()
  31898. */
  31899. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31900. }
  31901. }
  31902. declare module BABYLON {
  31903. /**
  31904. * Type of sub emitter
  31905. */
  31906. enum SubEmitterType {
  31907. /**
  31908. * Attached to the particle over it's lifetime
  31909. */
  31910. ATTACHED = 0,
  31911. /**
  31912. * Created when the particle dies
  31913. */
  31914. END = 1
  31915. }
  31916. /**
  31917. * Sub emitter class used to emit particles from an existing particle
  31918. */
  31919. class SubEmitter {
  31920. /**
  31921. * the particle system to be used by the sub emitter
  31922. */
  31923. particleSystem: ParticleSystem;
  31924. /**
  31925. * Type of the submitter (Default: END)
  31926. */
  31927. type: SubEmitterType;
  31928. /**
  31929. * 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)
  31930. * Note: This only is supported when using an emitter of type Mesh
  31931. */
  31932. inheritDirection: boolean;
  31933. /**
  31934. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  31935. */
  31936. inheritedVelocityAmount: number;
  31937. /**
  31938. * Creates a sub emitter
  31939. * @param particleSystem the particle system to be used by the sub emitter
  31940. */
  31941. constructor(
  31942. /**
  31943. * the particle system to be used by the sub emitter
  31944. */
  31945. particleSystem: ParticleSystem);
  31946. /**
  31947. * Clones the sub emitter
  31948. * @returns the cloned sub emitter
  31949. */
  31950. clone(): SubEmitter;
  31951. /**
  31952. * Serialize current object to a JSON object
  31953. * @returns the serialized object
  31954. */
  31955. serialize(): any;
  31956. /**
  31957. * Creates a new SubEmitter from a serialized JSON version
  31958. * @param serializationObject defines the JSON object to read from
  31959. * @param scene defines the hosting scene
  31960. * @param rootUrl defines the rootUrl for data loading
  31961. * @returns a new SubEmitter
  31962. */
  31963. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  31964. /** Release associated resources */
  31965. dispose(): void;
  31966. }
  31967. }
  31968. declare module BABYLON {
  31969. /**
  31970. * Interface used to describe a physics joint
  31971. */
  31972. interface PhysicsImpostorJoint {
  31973. /** Defines the main impostor to which the joint is linked */
  31974. mainImpostor: PhysicsImpostor;
  31975. /** Defines the impostor that is connected to the main impostor using this joint */
  31976. connectedImpostor: PhysicsImpostor;
  31977. /** Defines the joint itself */
  31978. joint: PhysicsJoint;
  31979. }
  31980. /** @hidden */
  31981. interface IPhysicsEnginePlugin {
  31982. world: any;
  31983. name: string;
  31984. setGravity(gravity: Vector3): void;
  31985. setTimeStep(timeStep: number): void;
  31986. getTimeStep(): number;
  31987. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31988. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31989. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31990. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31991. removePhysicsBody(impostor: PhysicsImpostor): void;
  31992. generateJoint(joint: PhysicsImpostorJoint): void;
  31993. removeJoint(joint: PhysicsImpostorJoint): void;
  31994. isSupported(): boolean;
  31995. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31996. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31997. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31998. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31999. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32000. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32001. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32002. getBodyMass(impostor: PhysicsImpostor): number;
  32003. getBodyFriction(impostor: PhysicsImpostor): number;
  32004. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32005. getBodyRestitution(impostor: PhysicsImpostor): number;
  32006. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32007. sleepBody(impostor: PhysicsImpostor): void;
  32008. wakeUpBody(impostor: PhysicsImpostor): void;
  32009. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32010. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32011. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32012. getRadius(impostor: PhysicsImpostor): number;
  32013. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32014. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32015. dispose(): void;
  32016. }
  32017. /**
  32018. * Interface used to define a physics engine
  32019. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32020. */
  32021. interface IPhysicsEngine {
  32022. /**
  32023. * Gets the gravity vector used by the simulation
  32024. */
  32025. gravity: Vector3;
  32026. /**
  32027. * Sets the gravity vector used by the simulation
  32028. * @param gravity defines the gravity vector to use
  32029. */
  32030. setGravity(gravity: Vector3): void;
  32031. /**
  32032. * Set the time step of the physics engine.
  32033. * Default is 1/60.
  32034. * To slow it down, enter 1/600 for example.
  32035. * To speed it up, 1/30
  32036. * @param newTimeStep the new timestep to apply to this world.
  32037. */
  32038. setTimeStep(newTimeStep: number): void;
  32039. /**
  32040. * Get the time step of the physics engine.
  32041. * @returns the current time step
  32042. */
  32043. getTimeStep(): number;
  32044. /**
  32045. * Release all resources
  32046. */
  32047. dispose(): void;
  32048. /**
  32049. * Gets the name of the current physics plugin
  32050. * @returns the name of the plugin
  32051. */
  32052. getPhysicsPluginName(): string;
  32053. /**
  32054. * Adding a new impostor for the impostor tracking.
  32055. * This will be done by the impostor itself.
  32056. * @param impostor the impostor to add
  32057. */
  32058. addImpostor(impostor: PhysicsImpostor): void;
  32059. /**
  32060. * Remove an impostor from the engine.
  32061. * This impostor and its mesh will not longer be updated by the physics engine.
  32062. * @param impostor the impostor to remove
  32063. */
  32064. removeImpostor(impostor: PhysicsImpostor): void;
  32065. /**
  32066. * Add a joint to the physics engine
  32067. * @param mainImpostor defines the main impostor to which the joint is added.
  32068. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32069. * @param joint defines the joint that will connect both impostors.
  32070. */
  32071. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32072. /**
  32073. * Removes a joint from the simulation
  32074. * @param mainImpostor defines the impostor used with the joint
  32075. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32076. * @param joint defines the joint to remove
  32077. */
  32078. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32079. /**
  32080. * Gets the current plugin used to run the simulation
  32081. * @returns current plugin
  32082. */
  32083. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32084. /**
  32085. * Gets the list of physic impostors
  32086. * @returns an array of PhysicsImpostor
  32087. */
  32088. getImpostors(): Array<PhysicsImpostor>;
  32089. /**
  32090. * Gets the impostor for a physics enabled object
  32091. * @param object defines the object impersonated by the impostor
  32092. * @returns the PhysicsImpostor or null if not found
  32093. */
  32094. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32095. /**
  32096. * Gets the impostor for a physics body object
  32097. * @param body defines physics body used by the impostor
  32098. * @returns the PhysicsImpostor or null if not found
  32099. */
  32100. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32101. /**
  32102. * Called by the scene. No need to call it.
  32103. * @param delta defines the timespam between frames
  32104. */
  32105. _step(delta: number): void;
  32106. }
  32107. }
  32108. declare module BABYLON {
  32109. /**
  32110. * Class used to control physics engine
  32111. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32112. */
  32113. class PhysicsEngine implements IPhysicsEngine {
  32114. private _physicsPlugin;
  32115. /**
  32116. * Global value used to control the smallest number supported by the simulation
  32117. */
  32118. static Epsilon: number;
  32119. private _impostors;
  32120. private _joints;
  32121. /**
  32122. * Gets the gravity vector used by the simulation
  32123. */
  32124. gravity: Vector3;
  32125. /**
  32126. * Creates a new Physics Engine
  32127. * @param gravity defines the gravity vector used by the simulation
  32128. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  32129. */
  32130. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  32131. /**
  32132. * Sets the gravity vector used by the simulation
  32133. * @param gravity defines the gravity vector to use
  32134. */
  32135. setGravity(gravity: Vector3): void;
  32136. /**
  32137. * Set the time step of the physics engine.
  32138. * Default is 1/60.
  32139. * To slow it down, enter 1/600 for example.
  32140. * To speed it up, 1/30
  32141. * @param newTimeStep defines the new timestep to apply to this world.
  32142. */
  32143. setTimeStep(newTimeStep?: number): void;
  32144. /**
  32145. * Get the time step of the physics engine.
  32146. * @returns the current time step
  32147. */
  32148. getTimeStep(): number;
  32149. /**
  32150. * Release all resources
  32151. */
  32152. dispose(): void;
  32153. /**
  32154. * Gets the name of the current physics plugin
  32155. * @returns the name of the plugin
  32156. */
  32157. getPhysicsPluginName(): string;
  32158. /**
  32159. * Adding a new impostor for the impostor tracking.
  32160. * This will be done by the impostor itself.
  32161. * @param impostor the impostor to add
  32162. */
  32163. addImpostor(impostor: PhysicsImpostor): void;
  32164. /**
  32165. * Remove an impostor from the engine.
  32166. * This impostor and its mesh will not longer be updated by the physics engine.
  32167. * @param impostor the impostor to remove
  32168. */
  32169. removeImpostor(impostor: PhysicsImpostor): void;
  32170. /**
  32171. * Add a joint to the physics engine
  32172. * @param mainImpostor defines the main impostor to which the joint is added.
  32173. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32174. * @param joint defines the joint that will connect both impostors.
  32175. */
  32176. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32177. /**
  32178. * Removes a joint from the simulation
  32179. * @param mainImpostor defines the impostor used with the joint
  32180. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32181. * @param joint defines the joint to remove
  32182. */
  32183. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32184. /**
  32185. * Called by the scene. No need to call it.
  32186. * @param delta defines the timespam between frames
  32187. */
  32188. _step(delta: number): void;
  32189. /**
  32190. * Gets the current plugin used to run the simulation
  32191. * @returns current plugin
  32192. */
  32193. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32194. /**
  32195. * Gets the list of physic impostors
  32196. * @returns an array of PhysicsImpostor
  32197. */
  32198. getImpostors(): Array<PhysicsImpostor>;
  32199. /**
  32200. * Gets the impostor for a physics enabled object
  32201. * @param object defines the object impersonated by the impostor
  32202. * @returns the PhysicsImpostor or null if not found
  32203. */
  32204. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32205. /**
  32206. * Gets the impostor for a physics body object
  32207. * @param body defines physics body used by the impostor
  32208. * @returns the PhysicsImpostor or null if not found
  32209. */
  32210. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32211. }
  32212. }
  32213. declare module BABYLON {
  32214. interface Scene {
  32215. /** @hidden (Backing field) */
  32216. _physicsEngine: Nullable<IPhysicsEngine>;
  32217. /**
  32218. * Gets the current physics engine
  32219. * @returns a IPhysicsEngine or null if none attached
  32220. */
  32221. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  32222. /**
  32223. * Enables physics to the current scene
  32224. * @param gravity defines the scene's gravity for the physics engine
  32225. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  32226. * @return a boolean indicating if the physics engine was initialized
  32227. */
  32228. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  32229. /**
  32230. * Disables and disposes the physics engine associated with the scene
  32231. */
  32232. disablePhysicsEngine(): void;
  32233. /**
  32234. * Gets a boolean indicating if there is an active physics engine
  32235. * @returns a boolean indicating if there is an active physics engine
  32236. */
  32237. isPhysicsEnabled(): boolean;
  32238. /**
  32239. * Deletes a physics compound impostor
  32240. * @param compound defines the compound to delete
  32241. */
  32242. deleteCompoundImpostor(compound: any): void;
  32243. /**
  32244. * An event triggered when physic simulation is about to be run
  32245. */
  32246. onBeforePhysicsObservable: Observable<Scene>;
  32247. /**
  32248. * An event triggered when physic simulation has been done
  32249. */
  32250. onAfterPhysicsObservable: Observable<Scene>;
  32251. }
  32252. interface AbstractMesh {
  32253. /** @hidden */
  32254. _physicsImpostor: Nullable<PhysicsImpostor>;
  32255. /**
  32256. * Gets or sets impostor used for physic simulation
  32257. * @see http://doc.babylonjs.com/features/physics_engine
  32258. */
  32259. physicsImpostor: Nullable<PhysicsImpostor>;
  32260. /**
  32261. * Gets the current physics impostor
  32262. * @see http://doc.babylonjs.com/features/physics_engine
  32263. * @returns a physics impostor or null
  32264. */
  32265. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  32266. /** Apply a physic impulse to the mesh
  32267. * @param force defines the force to apply
  32268. * @param contactPoint defines where to apply the force
  32269. * @returns the current mesh
  32270. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32271. */
  32272. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  32273. /**
  32274. * Creates a physic joint between two meshes
  32275. * @param otherMesh defines the other mesh to use
  32276. * @param pivot1 defines the pivot to use on this mesh
  32277. * @param pivot2 defines the pivot to use on the other mesh
  32278. * @param options defines additional options (can be plugin dependent)
  32279. * @returns the current mesh
  32280. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  32281. */
  32282. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  32283. /** @hidden */
  32284. _disposePhysicsObserver: Nullable<Observer<Node>>;
  32285. }
  32286. /**
  32287. * Defines the physics engine scene component responsible to manage a physics engine
  32288. */
  32289. class PhysicsEngineSceneComponent implements ISceneComponent {
  32290. /**
  32291. * The component name helpful to identify the component in the list of scene components.
  32292. */
  32293. readonly name: string;
  32294. /**
  32295. * The scene the component belongs to.
  32296. */
  32297. scene: Scene;
  32298. /**
  32299. * Creates a new instance of the component for the given scene
  32300. * @param scene Defines the scene to register the component in
  32301. */
  32302. constructor(scene: Scene);
  32303. /**
  32304. * Registers the component in a given scene
  32305. */
  32306. register(): void;
  32307. /**
  32308. * Rebuilds the elements related to this component in case of
  32309. * context lost for instance.
  32310. */
  32311. rebuild(): void;
  32312. /**
  32313. * Disposes the component and the associated ressources
  32314. */
  32315. dispose(): void;
  32316. }
  32317. }
  32318. declare module BABYLON {
  32319. /**
  32320. * A helper for physics simulations
  32321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32322. */
  32323. class PhysicsHelper {
  32324. private _scene;
  32325. private _physicsEngine;
  32326. /**
  32327. * Initializes the Physics helper
  32328. * @param scene Babylon.js scene
  32329. */
  32330. constructor(scene: Scene);
  32331. /**
  32332. * Applies a radial explosion impulse
  32333. * @param origin the origin of the explosion
  32334. * @param radius the explosion radius
  32335. * @param strength the explosion strength
  32336. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32337. * @returns A physics radial explosion event, or null
  32338. */
  32339. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  32340. /**
  32341. * Applies a radial explosion force
  32342. * @param origin the origin of the explosion
  32343. * @param radius the explosion radius
  32344. * @param strength the explosion strength
  32345. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32346. * @returns A physics radial explosion event, or null
  32347. */
  32348. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  32349. /**
  32350. * Creates a gravitational field
  32351. * @param origin the origin of the explosion
  32352. * @param radius the explosion radius
  32353. * @param strength the explosion strength
  32354. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32355. * @returns A physics gravitational field event, or null
  32356. */
  32357. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  32358. /**
  32359. * Creates a physics updraft event
  32360. * @param origin the origin of the updraft
  32361. * @param radius the radius of the updraft
  32362. * @param strength the strength of the updraft
  32363. * @param height the height of the updraft
  32364. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  32365. * @returns A physics updraft event, or null
  32366. */
  32367. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  32368. /**
  32369. * Creates a physics vortex event
  32370. * @param origin the of the vortex
  32371. * @param radius the radius of the vortex
  32372. * @param strength the strength of the vortex
  32373. * @param height the height of the vortex
  32374. * @returns a Physics vortex event, or null
  32375. * A physics vortex event or null
  32376. */
  32377. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  32378. }
  32379. /**
  32380. * Represents a physics radial explosion event
  32381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32382. */
  32383. class PhysicsRadialExplosionEvent {
  32384. private _scene;
  32385. private _sphere;
  32386. private _sphereOptions;
  32387. private _rays;
  32388. private _dataFetched;
  32389. /**
  32390. * Initializes a radial explosioin event
  32391. * @param scene BabylonJS scene
  32392. */
  32393. constructor(scene: Scene);
  32394. /**
  32395. * Returns the data related to the radial explosion event (sphere & rays).
  32396. * @returns The radial explosion event data
  32397. */
  32398. getData(): PhysicsRadialExplosionEventData;
  32399. /**
  32400. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  32401. * @param impostor A physics imposter
  32402. * @param origin the origin of the explosion
  32403. * @param radius the explosion radius
  32404. * @param strength the explosion strength
  32405. * @param falloff possible options: Constant & Linear
  32406. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  32407. */
  32408. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  32409. /**
  32410. * Disposes the sphere.
  32411. * @param force Specifies if the sphere should be disposed by force
  32412. */
  32413. dispose(force?: boolean): void;
  32414. /*** Helpers ***/
  32415. private _prepareSphere;
  32416. private _intersectsWithSphere;
  32417. }
  32418. /**
  32419. * Represents a gravitational field event
  32420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32421. */
  32422. class PhysicsGravitationalFieldEvent {
  32423. private _physicsHelper;
  32424. private _scene;
  32425. private _origin;
  32426. private _radius;
  32427. private _strength;
  32428. private _falloff;
  32429. private _tickCallback;
  32430. private _sphere;
  32431. private _dataFetched;
  32432. /**
  32433. * Initializes the physics gravitational field event
  32434. * @param physicsHelper A physics helper
  32435. * @param scene BabylonJS scene
  32436. * @param origin The origin position of the gravitational field event
  32437. * @param radius The radius of the gravitational field event
  32438. * @param strength The strength of the gravitational field event
  32439. * @param falloff The falloff for the gravitational field event
  32440. */
  32441. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  32442. /**
  32443. * Returns the data related to the gravitational field event (sphere).
  32444. * @returns A gravitational field event
  32445. */
  32446. getData(): PhysicsGravitationalFieldEventData;
  32447. /**
  32448. * Enables the gravitational field.
  32449. */
  32450. enable(): void;
  32451. /**
  32452. * Disables the gravitational field.
  32453. */
  32454. disable(): void;
  32455. /**
  32456. * Disposes the sphere.
  32457. * @param force The force to dispose from the gravitational field event
  32458. */
  32459. dispose(force?: boolean): void;
  32460. private _tick;
  32461. }
  32462. /**
  32463. * Represents a physics updraft event
  32464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32465. */
  32466. class PhysicsUpdraftEvent {
  32467. private _scene;
  32468. private _origin;
  32469. private _radius;
  32470. private _strength;
  32471. private _height;
  32472. private _updraftMode;
  32473. private _physicsEngine;
  32474. private _originTop;
  32475. private _originDirection;
  32476. private _tickCallback;
  32477. private _cylinder;
  32478. private _cylinderPosition;
  32479. private _dataFetched;
  32480. /**
  32481. * Initializes the physics updraft event
  32482. * @param _scene BabylonJS scene
  32483. * @param _origin The origin position of the updraft
  32484. * @param _radius The radius of the updraft
  32485. * @param _strength The strength of the updraft
  32486. * @param _height The height of the updraft
  32487. * @param _updraftMode The mode of the updraft
  32488. */
  32489. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  32490. /**
  32491. * Returns the data related to the updraft event (cylinder).
  32492. * @returns A physics updraft event
  32493. */
  32494. getData(): PhysicsUpdraftEventData;
  32495. /**
  32496. * Enables the updraft.
  32497. */
  32498. enable(): void;
  32499. /**
  32500. * Disables the cortex.
  32501. */
  32502. disable(): void;
  32503. /**
  32504. * Disposes the sphere.
  32505. * @param force Specifies if the updraft should be disposed by force
  32506. */
  32507. dispose(force?: boolean): void;
  32508. private getImpostorForceAndContactPoint;
  32509. private _tick;
  32510. /*** Helpers ***/
  32511. private _prepareCylinder;
  32512. private _intersectsWithCylinder;
  32513. }
  32514. /**
  32515. * Represents a physics vortex event
  32516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32517. */
  32518. class PhysicsVortexEvent {
  32519. private _scene;
  32520. private _origin;
  32521. private _radius;
  32522. private _strength;
  32523. private _height;
  32524. private _physicsEngine;
  32525. private _originTop;
  32526. private _centripetalForceThreshold;
  32527. private _updraftMultiplier;
  32528. private _tickCallback;
  32529. private _cylinder;
  32530. private _cylinderPosition;
  32531. private _dataFetched;
  32532. /**
  32533. * Initializes the physics vortex event
  32534. * @param _scene The BabylonJS scene
  32535. * @param _origin The origin position of the vortex
  32536. * @param _radius The radius of the vortex
  32537. * @param _strength The strength of the vortex
  32538. * @param _height The height of the vortex
  32539. */
  32540. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  32541. /**
  32542. * Returns the data related to the vortex event (cylinder).
  32543. * @returns The physics vortex event data
  32544. */
  32545. getData(): PhysicsVortexEventData;
  32546. /**
  32547. * Enables the vortex.
  32548. */
  32549. enable(): void;
  32550. /**
  32551. * Disables the cortex.
  32552. */
  32553. disable(): void;
  32554. /**
  32555. * Disposes the sphere.
  32556. * @param force
  32557. */
  32558. dispose(force?: boolean): void;
  32559. private getImpostorForceAndContactPoint;
  32560. private _tick;
  32561. /*** Helpers ***/
  32562. private _prepareCylinder;
  32563. private _intersectsWithCylinder;
  32564. }
  32565. /**
  32566. * The strenght of the force in correspondence to the distance of the affected object
  32567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32568. */
  32569. enum PhysicsRadialImpulseFalloff {
  32570. /** Defines that impulse is constant in strength across it's whole radius */
  32571. Constant = 0,
  32572. /** DEfines that impulse gets weaker if it's further from the origin */
  32573. Linear = 1
  32574. }
  32575. /**
  32576. * The strength of the force in correspondence to the distance of the affected object
  32577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32578. */
  32579. enum PhysicsUpdraftMode {
  32580. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  32581. Center = 0,
  32582. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  32583. Perpendicular = 1
  32584. }
  32585. /**
  32586. * Interface for a physics force and contact point
  32587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32588. */
  32589. interface PhysicsForceAndContactPoint {
  32590. /**
  32591. * The force applied at the contact point
  32592. */
  32593. force: Vector3;
  32594. /**
  32595. * The contact point
  32596. */
  32597. contactPoint: Vector3;
  32598. }
  32599. /**
  32600. * Interface for radial explosion event data
  32601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32602. */
  32603. interface PhysicsRadialExplosionEventData {
  32604. /**
  32605. * A sphere used for the radial explosion event
  32606. */
  32607. sphere: Mesh;
  32608. /**
  32609. * An array of rays for the radial explosion event
  32610. */
  32611. rays: Array<Ray>;
  32612. }
  32613. /**
  32614. * Interface for gravitational field event data
  32615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32616. */
  32617. interface PhysicsGravitationalFieldEventData {
  32618. /**
  32619. * A sphere mesh used for the gravitational field event
  32620. */
  32621. sphere: Mesh;
  32622. }
  32623. /**
  32624. * Interface for updraft event data
  32625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32626. */
  32627. interface PhysicsUpdraftEventData {
  32628. /**
  32629. * A cylinder used for the updraft event
  32630. */
  32631. cylinder: Mesh;
  32632. }
  32633. /**
  32634. * Interface for vortex event data
  32635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32636. */
  32637. interface PhysicsVortexEventData {
  32638. /**
  32639. * A cylinder used for the vortex event
  32640. */
  32641. cylinder: Mesh;
  32642. }
  32643. }
  32644. declare module BABYLON {
  32645. /**
  32646. * The interface for the physics imposter parameters
  32647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32648. */
  32649. interface PhysicsImpostorParameters {
  32650. /**
  32651. * The mass of the physics imposter
  32652. */
  32653. mass: number;
  32654. /**
  32655. * The friction of the physics imposter
  32656. */
  32657. friction?: number;
  32658. /**
  32659. * The coefficient of restitution of the physics imposter
  32660. */
  32661. restitution?: number;
  32662. /**
  32663. * The native options of the physics imposter
  32664. */
  32665. nativeOptions?: any;
  32666. /**
  32667. * Specifies if the parent should be ignored
  32668. */
  32669. ignoreParent?: boolean;
  32670. /**
  32671. * Specifies if bi-directional transformations should be disabled
  32672. */
  32673. disableBidirectionalTransformation?: boolean;
  32674. }
  32675. /**
  32676. * Interface for a physics-enabled object
  32677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32678. */
  32679. interface IPhysicsEnabledObject {
  32680. /**
  32681. * The position of the physics-enabled object
  32682. */
  32683. position: Vector3;
  32684. /**
  32685. * The rotation of the physics-enabled object
  32686. */
  32687. rotationQuaternion: Nullable<Quaternion>;
  32688. /**
  32689. * The scale of the physics-enabled object
  32690. */
  32691. scaling: Vector3;
  32692. /**
  32693. * The rotation of the physics-enabled object
  32694. */
  32695. rotation?: Vector3;
  32696. /**
  32697. * The parent of the physics-enabled object
  32698. */
  32699. parent?: any;
  32700. /**
  32701. * The bounding info of the physics-enabled object
  32702. * @returns The bounding info of the physics-enabled object
  32703. */
  32704. getBoundingInfo(): BoundingInfo;
  32705. /**
  32706. * Computes the world matrix
  32707. * @param force Specifies if the world matrix should be computed by force
  32708. * @returns A world matrix
  32709. */
  32710. computeWorldMatrix(force: boolean): Matrix;
  32711. /**
  32712. * Gets the world matrix
  32713. * @returns A world matrix
  32714. */
  32715. getWorldMatrix?(): Matrix;
  32716. /**
  32717. * Gets the child meshes
  32718. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32719. * @returns An array of abstract meshes
  32720. */
  32721. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32722. /**
  32723. * Gets the vertex data
  32724. * @param kind The type of vertex data
  32725. * @returns A nullable array of numbers, or a float32 array
  32726. */
  32727. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32728. /**
  32729. * Gets the indices from the mesh
  32730. * @returns A nullable array of index arrays
  32731. */
  32732. getIndices?(): Nullable<IndicesArray>;
  32733. /**
  32734. * Gets the scene from the mesh
  32735. * @returns the indices array or null
  32736. */
  32737. getScene?(): Scene;
  32738. /**
  32739. * Gets the absolute position from the mesh
  32740. * @returns the absolute position
  32741. */
  32742. getAbsolutePosition(): Vector3;
  32743. /**
  32744. * Gets the absolute pivot point from the mesh
  32745. * @returns the absolute pivot point
  32746. */
  32747. getAbsolutePivotPoint(): Vector3;
  32748. /**
  32749. * Rotates the mesh
  32750. * @param axis The axis of rotation
  32751. * @param amount The amount of rotation
  32752. * @param space The space of the rotation
  32753. * @returns The rotation transform node
  32754. */
  32755. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32756. /**
  32757. * Translates the mesh
  32758. * @param axis The axis of translation
  32759. * @param distance The distance of translation
  32760. * @param space The space of the translation
  32761. * @returns The transform node
  32762. */
  32763. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32764. /**
  32765. * Sets the absolute position of the mesh
  32766. * @param absolutePosition The absolute position of the mesh
  32767. * @returns The transform node
  32768. */
  32769. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32770. /**
  32771. * Gets the class name of the mesh
  32772. * @returns The class name
  32773. */
  32774. getClassName(): string;
  32775. }
  32776. /**
  32777. * Represents a physics imposter
  32778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32779. */
  32780. class PhysicsImpostor {
  32781. /**
  32782. * The physics-enabled object used as the physics imposter
  32783. */
  32784. object: IPhysicsEnabledObject;
  32785. /**
  32786. * The type of the physics imposter
  32787. */
  32788. type: number;
  32789. private _options;
  32790. private _scene?;
  32791. /**
  32792. * The default object size of the imposter
  32793. */
  32794. static DEFAULT_OBJECT_SIZE: Vector3;
  32795. /**
  32796. * The identity quaternion of the imposter
  32797. */
  32798. static IDENTITY_QUATERNION: Quaternion;
  32799. private _physicsEngine;
  32800. private _physicsBody;
  32801. private _bodyUpdateRequired;
  32802. private _onBeforePhysicsStepCallbacks;
  32803. private _onAfterPhysicsStepCallbacks;
  32804. private _onPhysicsCollideCallbacks;
  32805. private _deltaPosition;
  32806. private _deltaRotation;
  32807. private _deltaRotationConjugated;
  32808. private _parent;
  32809. private _isDisposed;
  32810. private static _tmpVecs;
  32811. private static _tmpQuat;
  32812. /**
  32813. * Specifies if the physics imposter is disposed
  32814. */
  32815. readonly isDisposed: boolean;
  32816. /**
  32817. * Gets the mass of the physics imposter
  32818. */
  32819. mass: number;
  32820. /**
  32821. * Gets the coefficient of friction
  32822. */
  32823. /**
  32824. * Sets the coefficient of friction
  32825. */
  32826. friction: number;
  32827. /**
  32828. * Gets the coefficient of restitution
  32829. */
  32830. /**
  32831. * Sets the coefficient of restitution
  32832. */
  32833. restitution: number;
  32834. /**
  32835. * The unique id of the physics imposter
  32836. * set by the physics engine when adding this impostor to the array
  32837. */
  32838. uniqueId: number;
  32839. private _joints;
  32840. /**
  32841. * Initializes the physics imposter
  32842. * @param object The physics-enabled object used as the physics imposter
  32843. * @param type The type of the physics imposter
  32844. * @param _options The options for the physics imposter
  32845. * @param _scene The Babylon scene
  32846. */
  32847. constructor(
  32848. /**
  32849. * The physics-enabled object used as the physics imposter
  32850. */
  32851. object: IPhysicsEnabledObject,
  32852. /**
  32853. * The type of the physics imposter
  32854. */
  32855. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32856. /**
  32857. * This function will completly initialize this impostor.
  32858. * It will create a new body - but only if this mesh has no parent.
  32859. * If it has, this impostor will not be used other than to define the impostor
  32860. * of the child mesh.
  32861. * @hidden
  32862. */
  32863. _init(): void;
  32864. private _getPhysicsParent;
  32865. /**
  32866. * Should a new body be generated.
  32867. * @returns boolean specifying if body initialization is required
  32868. */
  32869. isBodyInitRequired(): boolean;
  32870. /**
  32871. * Sets the updated scaling
  32872. * @param updated Specifies if the scaling is updated
  32873. */
  32874. setScalingUpdated(updated: boolean): void;
  32875. /**
  32876. * Force a regeneration of this or the parent's impostor's body.
  32877. * Use under cautious - This will remove all joints already implemented.
  32878. */
  32879. forceUpdate(): void;
  32880. /**
  32881. * Gets the body that holds this impostor. Either its own, or its parent.
  32882. */
  32883. /**
  32884. * Set the physics body. Used mainly by the physics engine/plugin
  32885. */
  32886. physicsBody: any;
  32887. /**
  32888. * Get the parent of the physics imposter
  32889. * @returns Physics imposter or null
  32890. */
  32891. /**
  32892. * Sets the parent of the physics imposter
  32893. */
  32894. parent: Nullable<PhysicsImpostor>;
  32895. /**
  32896. * Resets the update flags
  32897. */
  32898. resetUpdateFlags(): void;
  32899. /**
  32900. * Gets the object extend size
  32901. * @returns the object extend size
  32902. */
  32903. getObjectExtendSize(): Vector3;
  32904. /**
  32905. * Gets the object center
  32906. * @returns The object center
  32907. */
  32908. getObjectCenter(): Vector3;
  32909. /**
  32910. * Get a specific parametes from the options parameter
  32911. * @param paramName The object parameter name
  32912. * @returns The object parameter
  32913. */
  32914. getParam(paramName: string): any;
  32915. /**
  32916. * Sets a specific parameter in the options given to the physics plugin
  32917. * @param paramName The parameter name
  32918. * @param value The value of the parameter
  32919. */
  32920. setParam(paramName: string, value: number): void;
  32921. /**
  32922. * Specifically change the body's mass option. Won't recreate the physics body object
  32923. * @param mass The mass of the physics imposter
  32924. */
  32925. setMass(mass: number): void;
  32926. /**
  32927. * Gets the linear velocity
  32928. * @returns linear velocity or null
  32929. */
  32930. getLinearVelocity(): Nullable<Vector3>;
  32931. /**
  32932. * Sets the linear velocity
  32933. * @param velocity linear velocity or null
  32934. */
  32935. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32936. /**
  32937. * Gets the angular velocity
  32938. * @returns angular velocity or null
  32939. */
  32940. getAngularVelocity(): Nullable<Vector3>;
  32941. /**
  32942. * Sets the angular velocity
  32943. * @param velocity The velocity or null
  32944. */
  32945. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32946. /**
  32947. * Execute a function with the physics plugin native code
  32948. * Provide a function the will have two variables - the world object and the physics body object
  32949. * @param func The function to execute with the physics plugin native code
  32950. */
  32951. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32952. /**
  32953. * Register a function that will be executed before the physics world is stepping forward
  32954. * @param func The function to execute before the physics world is stepped forward
  32955. */
  32956. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32957. /**
  32958. * Unregister a function that will be executed before the physics world is stepping forward
  32959. * @param func The function to execute before the physics world is stepped forward
  32960. */
  32961. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32962. /**
  32963. * Register a function that will be executed after the physics step
  32964. * @param func The function to execute after physics step
  32965. */
  32966. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32967. /**
  32968. * Unregisters a function that will be executed after the physics step
  32969. * @param func The function to execute after physics step
  32970. */
  32971. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32972. /**
  32973. * register a function that will be executed when this impostor collides against a different body
  32974. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32975. * @param func Callback that is executed on collision
  32976. */
  32977. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32978. /**
  32979. * Unregisters the physics imposter on contact
  32980. * @param collideAgainst The physics object to collide against
  32981. * @param func Callback to execute on collision
  32982. */
  32983. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32984. private _tmpQuat;
  32985. private _tmpQuat2;
  32986. /**
  32987. * Get the parent rotation
  32988. * @returns The parent rotation
  32989. */
  32990. getParentsRotation(): Quaternion;
  32991. /**
  32992. * this function is executed by the physics engine.
  32993. */
  32994. beforeStep: () => void;
  32995. /**
  32996. * this function is executed by the physics engine
  32997. */
  32998. afterStep: () => void;
  32999. /**
  33000. * Legacy collision detection event support
  33001. */
  33002. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33003. /**
  33004. * event and body object due to cannon's event-based architecture.
  33005. */
  33006. onCollide: (e: {
  33007. body: any;
  33008. }) => void;
  33009. /**
  33010. * Apply a force
  33011. * @param force The force to apply
  33012. * @param contactPoint The contact point for the force
  33013. * @returns The physics imposter
  33014. */
  33015. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33016. /**
  33017. * Apply an impulse
  33018. * @param force The impulse force
  33019. * @param contactPoint The contact point for the impulse force
  33020. * @returns The physics imposter
  33021. */
  33022. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33023. /**
  33024. * A help function to create a joint
  33025. * @param otherImpostor A physics imposter used to create a joint
  33026. * @param jointType The type of joint
  33027. * @param jointData The data for the joint
  33028. * @returns The physics imposter
  33029. */
  33030. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33031. /**
  33032. * Add a joint to this impostor with a different impostor
  33033. * @param otherImpostor A physics imposter used to add a joint
  33034. * @param joint The joint to add
  33035. * @returns The physics imposter
  33036. */
  33037. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33038. /**
  33039. * Will keep this body still, in a sleep mode.
  33040. * @returns the physics imposter
  33041. */
  33042. sleep(): PhysicsImpostor;
  33043. /**
  33044. * Wake the body up.
  33045. * @returns The physics imposter
  33046. */
  33047. wakeUp(): PhysicsImpostor;
  33048. /**
  33049. * Clones the physics imposter
  33050. * @param newObject The physics imposter clones to this physics-enabled object
  33051. * @returns A nullable physics imposter
  33052. */
  33053. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33054. /**
  33055. * Disposes the physics imposter
  33056. */
  33057. dispose(): void;
  33058. /**
  33059. * Sets the delta position
  33060. * @param position The delta position amount
  33061. */
  33062. setDeltaPosition(position: Vector3): void;
  33063. /**
  33064. * Sets the delta rotation
  33065. * @param rotation The delta rotation amount
  33066. */
  33067. setDeltaRotation(rotation: Quaternion): void;
  33068. /**
  33069. * Gets the box size of the physics imposter and stores the result in the input parameter
  33070. * @param result Stores the box size
  33071. * @returns The physics imposter
  33072. */
  33073. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33074. /**
  33075. * Gets the radius of the physics imposter
  33076. * @returns Radius of the physics imposter
  33077. */
  33078. getRadius(): number;
  33079. /**
  33080. * Sync a bone with this impostor
  33081. * @param bone The bone to sync to the impostor.
  33082. * @param boneMesh The mesh that the bone is influencing.
  33083. * @param jointPivot The pivot of the joint / bone in local space.
  33084. * @param distToJoint Optional distance from the impostor to the joint.
  33085. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33086. */
  33087. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33088. /**
  33089. * Sync impostor to a bone
  33090. * @param bone The bone that the impostor will be synced to.
  33091. * @param boneMesh The mesh that the bone is influencing.
  33092. * @param jointPivot The pivot of the joint / bone in local space.
  33093. * @param distToJoint Optional distance from the impostor to the joint.
  33094. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33095. * @param boneAxis Optional vector3 axis the bone is aligned with
  33096. */
  33097. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33098. /**
  33099. * No-Imposter type
  33100. */
  33101. static NoImpostor: number;
  33102. /**
  33103. * Sphere-Imposter type
  33104. */
  33105. static SphereImpostor: number;
  33106. /**
  33107. * Box-Imposter type
  33108. */
  33109. static BoxImpostor: number;
  33110. /**
  33111. * Plane-Imposter type
  33112. */
  33113. static PlaneImpostor: number;
  33114. /**
  33115. * Mesh-imposter type
  33116. */
  33117. static MeshImpostor: number;
  33118. /**
  33119. * Cylinder-Imposter type
  33120. */
  33121. static CylinderImpostor: number;
  33122. /**
  33123. * Particle-Imposter type
  33124. */
  33125. static ParticleImpostor: number;
  33126. /**
  33127. * Heightmap-Imposter type
  33128. */
  33129. static HeightmapImpostor: number;
  33130. }
  33131. }
  33132. declare module BABYLON {
  33133. /**
  33134. * Interface for Physics-Joint data
  33135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33136. */
  33137. interface PhysicsJointData {
  33138. /**
  33139. * The main pivot of the joint
  33140. */
  33141. mainPivot?: Vector3;
  33142. /**
  33143. * The connected pivot of the joint
  33144. */
  33145. connectedPivot?: Vector3;
  33146. /**
  33147. * The main axis of the joint
  33148. */
  33149. mainAxis?: Vector3;
  33150. /**
  33151. * The connected axis of the joint
  33152. */
  33153. connectedAxis?: Vector3;
  33154. /**
  33155. * The collision of the joint
  33156. */
  33157. collision?: boolean;
  33158. /**
  33159. * Native Oimo/Cannon/Energy data
  33160. */
  33161. nativeParams?: any;
  33162. }
  33163. /**
  33164. * This is a holder class for the physics joint created by the physics plugin
  33165. * It holds a set of functions to control the underlying joint
  33166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33167. */
  33168. class PhysicsJoint {
  33169. /**
  33170. * The type of the physics joint
  33171. */
  33172. type: number;
  33173. /**
  33174. * The data for the physics joint
  33175. */
  33176. jointData: PhysicsJointData;
  33177. private _physicsJoint;
  33178. protected _physicsPlugin: IPhysicsEnginePlugin;
  33179. /**
  33180. * Initializes the physics joint
  33181. * @param type The type of the physics joint
  33182. * @param jointData The data for the physics joint
  33183. */
  33184. constructor(
  33185. /**
  33186. * The type of the physics joint
  33187. */
  33188. type: number,
  33189. /**
  33190. * The data for the physics joint
  33191. */
  33192. jointData: PhysicsJointData);
  33193. /**
  33194. * Gets the physics joint
  33195. */
  33196. /**
  33197. * Sets the physics joint
  33198. */
  33199. physicsJoint: any;
  33200. /**
  33201. * Sets the physics plugin
  33202. */
  33203. physicsPlugin: IPhysicsEnginePlugin;
  33204. /**
  33205. * Execute a function that is physics-plugin specific.
  33206. * @param {Function} func the function that will be executed.
  33207. * It accepts two parameters: the physics world and the physics joint
  33208. */
  33209. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  33210. /**
  33211. * Distance-Joint type
  33212. */
  33213. static DistanceJoint: number;
  33214. /**
  33215. * Hinge-Joint type
  33216. */
  33217. static HingeJoint: number;
  33218. /**
  33219. * Ball-and-Socket joint type
  33220. */
  33221. static BallAndSocketJoint: number;
  33222. /**
  33223. * Wheel-Joint type
  33224. */
  33225. static WheelJoint: number;
  33226. /**
  33227. * Slider-Joint type
  33228. */
  33229. static SliderJoint: number;
  33230. /**
  33231. * Prismatic-Joint type
  33232. */
  33233. static PrismaticJoint: number;
  33234. /**
  33235. * Universal-Joint type
  33236. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  33237. */
  33238. static UniversalJoint: number;
  33239. /**
  33240. * Hinge-Joint 2 type
  33241. */
  33242. static Hinge2Joint: number;
  33243. /**
  33244. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  33245. */
  33246. static PointToPointJoint: number;
  33247. /**
  33248. * Spring-Joint type
  33249. */
  33250. static SpringJoint: number;
  33251. /**
  33252. * Lock-Joint type
  33253. */
  33254. static LockJoint: number;
  33255. }
  33256. /**
  33257. * A class representing a physics distance joint
  33258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33259. */
  33260. class DistanceJoint extends PhysicsJoint {
  33261. /**
  33262. *
  33263. * @param jointData The data for the Distance-Joint
  33264. */
  33265. constructor(jointData: DistanceJointData);
  33266. /**
  33267. * Update the predefined distance.
  33268. * @param maxDistance The maximum preferred distance
  33269. * @param minDistance The minimum preferred distance
  33270. */
  33271. updateDistance(maxDistance: number, minDistance?: number): void;
  33272. }
  33273. /**
  33274. * Represents a Motor-Enabled Joint
  33275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33276. */
  33277. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  33278. /**
  33279. * Initializes the Motor-Enabled Joint
  33280. * @param type The type of the joint
  33281. * @param jointData The physica joint data for the joint
  33282. */
  33283. constructor(type: number, jointData: PhysicsJointData);
  33284. /**
  33285. * Set the motor values.
  33286. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33287. * @param force the force to apply
  33288. * @param maxForce max force for this motor.
  33289. */
  33290. setMotor(force?: number, maxForce?: number): void;
  33291. /**
  33292. * Set the motor's limits.
  33293. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33294. * @param upperLimit The upper limit of the motor
  33295. * @param lowerLimit The lower limit of the motor
  33296. */
  33297. setLimit(upperLimit: number, lowerLimit?: number): void;
  33298. }
  33299. /**
  33300. * This class represents a single physics Hinge-Joint
  33301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33302. */
  33303. class HingeJoint extends MotorEnabledJoint {
  33304. /**
  33305. * Initializes the Hinge-Joint
  33306. * @param jointData The joint data for the Hinge-Joint
  33307. */
  33308. constructor(jointData: PhysicsJointData);
  33309. /**
  33310. * Set the motor values.
  33311. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33312. * @param {number} force the force to apply
  33313. * @param {number} maxForce max force for this motor.
  33314. */
  33315. setMotor(force?: number, maxForce?: number): void;
  33316. /**
  33317. * Set the motor's limits.
  33318. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33319. * @param upperLimit The upper limit of the motor
  33320. * @param lowerLimit The lower limit of the motor
  33321. */
  33322. setLimit(upperLimit: number, lowerLimit?: number): void;
  33323. }
  33324. /**
  33325. * This class represents a dual hinge physics joint (same as wheel joint)
  33326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33327. */
  33328. class Hinge2Joint extends MotorEnabledJoint {
  33329. /**
  33330. * Initializes the Hinge2-Joint
  33331. * @param jointData The joint data for the Hinge2-Joint
  33332. */
  33333. constructor(jointData: PhysicsJointData);
  33334. /**
  33335. * Set the motor values.
  33336. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33337. * @param {number} force the force to apply
  33338. * @param {number} maxForce max force for this motor.
  33339. * @param {motorIndex} the motor's index, 0 or 1.
  33340. */
  33341. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33342. /**
  33343. * Set the motor limits.
  33344. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33345. * @param {number} upperLimit the upper limit
  33346. * @param {number} lowerLimit lower limit
  33347. * @param {motorIndex} the motor's index, 0 or 1.
  33348. */
  33349. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33350. }
  33351. /**
  33352. * Interface for a motor enabled joint
  33353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33354. */
  33355. interface IMotorEnabledJoint {
  33356. /**
  33357. * Physics joint
  33358. */
  33359. physicsJoint: any;
  33360. /**
  33361. * Sets the motor of the motor-enabled joint
  33362. * @param force The force of the motor
  33363. * @param maxForce The maximum force of the motor
  33364. * @param motorIndex The index of the motor
  33365. */
  33366. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33367. /**
  33368. * Sets the limit of the motor
  33369. * @param upperLimit The upper limit of the motor
  33370. * @param lowerLimit The lower limit of the motor
  33371. * @param motorIndex The index of the motor
  33372. */
  33373. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33374. }
  33375. /**
  33376. * Joint data for a Distance-Joint
  33377. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33378. */
  33379. interface DistanceJointData extends PhysicsJointData {
  33380. /**
  33381. * Max distance the 2 joint objects can be apart
  33382. */
  33383. maxDistance: number;
  33384. }
  33385. /**
  33386. * Joint data from a spring joint
  33387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33388. */
  33389. interface SpringJointData extends PhysicsJointData {
  33390. /**
  33391. * Length of the spring
  33392. */
  33393. length: number;
  33394. /**
  33395. * Stiffness of the spring
  33396. */
  33397. stiffness: number;
  33398. /**
  33399. * Damping of the spring
  33400. */
  33401. damping: number;
  33402. /** this callback will be called when applying the force to the impostors. */
  33403. forceApplicationCallback: () => void;
  33404. }
  33405. }
  33406. declare module BABYLON {
  33407. /**
  33408. * Postprocess used to generate anaglyphic rendering
  33409. */
  33410. class AnaglyphPostProcess extends PostProcess {
  33411. private _passedProcess;
  33412. /**
  33413. * Creates a new AnaglyphPostProcess
  33414. * @param name defines postprocess name
  33415. * @param options defines creation options or target ratio scale
  33416. * @param rigCameras defines cameras using this postprocess
  33417. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  33418. * @param engine defines hosting engine
  33419. * @param reusable defines if the postprocess will be reused multiple times per frame
  33420. */
  33421. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  33422. }
  33423. }
  33424. declare module BABYLON {
  33425. /**
  33426. * Post process used to render in black and white
  33427. */
  33428. class BlackAndWhitePostProcess extends PostProcess {
  33429. /**
  33430. * Linear about to convert he result to black and white (default: 1)
  33431. */
  33432. degree: number;
  33433. /**
  33434. * Creates a black and white post process
  33435. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  33436. * @param name The name of the effect.
  33437. * @param options The required width/height ratio to downsize to before computing the render pass.
  33438. * @param camera The camera to apply the render pass to.
  33439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33440. * @param engine The engine which the post process will be applied. (default: current engine)
  33441. * @param reusable If the post process can be reused on the same frame. (default: false)
  33442. */
  33443. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33444. }
  33445. }
  33446. declare module BABYLON {
  33447. /**
  33448. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  33449. */
  33450. class BloomEffect extends PostProcessRenderEffect {
  33451. private bloomScale;
  33452. /**
  33453. * @hidden Internal
  33454. */
  33455. _effects: Array<PostProcess>;
  33456. /**
  33457. * @hidden Internal
  33458. */
  33459. _downscale: ExtractHighlightsPostProcess;
  33460. private _blurX;
  33461. private _blurY;
  33462. private _merge;
  33463. /**
  33464. * The luminance threshold to find bright areas of the image to bloom.
  33465. */
  33466. threshold: number;
  33467. /**
  33468. * The strength of the bloom.
  33469. */
  33470. weight: number;
  33471. /**
  33472. * Specifies the size of the bloom blur kernel, relative to the final output size
  33473. */
  33474. kernel: number;
  33475. /**
  33476. * Creates a new instance of @see BloomEffect
  33477. * @param scene The scene the effect belongs to.
  33478. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  33479. * @param bloomKernel The size of the kernel to be used when applying the blur.
  33480. * @param bloomWeight The the strength of bloom.
  33481. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  33482. * @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)
  33483. */
  33484. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  33485. /**
  33486. * Disposes each of the internal effects for a given camera.
  33487. * @param camera The camera to dispose the effect on.
  33488. */
  33489. disposeEffects(camera: Camera): void;
  33490. /**
  33491. * @hidden Internal
  33492. */
  33493. _updateEffects(): void;
  33494. /**
  33495. * Internal
  33496. * @returns if all the contained post processes are ready.
  33497. * @hidden
  33498. */
  33499. _isReady(): boolean;
  33500. }
  33501. }
  33502. declare module BABYLON {
  33503. /**
  33504. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  33505. */
  33506. class BloomMergePostProcess extends PostProcess {
  33507. /** Weight of the bloom to be added to the original input. */
  33508. weight: number;
  33509. /**
  33510. * Creates a new instance of @see BloomMergePostProcess
  33511. * @param name The name of the effect.
  33512. * @param originalFromInput Post process which's input will be used for the merge.
  33513. * @param blurred Blurred highlights post process which's output will be used.
  33514. * @param weight Weight of the bloom to be added to the original input.
  33515. * @param options The required width/height ratio to downsize to before computing the render pass.
  33516. * @param camera The camera to apply the render pass to.
  33517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33518. * @param engine The engine which the post process will be applied. (default: current engine)
  33519. * @param reusable If the post process can be reused on the same frame. (default: false)
  33520. * @param textureType Type of textures used when performing the post process. (default: 0)
  33521. * @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)
  33522. */
  33523. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  33524. /** Weight of the bloom to be added to the original input. */
  33525. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33526. }
  33527. }
  33528. declare module BABYLON {
  33529. /**
  33530. * The Blur Post Process which blurs an image based on a kernel and direction.
  33531. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  33532. */
  33533. class BlurPostProcess extends PostProcess {
  33534. /** The direction in which to blur the image. */
  33535. direction: Vector2;
  33536. private blockCompilation;
  33537. protected _kernel: number;
  33538. protected _idealKernel: number;
  33539. protected _packedFloat: boolean;
  33540. private _staticDefines;
  33541. /**
  33542. * Sets the length in pixels of the blur sample region
  33543. */
  33544. /**
  33545. * Gets the length in pixels of the blur sample region
  33546. */
  33547. kernel: number;
  33548. /**
  33549. * Sets wether or not the blur needs to unpack/repack floats
  33550. */
  33551. /**
  33552. * Gets wether or not the blur is unpacking/repacking floats
  33553. */
  33554. packedFloat: boolean;
  33555. /**
  33556. * Creates a new instance BlurPostProcess
  33557. * @param name The name of the effect.
  33558. * @param direction The direction in which to blur the image.
  33559. * @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.
  33560. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  33561. * @param camera The camera to apply the render pass to.
  33562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33563. * @param engine The engine which the post process will be applied. (default: current engine)
  33564. * @param reusable If the post process can be reused on the same frame. (default: false)
  33565. * @param textureType Type of textures used when performing the post process. (default: 0)
  33566. * @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)
  33567. */
  33568. constructor(name: string,
  33569. /** The direction in which to blur the image. */
  33570. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  33571. /**
  33572. * Updates the effect with the current post process compile time values and recompiles the shader.
  33573. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  33574. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  33575. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  33576. * @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
  33577. * @param onCompiled Called when the shader has been compiled.
  33578. * @param onError Called if there is an error when compiling a shader.
  33579. */
  33580. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  33581. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  33582. /**
  33583. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  33584. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  33585. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  33586. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  33587. * The gaps between physical kernels are compensated for in the weighting of the samples
  33588. * @param idealKernel Ideal blur kernel.
  33589. * @return Nearest best kernel.
  33590. */
  33591. protected _nearestBestKernel(idealKernel: number): number;
  33592. /**
  33593. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  33594. * @param x The point on the Gaussian distribution to sample.
  33595. * @return the value of the Gaussian function at x.
  33596. */
  33597. protected _gaussianWeight(x: number): number;
  33598. /**
  33599. * Generates a string that can be used as a floating point number in GLSL.
  33600. * @param x Value to print.
  33601. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  33602. * @return GLSL float string.
  33603. */
  33604. protected _glslFloat(x: number, decimalFigures?: number): string;
  33605. }
  33606. }
  33607. declare module BABYLON {
  33608. /**
  33609. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  33610. */
  33611. class ChromaticAberrationPostProcess extends PostProcess {
  33612. /**
  33613. * The amount of seperation of rgb channels (default: 30)
  33614. */
  33615. aberrationAmount: number;
  33616. /**
  33617. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  33618. */
  33619. radialIntensity: number;
  33620. /**
  33621. * 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))
  33622. */
  33623. direction: Vector2;
  33624. /**
  33625. * 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))
  33626. */
  33627. centerPosition: Vector2;
  33628. /**
  33629. * Creates a new instance ChromaticAberrationPostProcess
  33630. * @param name The name of the effect.
  33631. * @param screenWidth The width of the screen to apply the effect on.
  33632. * @param screenHeight The height of the screen to apply the effect on.
  33633. * @param options The required width/height ratio to downsize to before computing the render pass.
  33634. * @param camera The camera to apply the render pass to.
  33635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33636. * @param engine The engine which the post process will be applied. (default: current engine)
  33637. * @param reusable If the post process can be reused on the same frame. (default: false)
  33638. * @param textureType Type of textures used when performing the post process. (default: 0)
  33639. * @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)
  33640. */
  33641. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33642. }
  33643. }
  33644. declare module BABYLON {
  33645. /**
  33646. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  33647. */
  33648. class CircleOfConfusionPostProcess extends PostProcess {
  33649. /**
  33650. * 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.
  33651. */
  33652. lensSize: number;
  33653. /**
  33654. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  33655. */
  33656. fStop: number;
  33657. /**
  33658. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  33659. */
  33660. focusDistance: number;
  33661. /**
  33662. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  33663. */
  33664. focalLength: number;
  33665. private _depthTexture;
  33666. /**
  33667. * Creates a new instance CircleOfConfusionPostProcess
  33668. * @param name The name of the effect.
  33669. * @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.
  33670. * @param options The required width/height ratio to downsize to before computing the render pass.
  33671. * @param camera The camera to apply the render pass to.
  33672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33673. * @param engine The engine which the post process will be applied. (default: current engine)
  33674. * @param reusable If the post process can be reused on the same frame. (default: false)
  33675. * @param textureType Type of textures used when performing the post process. (default: 0)
  33676. * @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)
  33677. */
  33678. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33679. /**
  33680. * 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.
  33681. */
  33682. depthTexture: RenderTargetTexture;
  33683. }
  33684. }
  33685. declare module BABYLON {
  33686. /**
  33687. *
  33688. * This post-process allows the modification of rendered colors by using
  33689. * a 'look-up table' (LUT). This effect is also called Color Grading.
  33690. *
  33691. * The object needs to be provided an url to a texture containing the color
  33692. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  33693. * Use an image editing software to tweak the LUT to match your needs.
  33694. *
  33695. * For an example of a color LUT, see here:
  33696. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  33697. * For explanations on color grading, see here:
  33698. * @see http://udn.epicgames.com/Three/ColorGrading.html
  33699. *
  33700. */
  33701. class ColorCorrectionPostProcess extends PostProcess {
  33702. private _colorTableTexture;
  33703. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33704. }
  33705. }
  33706. declare module BABYLON {
  33707. /**
  33708. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  33709. * input texture to perform effects such as edge detection or sharpening
  33710. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  33711. */
  33712. class ConvolutionPostProcess extends PostProcess {
  33713. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  33714. kernel: number[];
  33715. /**
  33716. * Creates a new instance ConvolutionPostProcess
  33717. * @param name The name of the effect.
  33718. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  33719. * @param options The required width/height ratio to downsize to before computing the render pass.
  33720. * @param camera The camera to apply the render pass to.
  33721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33722. * @param engine The engine which the post process will be applied. (default: current engine)
  33723. * @param reusable If the post process can be reused on the same frame. (default: false)
  33724. * @param textureType Type of textures used when performing the post process. (default: 0)
  33725. */
  33726. constructor(name: string,
  33727. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  33728. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  33729. /**
  33730. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  33731. */
  33732. static EdgeDetect0Kernel: number[];
  33733. /**
  33734. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  33735. */
  33736. static EdgeDetect1Kernel: number[];
  33737. /**
  33738. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  33739. */
  33740. static EdgeDetect2Kernel: number[];
  33741. /**
  33742. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  33743. */
  33744. static SharpenKernel: number[];
  33745. /**
  33746. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  33747. */
  33748. static EmbossKernel: number[];
  33749. /**
  33750. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  33751. */
  33752. static GaussianKernel: number[];
  33753. }
  33754. }
  33755. declare module BABYLON {
  33756. /**
  33757. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  33758. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  33759. * based on samples that have a large difference in distance than the center pixel.
  33760. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  33761. */
  33762. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  33763. direction: Vector2;
  33764. /**
  33765. * Creates a new instance CircleOfConfusionPostProcess
  33766. * @param name The name of the effect.
  33767. * @param scene The scene the effect belongs to.
  33768. * @param direction The direction the blur should be applied.
  33769. * @param kernel The size of the kernel used to blur.
  33770. * @param options The required width/height ratio to downsize to before computing the render pass.
  33771. * @param camera The camera to apply the render pass to.
  33772. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  33773. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  33774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33775. * @param engine The engine which the post process will be applied. (default: current engine)
  33776. * @param reusable If the post process can be reused on the same frame. (default: false)
  33777. * @param textureType Type of textures used when performing the post process. (default: 0)
  33778. * @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)
  33779. */
  33780. 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);
  33781. }
  33782. }
  33783. declare module BABYLON {
  33784. /**
  33785. * Specifies the level of max blur that should be applied when using the depth of field effect
  33786. */
  33787. enum DepthOfFieldEffectBlurLevel {
  33788. /**
  33789. * Subtle blur
  33790. */
  33791. Low = 0,
  33792. /**
  33793. * Medium blur
  33794. */
  33795. Medium = 1,
  33796. /**
  33797. * Large blur
  33798. */
  33799. High = 2
  33800. }
  33801. /**
  33802. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  33803. */
  33804. class DepthOfFieldEffect extends PostProcessRenderEffect {
  33805. private _circleOfConfusion;
  33806. /**
  33807. * @hidden Internal, blurs from high to low
  33808. */
  33809. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  33810. private _depthOfFieldBlurY;
  33811. private _dofMerge;
  33812. /**
  33813. * @hidden Internal post processes in depth of field effect
  33814. */
  33815. _effects: Array<PostProcess>;
  33816. /**
  33817. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  33818. */
  33819. focalLength: number;
  33820. /**
  33821. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  33822. */
  33823. fStop: number;
  33824. /**
  33825. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  33826. */
  33827. focusDistance: number;
  33828. /**
  33829. * 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.
  33830. */
  33831. lensSize: number;
  33832. /**
  33833. * Creates a new instance DepthOfFieldEffect
  33834. * @param scene The scene the effect belongs to.
  33835. * @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.
  33836. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  33837. * @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)
  33838. */
  33839. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  33840. /**
  33841. * 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.
  33842. */
  33843. depthTexture: RenderTargetTexture;
  33844. /**
  33845. * Disposes each of the internal effects for a given camera.
  33846. * @param camera The camera to dispose the effect on.
  33847. */
  33848. disposeEffects(camera: Camera): void;
  33849. /**
  33850. * @hidden Internal
  33851. */
  33852. _updateEffects(): void;
  33853. /**
  33854. * Internal
  33855. * @returns if all the contained post processes are ready.
  33856. * @hidden
  33857. */
  33858. _isReady(): boolean;
  33859. }
  33860. }
  33861. declare module BABYLON {
  33862. /**
  33863. * Options to be set when merging outputs from the default pipeline.
  33864. */
  33865. class DepthOfFieldMergePostProcessOptions {
  33866. /**
  33867. * The original image to merge on top of
  33868. */
  33869. originalFromInput: PostProcess;
  33870. /**
  33871. * Parameters to perform the merge of the depth of field effect
  33872. */
  33873. depthOfField?: {
  33874. circleOfConfusion: PostProcess;
  33875. blurSteps: Array<PostProcess>;
  33876. };
  33877. /**
  33878. * Parameters to perform the merge of bloom effect
  33879. */
  33880. bloom?: {
  33881. blurred: PostProcess;
  33882. weight: number;
  33883. };
  33884. }
  33885. /**
  33886. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  33887. */
  33888. class DepthOfFieldMergePostProcess extends PostProcess {
  33889. private blurSteps;
  33890. /**
  33891. * Creates a new instance of DepthOfFieldMergePostProcess
  33892. * @param name The name of the effect.
  33893. * @param originalFromInput Post process which's input will be used for the merge.
  33894. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  33895. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  33896. * @param options The required width/height ratio to downsize to before computing the render pass.
  33897. * @param camera The camera to apply the render pass to.
  33898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33899. * @param engine The engine which the post process will be applied. (default: current engine)
  33900. * @param reusable If the post process can be reused on the same frame. (default: false)
  33901. * @param textureType Type of textures used when performing the post process. (default: 0)
  33902. * @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)
  33903. */
  33904. 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);
  33905. /**
  33906. * Updates the effect with the current post process compile time values and recompiles the shader.
  33907. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  33908. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  33909. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  33910. * @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
  33911. * @param onCompiled Called when the shader has been compiled.
  33912. * @param onError Called if there is an error when compiling a shader.
  33913. */
  33914. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  33915. }
  33916. }
  33917. declare module BABYLON {
  33918. /**
  33919. * DisplayPassPostProcess which produces an output the same as it's input
  33920. */
  33921. class DisplayPassPostProcess extends PostProcess {
  33922. /**
  33923. * Creates the DisplayPassPostProcess
  33924. * @param name The name of the effect.
  33925. * @param options The required width/height ratio to downsize to before computing the render pass.
  33926. * @param camera The camera to apply the render pass to.
  33927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33928. * @param engine The engine which the post process will be applied. (default: current engine)
  33929. * @param reusable If the post process can be reused on the same frame. (default: false)
  33930. */
  33931. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33932. }
  33933. }
  33934. declare module BABYLON {
  33935. /**
  33936. * 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.
  33937. */
  33938. class ExtractHighlightsPostProcess extends PostProcess {
  33939. /**
  33940. * The luminance threshold, pixels below this value will be set to black.
  33941. */
  33942. threshold: number;
  33943. /** @hidden */
  33944. _exposure: number;
  33945. /**
  33946. * Post process which has the input texture to be used when performing highlight extraction
  33947. * @hidden
  33948. */
  33949. _inputPostProcess: Nullable<PostProcess>;
  33950. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33951. }
  33952. }
  33953. declare module BABYLON {
  33954. /**
  33955. * Applies a kernel filter to the image
  33956. */
  33957. class FilterPostProcess extends PostProcess {
  33958. /** The matrix to be applied to the image */
  33959. kernelMatrix: Matrix;
  33960. /**
  33961. *
  33962. * @param name The name of the effect.
  33963. * @param kernelMatrix The matrix to be applied to the image
  33964. * @param options The required width/height ratio to downsize to before computing the render pass.
  33965. * @param camera The camera to apply the render pass to.
  33966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33967. * @param engine The engine which the post process will be applied. (default: current engine)
  33968. * @param reusable If the post process can be reused on the same frame. (default: false)
  33969. */
  33970. constructor(name: string,
  33971. /** The matrix to be applied to the image */
  33972. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33973. }
  33974. }
  33975. declare module BABYLON {
  33976. /**
  33977. * Fxaa post process
  33978. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  33979. */
  33980. class FxaaPostProcess extends PostProcess {
  33981. /** @hidden */
  33982. texelWidth: number;
  33983. /** @hidden */
  33984. texelHeight: number;
  33985. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  33986. private _getDefines;
  33987. }
  33988. }
  33989. declare module BABYLON {
  33990. /**
  33991. * The GrainPostProcess adds noise to the image at mid luminance levels
  33992. */
  33993. class GrainPostProcess extends PostProcess {
  33994. /**
  33995. * The intensity of the grain added (default: 30)
  33996. */
  33997. intensity: number;
  33998. /**
  33999. * If the grain should be randomized on every frame
  34000. */
  34001. animated: boolean;
  34002. /**
  34003. * Creates a new instance of @see GrainPostProcess
  34004. * @param name The name of the effect.
  34005. * @param options The required width/height ratio to downsize to before computing the render pass.
  34006. * @param camera The camera to apply the render pass to.
  34007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34008. * @param engine The engine which the post process will be applied. (default: current engine)
  34009. * @param reusable If the post process can be reused on the same frame. (default: false)
  34010. * @param textureType Type of textures used when performing the post process. (default: 0)
  34011. * @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)
  34012. */
  34013. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34014. }
  34015. }
  34016. declare module BABYLON {
  34017. /**
  34018. * Extracts highlights from the image
  34019. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34020. */
  34021. class HighlightsPostProcess extends PostProcess {
  34022. /**
  34023. * Extracts highlights from the image
  34024. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34025. * @param name The name of the effect.
  34026. * @param options The required width/height ratio to downsize to before computing the render pass.
  34027. * @param camera The camera to apply the render pass to.
  34028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34029. * @param engine The engine which the post process will be applied. (default: current engine)
  34030. * @param reusable If the post process can be reused on the same frame. (default: false)
  34031. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  34032. */
  34033. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34034. }
  34035. }
  34036. declare module BABYLON {
  34037. /**
  34038. * ImageProcessingPostProcess
  34039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  34040. */
  34041. class ImageProcessingPostProcess extends PostProcess {
  34042. /**
  34043. * Default configuration related to image processing available in the PBR Material.
  34044. */
  34045. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34046. /**
  34047. * Gets the image processing configuration used either in this material.
  34048. */
  34049. /**
  34050. * Sets the Default image processing configuration used either in the this material.
  34051. *
  34052. * If sets to null, the scene one is in use.
  34053. */
  34054. imageProcessingConfiguration: ImageProcessingConfiguration;
  34055. /**
  34056. * Keep track of the image processing observer to allow dispose and replace.
  34057. */
  34058. private _imageProcessingObserver;
  34059. /**
  34060. * Attaches a new image processing configuration to the PBR Material.
  34061. * @param configuration
  34062. */
  34063. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  34064. /**
  34065. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34066. */
  34067. /**
  34068. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34069. */
  34070. colorCurves: Nullable<ColorCurves>;
  34071. /**
  34072. * Gets wether the color curves effect is enabled.
  34073. */
  34074. /**
  34075. * Sets wether the color curves effect is enabled.
  34076. */
  34077. colorCurvesEnabled: boolean;
  34078. /**
  34079. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34080. */
  34081. /**
  34082. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34083. */
  34084. colorGradingTexture: Nullable<BaseTexture>;
  34085. /**
  34086. * Gets wether the color grading effect is enabled.
  34087. */
  34088. /**
  34089. * Gets wether the color grading effect is enabled.
  34090. */
  34091. colorGradingEnabled: boolean;
  34092. /**
  34093. * Gets exposure used in the effect.
  34094. */
  34095. /**
  34096. * Sets exposure used in the effect.
  34097. */
  34098. exposure: number;
  34099. /**
  34100. * Gets wether tonemapping is enabled or not.
  34101. */
  34102. /**
  34103. * Sets wether tonemapping is enabled or not
  34104. */
  34105. toneMappingEnabled: boolean;
  34106. /**
  34107. * Gets contrast used in the effect.
  34108. */
  34109. /**
  34110. * Sets contrast used in the effect.
  34111. */
  34112. contrast: number;
  34113. /**
  34114. * Gets Vignette stretch size.
  34115. */
  34116. /**
  34117. * Sets Vignette stretch size.
  34118. */
  34119. vignetteStretch: number;
  34120. /**
  34121. * Gets Vignette centre X Offset.
  34122. */
  34123. /**
  34124. * Sets Vignette centre X Offset.
  34125. */
  34126. vignetteCentreX: number;
  34127. /**
  34128. * Gets Vignette centre Y Offset.
  34129. */
  34130. /**
  34131. * Sets Vignette centre Y Offset.
  34132. */
  34133. vignetteCentreY: number;
  34134. /**
  34135. * Gets Vignette weight or intensity of the vignette effect.
  34136. */
  34137. /**
  34138. * Sets Vignette weight or intensity of the vignette effect.
  34139. */
  34140. vignetteWeight: number;
  34141. /**
  34142. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34143. * if vignetteEnabled is set to true.
  34144. */
  34145. /**
  34146. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34147. * if vignetteEnabled is set to true.
  34148. */
  34149. vignetteColor: Color4;
  34150. /**
  34151. * Gets Camera field of view used by the Vignette effect.
  34152. */
  34153. /**
  34154. * Sets Camera field of view used by the Vignette effect.
  34155. */
  34156. vignetteCameraFov: number;
  34157. /**
  34158. * Gets the vignette blend mode allowing different kind of effect.
  34159. */
  34160. /**
  34161. * Sets the vignette blend mode allowing different kind of effect.
  34162. */
  34163. vignetteBlendMode: number;
  34164. /**
  34165. * Gets wether the vignette effect is enabled.
  34166. */
  34167. /**
  34168. * Sets wether the vignette effect is enabled.
  34169. */
  34170. vignetteEnabled: boolean;
  34171. private _fromLinearSpace;
  34172. /**
  34173. * Gets wether the input of the processing is in Gamma or Linear Space.
  34174. */
  34175. /**
  34176. * Sets wether the input of the processing is in Gamma or Linear Space.
  34177. */
  34178. fromLinearSpace: boolean;
  34179. /**
  34180. * Defines cache preventing GC.
  34181. */
  34182. private _defines;
  34183. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  34184. /**
  34185. * "ImageProcessingPostProcess"
  34186. * @returns "ImageProcessingPostProcess"
  34187. */
  34188. getClassName(): string;
  34189. protected _updateParameters(): void;
  34190. dispose(camera?: Camera): void;
  34191. }
  34192. }
  34193. declare module BABYLON {
  34194. /**
  34195. * PassPostProcess which produces an output the same as it's input
  34196. */
  34197. class PassPostProcess extends PostProcess {
  34198. /**
  34199. * Creates the PassPostProcess
  34200. * @param name The name of the effect.
  34201. * @param options The required width/height ratio to downsize to before computing the render pass.
  34202. * @param camera The camera to apply the render pass to.
  34203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34204. * @param engine The engine which the post process will be applied. (default: current engine)
  34205. * @param reusable If the post process can be reused on the same frame. (default: false)
  34206. * @param textureType The type of texture to be used when performing the post processing.
  34207. * @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)
  34208. */
  34209. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34210. }
  34211. }
  34212. declare module BABYLON {
  34213. /**
  34214. * Size options for a post process
  34215. */
  34216. type PostProcessOptions = {
  34217. width: number;
  34218. height: number;
  34219. };
  34220. /**
  34221. * PostProcess can be used to apply a shader to a texture after it has been rendered
  34222. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34223. */
  34224. class PostProcess {
  34225. /** Name of the PostProcess. */
  34226. name: string;
  34227. /**
  34228. * Width of the texture to apply the post process on
  34229. */
  34230. width: number;
  34231. /**
  34232. * Height of the texture to apply the post process on
  34233. */
  34234. height: number;
  34235. /**
  34236. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  34237. * @hidden
  34238. */
  34239. _outputTexture: Nullable<InternalTexture>;
  34240. /**
  34241. * Sampling mode used by the shader
  34242. * See https://doc.babylonjs.com/classes/3.1/texture
  34243. */
  34244. renderTargetSamplingMode: number;
  34245. /**
  34246. * Clear color to use when screen clearing
  34247. */
  34248. clearColor: Color4;
  34249. /**
  34250. * If the buffer needs to be cleared before applying the post process. (default: true)
  34251. * Should be set to false if shader will overwrite all previous pixels.
  34252. */
  34253. autoClear: boolean;
  34254. /**
  34255. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  34256. */
  34257. alphaMode: number;
  34258. /**
  34259. * Sets the setAlphaBlendConstants of the babylon engine
  34260. */
  34261. alphaConstants: Color4;
  34262. /**
  34263. * Animations to be used for the post processing
  34264. */
  34265. animations: Animation[];
  34266. /**
  34267. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  34268. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  34269. */
  34270. enablePixelPerfectMode: boolean;
  34271. /**
  34272. * Force the postprocess to be applied without taking in account viewport
  34273. */
  34274. forceFullscreenViewport: boolean;
  34275. /**
  34276. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  34277. *
  34278. * | Value | Type | Description |
  34279. * | ----- | ----------------------------------- | ----------- |
  34280. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  34281. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  34282. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  34283. *
  34284. */
  34285. scaleMode: number;
  34286. /**
  34287. * Force textures to be a power of two (default: false)
  34288. */
  34289. alwaysForcePOT: boolean;
  34290. private _samples;
  34291. /**
  34292. * Number of sample textures (default: 1)
  34293. */
  34294. samples: number;
  34295. /**
  34296. * Modify the scale of the post process to be the same as the viewport (default: false)
  34297. */
  34298. adaptScaleToCurrentViewport: boolean;
  34299. private _camera;
  34300. private _scene;
  34301. private _engine;
  34302. private _options;
  34303. private _reusable;
  34304. private _textureType;
  34305. /**
  34306. * Smart array of input and output textures for the post process.
  34307. * @hidden
  34308. */
  34309. _textures: SmartArray<InternalTexture>;
  34310. /**
  34311. * The index in _textures that corresponds to the output texture.
  34312. * @hidden
  34313. */
  34314. _currentRenderTextureInd: number;
  34315. private _effect;
  34316. private _samplers;
  34317. private _fragmentUrl;
  34318. private _vertexUrl;
  34319. private _parameters;
  34320. private _scaleRatio;
  34321. protected _indexParameters: any;
  34322. private _shareOutputWithPostProcess;
  34323. private _texelSize;
  34324. private _forcedOutputTexture;
  34325. /**
  34326. * An event triggered when the postprocess is activated.
  34327. */
  34328. onActivateObservable: Observable<Camera>;
  34329. private _onActivateObserver;
  34330. /**
  34331. * A function that is added to the onActivateObservable
  34332. */
  34333. onActivate: Nullable<(camera: Camera) => void>;
  34334. /**
  34335. * An event triggered when the postprocess changes its size.
  34336. */
  34337. onSizeChangedObservable: Observable<PostProcess>;
  34338. private _onSizeChangedObserver;
  34339. /**
  34340. * A function that is added to the onSizeChangedObservable
  34341. */
  34342. onSizeChanged: (postProcess: PostProcess) => void;
  34343. /**
  34344. * An event triggered when the postprocess applies its effect.
  34345. */
  34346. onApplyObservable: Observable<Effect>;
  34347. private _onApplyObserver;
  34348. /**
  34349. * A function that is added to the onApplyObservable
  34350. */
  34351. onApply: (effect: Effect) => void;
  34352. /**
  34353. * An event triggered before rendering the postprocess
  34354. */
  34355. onBeforeRenderObservable: Observable<Effect>;
  34356. private _onBeforeRenderObserver;
  34357. /**
  34358. * A function that is added to the onBeforeRenderObservable
  34359. */
  34360. onBeforeRender: (effect: Effect) => void;
  34361. /**
  34362. * An event triggered after rendering the postprocess
  34363. */
  34364. onAfterRenderObservable: Observable<Effect>;
  34365. private _onAfterRenderObserver;
  34366. /**
  34367. * A function that is added to the onAfterRenderObservable
  34368. */
  34369. onAfterRender: (efect: Effect) => void;
  34370. /**
  34371. * 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
  34372. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  34373. */
  34374. inputTexture: InternalTexture;
  34375. /**
  34376. * Gets the camera which post process is applied to.
  34377. * @returns The camera the post process is applied to.
  34378. */
  34379. getCamera(): Camera;
  34380. /**
  34381. * Gets the texel size of the postprocess.
  34382. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  34383. */
  34384. readonly texelSize: Vector2;
  34385. /**
  34386. * Creates a new instance PostProcess
  34387. * @param name The name of the PostProcess.
  34388. * @param fragmentUrl The url of the fragment shader to be used.
  34389. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  34390. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  34391. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34392. * @param camera The camera to apply the render pass to.
  34393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34394. * @param engine The engine which the post process will be applied. (default: current engine)
  34395. * @param reusable If the post process can be reused on the same frame. (default: false)
  34396. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  34397. * @param textureType Type of textures used when performing the post process. (default: 0)
  34398. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  34399. * @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
  34400. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  34401. */
  34402. constructor(
  34403. /** Name of the PostProcess. */
  34404. 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);
  34405. /**
  34406. * Gets the engine which this post process belongs to.
  34407. * @returns The engine the post process was enabled with.
  34408. */
  34409. getEngine(): Engine;
  34410. /**
  34411. * The effect that is created when initializing the post process.
  34412. * @returns The created effect corrisponding the the postprocess.
  34413. */
  34414. getEffect(): Effect;
  34415. /**
  34416. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  34417. * @param postProcess The post process to share the output with.
  34418. * @returns This post process.
  34419. */
  34420. shareOutputWith(postProcess: PostProcess): PostProcess;
  34421. /**
  34422. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  34423. * This should be called if the post process that shares output with this post process is disabled/disposed.
  34424. */
  34425. useOwnOutput(): void;
  34426. /**
  34427. * Updates the effect with the current post process compile time values and recompiles the shader.
  34428. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34429. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34430. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34431. * @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
  34432. * @param onCompiled Called when the shader has been compiled.
  34433. * @param onError Called if there is an error when compiling a shader.
  34434. */
  34435. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34436. /**
  34437. * The post process is reusable if it can be used multiple times within one frame.
  34438. * @returns If the post process is reusable
  34439. */
  34440. isReusable(): boolean;
  34441. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  34442. markTextureDirty(): void;
  34443. /**
  34444. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  34445. * 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.
  34446. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  34447. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  34448. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  34449. * @returns The target texture that was bound to be written to.
  34450. */
  34451. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  34452. /**
  34453. * If the post process is supported.
  34454. */
  34455. readonly isSupported: boolean;
  34456. /**
  34457. * The aspect ratio of the output texture.
  34458. */
  34459. readonly aspectRatio: number;
  34460. /**
  34461. * Get a value indicating if the post-process is ready to be used
  34462. * @returns true if the post-process is ready (shader is compiled)
  34463. */
  34464. isReady(): boolean;
  34465. /**
  34466. * Binds all textures and uniforms to the shader, this will be run on every pass.
  34467. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  34468. */
  34469. apply(): Nullable<Effect>;
  34470. private _disposeTextures;
  34471. /**
  34472. * Disposes the post process.
  34473. * @param camera The camera to dispose the post process on.
  34474. */
  34475. dispose(camera?: Camera): void;
  34476. }
  34477. }
  34478. declare module BABYLON {
  34479. /**
  34480. * PostProcessManager is used to manage one or more post processes or post process pipelines
  34481. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34482. */
  34483. class PostProcessManager {
  34484. private _scene;
  34485. private _indexBuffer;
  34486. private _vertexBuffers;
  34487. /**
  34488. * Creates a new instance PostProcess
  34489. * @param scene The scene that the post process is associated with.
  34490. */
  34491. constructor(scene: Scene);
  34492. private _prepareBuffers;
  34493. private _buildIndexBuffer;
  34494. /**
  34495. * Rebuilds the vertex buffers of the manager.
  34496. * @hidden
  34497. */
  34498. _rebuild(): void;
  34499. /**
  34500. * Prepares a frame to be run through a post process.
  34501. * @param sourceTexture The input texture to the post procesess. (default: null)
  34502. * @param postProcesses An array of post processes to be run. (default: null)
  34503. * @returns True if the post processes were able to be run.
  34504. * @hidden
  34505. */
  34506. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  34507. /**
  34508. * Manually render a set of post processes to a texture.
  34509. * @param postProcesses An array of post processes to be run.
  34510. * @param targetTexture The target texture to render to.
  34511. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  34512. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  34513. * @param lodLevel defines which lod of the texture to render to
  34514. */
  34515. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  34516. /**
  34517. * Finalize the result of the output of the postprocesses.
  34518. * @param doNotPresent If true the result will not be displayed to the screen.
  34519. * @param targetTexture The target texture to render to.
  34520. * @param faceIndex The index of the face to bind the target texture to.
  34521. * @param postProcesses The array of post processes to render.
  34522. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  34523. * @hidden
  34524. */
  34525. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  34526. /**
  34527. * Disposes of the post process manager.
  34528. */
  34529. dispose(): void;
  34530. }
  34531. }
  34532. declare module BABYLON {
  34533. /**
  34534. * Post process which applies a refractin texture
  34535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  34536. */
  34537. class RefractionPostProcess extends PostProcess {
  34538. /** the base color of the refraction (used to taint the rendering) */
  34539. color: Color3;
  34540. /** simulated refraction depth */
  34541. depth: number;
  34542. /** the coefficient of the base color (0 to remove base color tainting) */
  34543. colorLevel: number;
  34544. private _refTexture;
  34545. private _ownRefractionTexture;
  34546. /**
  34547. * Gets or sets the refraction texture
  34548. * Please note that you are responsible for disposing the texture if you set it manually
  34549. */
  34550. refractionTexture: Texture;
  34551. /**
  34552. * Initializes the RefractionPostProcess
  34553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  34554. * @param name The name of the effect.
  34555. * @param refractionTextureUrl Url of the refraction texture to use
  34556. * @param color the base color of the refraction (used to taint the rendering)
  34557. * @param depth simulated refraction depth
  34558. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  34559. * @param camera The camera to apply the render pass to.
  34560. * @param options The required width/height ratio to downsize to before computing the render pass.
  34561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34562. * @param engine The engine which the post process will be applied. (default: current engine)
  34563. * @param reusable If the post process can be reused on the same frame. (default: false)
  34564. */
  34565. constructor(name: string, refractionTextureUrl: string,
  34566. /** the base color of the refraction (used to taint the rendering) */
  34567. color: Color3,
  34568. /** simulated refraction depth */
  34569. depth: number,
  34570. /** the coefficient of the base color (0 to remove base color tainting) */
  34571. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34572. /**
  34573. * Disposes of the post process
  34574. * @param camera Camera to dispose post process on
  34575. */
  34576. dispose(camera: Camera): void;
  34577. }
  34578. }
  34579. declare module BABYLON {
  34580. /**
  34581. * The SharpenPostProcess applies a sharpen kernel to every pixel
  34582. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34583. */
  34584. class SharpenPostProcess extends PostProcess {
  34585. /**
  34586. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  34587. */
  34588. colorAmount: number;
  34589. /**
  34590. * How much sharpness should be applied (default: 0.3)
  34591. */
  34592. edgeAmount: number;
  34593. /**
  34594. * Creates a new instance ConvolutionPostProcess
  34595. * @param name The name of the effect.
  34596. * @param options The required width/height ratio to downsize to before computing the render pass.
  34597. * @param camera The camera to apply the render pass to.
  34598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34599. * @param engine The engine which the post process will be applied. (default: current engine)
  34600. * @param reusable If the post process can be reused on the same frame. (default: false)
  34601. * @param textureType Type of textures used when performing the post process. (default: 0)
  34602. * @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)
  34603. */
  34604. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34605. }
  34606. }
  34607. declare module BABYLON {
  34608. /**
  34609. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  34610. */
  34611. class StereoscopicInterlacePostProcess extends PostProcess {
  34612. private _stepSize;
  34613. private _passedProcess;
  34614. /**
  34615. * Initializes a StereoscopicInterlacePostProcess
  34616. * @param name The name of the effect.
  34617. * @param rigCameras The rig cameras to be appled to the post process
  34618. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  34619. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34620. * @param engine The engine which the post process will be applied. (default: current engine)
  34621. * @param reusable If the post process can be reused on the same frame. (default: false)
  34622. */
  34623. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34624. }
  34625. }
  34626. declare module BABYLON {
  34627. /** Defines operator used for tonemapping */
  34628. enum TonemappingOperator {
  34629. /** Hable */
  34630. Hable = 0,
  34631. /** Reinhard */
  34632. Reinhard = 1,
  34633. /** HejiDawson */
  34634. HejiDawson = 2,
  34635. /** Photographic */
  34636. Photographic = 3
  34637. }
  34638. /**
  34639. * Defines a post process to apply tone mapping
  34640. */
  34641. class TonemapPostProcess extends PostProcess {
  34642. private _operator;
  34643. /** Defines the required exposure adjustement */
  34644. exposureAdjustment: number;
  34645. /**
  34646. * Creates a new TonemapPostProcess
  34647. * @param name defines the name of the postprocess
  34648. * @param _operator defines the operator to use
  34649. * @param exposureAdjustment defines the required exposure adjustement
  34650. * @param camera defines the camera to use (can be null)
  34651. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  34652. * @param engine defines the hosting engine (can be ignore if camera is set)
  34653. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  34654. */
  34655. constructor(name: string, _operator: TonemappingOperator,
  34656. /** Defines the required exposure adjustement */
  34657. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  34658. }
  34659. }
  34660. declare module BABYLON {
  34661. /**
  34662. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  34663. */
  34664. class VolumetricLightScatteringPostProcess extends PostProcess {
  34665. private _volumetricLightScatteringPass;
  34666. private _volumetricLightScatteringRTT;
  34667. private _viewPort;
  34668. private _screenCoordinates;
  34669. private _cachedDefines;
  34670. /**
  34671. * If not undefined, the mesh position is computed from the attached node position
  34672. */
  34673. attachedNode: {
  34674. position: Vector3;
  34675. };
  34676. /**
  34677. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  34678. */
  34679. customMeshPosition: Vector3;
  34680. /**
  34681. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  34682. */
  34683. useCustomMeshPosition: boolean;
  34684. /**
  34685. * If the post-process should inverse the light scattering direction
  34686. */
  34687. invert: boolean;
  34688. /**
  34689. * The internal mesh used by the post-process
  34690. */
  34691. mesh: Mesh;
  34692. /**
  34693. * @hidden
  34694. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  34695. */
  34696. useDiffuseColor: boolean;
  34697. /**
  34698. * Array containing the excluded meshes not rendered in the internal pass
  34699. */
  34700. excludedMeshes: AbstractMesh[];
  34701. /**
  34702. * Controls the overall intensity of the post-process
  34703. */
  34704. exposure: number;
  34705. /**
  34706. * Dissipates each sample's contribution in range [0, 1]
  34707. */
  34708. decay: number;
  34709. /**
  34710. * Controls the overall intensity of each sample
  34711. */
  34712. weight: number;
  34713. /**
  34714. * Controls the density of each sample
  34715. */
  34716. density: number;
  34717. /**
  34718. * @constructor
  34719. * @param name The post-process name
  34720. * @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)
  34721. * @param camera The camera that the post-process will be attached to
  34722. * @param mesh The mesh used to create the light scattering
  34723. * @param samples The post-process quality, default 100
  34724. * @param samplingModeThe post-process filtering mode
  34725. * @param engine The babylon engine
  34726. * @param reusable If the post-process is reusable
  34727. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  34728. */
  34729. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  34730. /**
  34731. * Returns the string "VolumetricLightScatteringPostProcess"
  34732. * @returns "VolumetricLightScatteringPostProcess"
  34733. */
  34734. getClassName(): string;
  34735. private _isReady;
  34736. /**
  34737. * Sets the new light position for light scattering effect
  34738. * @param position The new custom light position
  34739. */
  34740. setCustomMeshPosition(position: Vector3): void;
  34741. /**
  34742. * Returns the light position for light scattering effect
  34743. * @return Vector3 The custom light position
  34744. */
  34745. getCustomMeshPosition(): Vector3;
  34746. /**
  34747. * Disposes the internal assets and detaches the post-process from the camera
  34748. */
  34749. dispose(camera: Camera): void;
  34750. /**
  34751. * Returns the render target texture used by the post-process
  34752. * @return the render target texture used by the post-process
  34753. */
  34754. getPass(): RenderTargetTexture;
  34755. private _meshExcluded;
  34756. private _createPass;
  34757. private _updateMeshScreenCoordinates;
  34758. /**
  34759. * Creates a default mesh for the Volumeric Light Scattering post-process
  34760. * @param name The mesh name
  34761. * @param scene The scene where to create the mesh
  34762. * @return the default mesh
  34763. */
  34764. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  34765. }
  34766. }
  34767. declare module BABYLON {
  34768. /**
  34769. * VRDistortionCorrectionPostProcess used for mobile VR
  34770. */
  34771. class VRDistortionCorrectionPostProcess extends PostProcess {
  34772. private _isRightEye;
  34773. private _distortionFactors;
  34774. private _postProcessScaleFactor;
  34775. private _lensCenterOffset;
  34776. private _scaleIn;
  34777. private _scaleFactor;
  34778. private _lensCenter;
  34779. /**
  34780. * Initializes the VRDistortionCorrectionPostProcess
  34781. * @param name The name of the effect.
  34782. * @param camera The camera to apply the render pass to.
  34783. * @param isRightEye If this is for the right eye distortion
  34784. * @param vrMetrics All the required metrics for the VR camera
  34785. */
  34786. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  34787. }
  34788. }
  34789. declare module BABYLON {
  34790. interface Scene {
  34791. /**
  34792. * The list of reflection probes added to the scene
  34793. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34794. */
  34795. reflectionProbes: Array<ReflectionProbe>;
  34796. }
  34797. /**
  34798. * Class used to generate realtime reflection / refraction cube textures
  34799. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34800. */
  34801. class ReflectionProbe {
  34802. /** defines the name of the probe */
  34803. name: string;
  34804. private _scene;
  34805. private _renderTargetTexture;
  34806. private _projectionMatrix;
  34807. private _viewMatrix;
  34808. private _target;
  34809. private _add;
  34810. private _attachedMesh;
  34811. private _invertYAxis;
  34812. /** Gets or sets probe position (center of the cube map) */
  34813. position: Vector3;
  34814. /**
  34815. * Creates a new reflection probe
  34816. * @param name defines the name of the probe
  34817. * @param size defines the texture resolution (for each face)
  34818. * @param scene defines the hosting scene
  34819. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34820. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34821. */
  34822. constructor(
  34823. /** defines the name of the probe */
  34824. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34825. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34826. samples: number;
  34827. /** Gets or sets the refresh rate to use (on every frame by default) */
  34828. refreshRate: number;
  34829. /**
  34830. * Gets the hosting scene
  34831. * @returns a Scene
  34832. */
  34833. getScene(): Scene;
  34834. /** Gets the internal CubeTexture used to render to */
  34835. readonly cubeTexture: RenderTargetTexture;
  34836. /** Gets the list of meshes to render */
  34837. readonly renderList: Nullable<AbstractMesh[]>;
  34838. /**
  34839. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34840. * @param mesh defines the mesh to attach to
  34841. */
  34842. attachToMesh(mesh: AbstractMesh): void;
  34843. /**
  34844. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34845. * @param renderingGroupId The rendering group id corresponding to its index
  34846. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34847. */
  34848. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34849. /**
  34850. * Clean all associated resources
  34851. */
  34852. dispose(): void;
  34853. }
  34854. }
  34855. declare module BABYLON {
  34856. interface Scene {
  34857. /** @hidden (Backing field) */
  34858. _boundingBoxRenderer: BoundingBoxRenderer;
  34859. /** @hidden (Backing field) */
  34860. _forceShowBoundingBoxes: boolean;
  34861. /**
  34862. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  34863. */
  34864. forceShowBoundingBoxes: boolean;
  34865. /**
  34866. * Gets the bounding box renderer associated with the scene
  34867. * @returns a BoundingBoxRenderer
  34868. */
  34869. getBoundingBoxRenderer(): BoundingBoxRenderer;
  34870. }
  34871. interface AbstractMesh {
  34872. /** @hidden (Backing field) */
  34873. _showBoundingBox: boolean;
  34874. /**
  34875. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  34876. */
  34877. showBoundingBox: boolean;
  34878. }
  34879. /**
  34880. * Component responsible of rendering the bounding box of the meshes in a scene.
  34881. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  34882. */
  34883. class BoundingBoxRenderer implements ISceneComponent {
  34884. /**
  34885. * The component name helpfull to identify the component in the list of scene components.
  34886. */
  34887. readonly name: string;
  34888. /**
  34889. * The scene the component belongs to.
  34890. */
  34891. scene: Scene;
  34892. /**
  34893. * Color of the bounding box lines placed in front of an object
  34894. */
  34895. frontColor: Color3;
  34896. /**
  34897. * Color of the bounding box lines placed behind an object
  34898. */
  34899. backColor: Color3;
  34900. /**
  34901. * Defines if the renderer should show the back lines or not
  34902. */
  34903. showBackLines: boolean;
  34904. /**
  34905. * @hidden
  34906. */
  34907. renderList: SmartArray<BoundingBox>;
  34908. private _colorShader;
  34909. private _vertexBuffers;
  34910. private _indexBuffer;
  34911. /**
  34912. * Instantiates a new bounding box renderer in a scene.
  34913. * @param scene the scene the renderer renders in
  34914. */
  34915. constructor(scene: Scene);
  34916. /**
  34917. * Registers the component in a given scene
  34918. */
  34919. register(): void;
  34920. private _evaluateSubMesh;
  34921. private _activeMesh;
  34922. private _prepareRessources;
  34923. private _createIndexBuffer;
  34924. /**
  34925. * Rebuilds the elements related to this component in case of
  34926. * context lost for instance.
  34927. */
  34928. rebuild(): void;
  34929. /**
  34930. * @hidden
  34931. */
  34932. reset(): void;
  34933. /**
  34934. * Render the bounding boxes of a specific rendering group
  34935. * @param renderingGroupId defines the rendering group to render
  34936. */
  34937. render(renderingGroupId: number): void;
  34938. /**
  34939. * In case of occlusion queries, we can render the occlusion bounding box through this method
  34940. * @param mesh Define the mesh to render the occlusion bounding box for
  34941. */
  34942. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  34943. /**
  34944. * Dispose and release the resources attached to this renderer.
  34945. */
  34946. dispose(): void;
  34947. }
  34948. }
  34949. declare module BABYLON {
  34950. /**
  34951. * This represents a depth renderer in Babylon.
  34952. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  34953. */
  34954. class DepthRenderer {
  34955. private _scene;
  34956. private _depthMap;
  34957. private _effect;
  34958. private _cachedDefines;
  34959. private _camera;
  34960. /**
  34961. * Specifiess that the depth renderer will only be used within
  34962. * the camera it is created for.
  34963. * This can help forcing its rendering during the camera processing.
  34964. */
  34965. useOnlyInActiveCamera: boolean;
  34966. /**
  34967. * Instantiates a depth renderer
  34968. * @param scene The scene the renderer belongs to
  34969. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  34970. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  34971. */
  34972. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  34973. /**
  34974. * Creates the depth rendering effect and checks if the effect is ready.
  34975. * @param subMesh The submesh to be used to render the depth map of
  34976. * @param useInstances If multiple world instances should be used
  34977. * @returns if the depth renderer is ready to render the depth map
  34978. */
  34979. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34980. /**
  34981. * Gets the texture which the depth map will be written to.
  34982. * @returns The depth map texture
  34983. */
  34984. getDepthMap(): RenderTargetTexture;
  34985. /**
  34986. * Disposes of the depth renderer.
  34987. */
  34988. dispose(): void;
  34989. }
  34990. }
  34991. declare module BABYLON {
  34992. interface Scene {
  34993. /** @hidden (Backing field) */
  34994. _depthRenderer: {
  34995. [id: string]: DepthRenderer;
  34996. };
  34997. /**
  34998. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  34999. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  35000. * @returns the created depth renderer
  35001. */
  35002. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  35003. /**
  35004. * Disables a depth renderer for a given camera
  35005. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  35006. */
  35007. disableDepthRenderer(camera?: Nullable<Camera>): void;
  35008. }
  35009. /**
  35010. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  35011. * in several rendering techniques.
  35012. */
  35013. class DepthRendererSceneComponent implements ISceneComponent {
  35014. /**
  35015. * The component name helpfull to identify the component in the list of scene components.
  35016. */
  35017. readonly name: string;
  35018. /**
  35019. * The scene the component belongs to.
  35020. */
  35021. scene: Scene;
  35022. /**
  35023. * Creates a new instance of the component for the given scene
  35024. * @param scene Defines the scene to register the component in
  35025. */
  35026. constructor(scene: Scene);
  35027. /**
  35028. * Registers the component in a given scene
  35029. */
  35030. register(): void;
  35031. /**
  35032. * Rebuilds the elements related to this component in case of
  35033. * context lost for instance.
  35034. */
  35035. rebuild(): void;
  35036. /**
  35037. * Disposes the component and the associated ressources
  35038. */
  35039. dispose(): void;
  35040. private _gatherRenderTargets;
  35041. private _gatherActiveCameraRenderTargets;
  35042. }
  35043. }
  35044. declare module BABYLON {
  35045. interface AbstractMesh {
  35046. /**
  35047. * Disables the mesh edge rendering mode
  35048. * @returns the currentAbstractMesh
  35049. */
  35050. disableEdgesRendering(): AbstractMesh;
  35051. /**
  35052. * Enables the edge rendering mode on the mesh.
  35053. * This mode makes the mesh edges visible
  35054. * @param epsilon defines the maximal distance between two angles to detect a face
  35055. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35056. * @returns the currentAbstractMesh
  35057. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35058. */
  35059. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35060. /**
  35061. * Gets the edgesRenderer associated with the mesh
  35062. */
  35063. edgesRenderer: Nullable<EdgesRenderer>;
  35064. }
  35065. interface LinesMesh {
  35066. /**
  35067. * Enables the edge rendering mode on the mesh.
  35068. * This mode makes the mesh edges visible
  35069. * @param epsilon defines the maximal distance between two angles to detect a face
  35070. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35071. * @returns the currentAbstractMesh
  35072. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35073. */
  35074. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35075. }
  35076. /**
  35077. * Defines the minimum contract an Edges renderer should follow.
  35078. */
  35079. interface IEdgesRenderer extends IDisposable {
  35080. /**
  35081. * Gets or sets a boolean indicating if the edgesRenderer is active
  35082. */
  35083. isEnabled: boolean;
  35084. /**
  35085. * Renders the edges of the attached mesh,
  35086. */
  35087. render(): void;
  35088. /**
  35089. * Checks wether or not the edges renderer is ready to render.
  35090. * @return true if ready, otherwise false.
  35091. */
  35092. isReady(): boolean;
  35093. }
  35094. /**
  35095. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  35096. */
  35097. class EdgesRenderer implements IEdgesRenderer {
  35098. /**
  35099. * Define the size of the edges with an orthographic camera
  35100. */
  35101. edgesWidthScalerForOrthographic: number;
  35102. /**
  35103. * Define the size of the edges with a perspective camera
  35104. */
  35105. edgesWidthScalerForPerspective: number;
  35106. protected _source: AbstractMesh;
  35107. protected _linesPositions: number[];
  35108. protected _linesNormals: number[];
  35109. protected _linesIndices: number[];
  35110. protected _epsilon: number;
  35111. protected _indicesCount: number;
  35112. protected _lineShader: ShaderMaterial;
  35113. protected _ib: WebGLBuffer;
  35114. protected _buffers: {
  35115. [key: string]: Nullable<VertexBuffer>;
  35116. };
  35117. protected _checkVerticesInsteadOfIndices: boolean;
  35118. private _meshRebuildObserver;
  35119. private _meshDisposeObserver;
  35120. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  35121. isEnabled: boolean;
  35122. /**
  35123. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  35124. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  35125. * @param source Mesh used to create edges
  35126. * @param epsilon sum of angles in adjacency to check for edge
  35127. * @param checkVerticesInsteadOfIndices
  35128. * @param generateEdgesLines - should generate Lines or only prepare resources.
  35129. */
  35130. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  35131. protected _prepareRessources(): void;
  35132. /** @hidden */
  35133. _rebuild(): void;
  35134. /**
  35135. * Releases the required resources for the edges renderer
  35136. */
  35137. dispose(): void;
  35138. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  35139. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  35140. /**
  35141. * Checks if the pair of p0 and p1 is en edge
  35142. * @param faceIndex
  35143. * @param edge
  35144. * @param faceNormals
  35145. * @param p0
  35146. * @param p1
  35147. * @private
  35148. */
  35149. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  35150. /**
  35151. * Generates lines edges from adjacencjes
  35152. * @private
  35153. */
  35154. _generateEdgesLines(): void;
  35155. /**
  35156. * Checks wether or not the edges renderer is ready to render.
  35157. * @return true if ready, otherwise false.
  35158. */
  35159. isReady(): boolean;
  35160. /**
  35161. * Renders the edges of the attached mesh,
  35162. */
  35163. render(): void;
  35164. }
  35165. }
  35166. declare module BABYLON {
  35167. /**
  35168. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  35169. */
  35170. class GeometryBufferRenderer {
  35171. private _scene;
  35172. private _multiRenderTarget;
  35173. private _ratio;
  35174. private _enablePosition;
  35175. protected _effect: Effect;
  35176. protected _cachedDefines: string;
  35177. /**
  35178. * Set the render list (meshes to be rendered) used in the G buffer.
  35179. */
  35180. renderList: Mesh[];
  35181. /**
  35182. * Gets wether or not G buffer are supported by the running hardware.
  35183. * This requires draw buffer supports
  35184. */
  35185. readonly isSupported: boolean;
  35186. /**
  35187. * Gets wether or not position are enabled for the G buffer.
  35188. */
  35189. /**
  35190. * Sets wether or not position are enabled for the G buffer.
  35191. */
  35192. enablePosition: boolean;
  35193. /**
  35194. * Gets the scene associated with the buffer.
  35195. */
  35196. readonly scene: Scene;
  35197. /**
  35198. * Gets the ratio used by the buffer during its creation.
  35199. * How big is the buffer related to the main canvas.
  35200. */
  35201. readonly ratio: number;
  35202. /**
  35203. * Creates a new G Buffer for the scene
  35204. * @param scene The scene the buffer belongs to
  35205. * @param ratio How big is the buffer related to the main canvas.
  35206. */
  35207. constructor(scene: Scene, ratio?: number);
  35208. /**
  35209. * Checks wether everything is ready to render a submesh to the G buffer.
  35210. * @param subMesh the submesh to check readiness for
  35211. * @param useInstances is the mesh drawn using instance or not
  35212. * @returns true if ready otherwise false
  35213. */
  35214. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35215. /**
  35216. * Gets the current underlying G Buffer.
  35217. * @returns the buffer
  35218. */
  35219. getGBuffer(): MultiRenderTarget;
  35220. /**
  35221. * Gets the number of samples used to render the buffer (anti aliasing).
  35222. */
  35223. /**
  35224. * Sets the number of samples used to render the buffer (anti aliasing).
  35225. */
  35226. samples: number;
  35227. /**
  35228. * Disposes the renderer and frees up associated resources.
  35229. */
  35230. dispose(): void;
  35231. protected _createRenderTargets(): void;
  35232. }
  35233. }
  35234. declare module BABYLON {
  35235. interface Scene {
  35236. /** @hidden (Backing field) */
  35237. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35238. /**
  35239. * Gets or Sets the current geometry buffer associated to the scene.
  35240. */
  35241. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35242. /**
  35243. * Enables a GeometryBufferRender and associates it with the scene
  35244. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  35245. * @returns the GeometryBufferRenderer
  35246. */
  35247. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  35248. /**
  35249. * Disables the GeometryBufferRender associated with the scene
  35250. */
  35251. disableGeometryBufferRenderer(): void;
  35252. }
  35253. /**
  35254. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  35255. * in several rendering techniques.
  35256. */
  35257. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  35258. /**
  35259. * The component name helpful to identify the component in the list of scene components.
  35260. */
  35261. readonly name: string;
  35262. /**
  35263. * The scene the component belongs to.
  35264. */
  35265. scene: Scene;
  35266. /**
  35267. * Creates a new instance of the component for the given scene
  35268. * @param scene Defines the scene to register the component in
  35269. */
  35270. constructor(scene: Scene);
  35271. /**
  35272. * Registers the component in a given scene
  35273. */
  35274. register(): void;
  35275. /**
  35276. * Rebuilds the elements related to this component in case of
  35277. * context lost for instance.
  35278. */
  35279. rebuild(): void;
  35280. /**
  35281. * Disposes the component and the associated ressources
  35282. */
  35283. dispose(): void;
  35284. private _gatherRenderTargets;
  35285. }
  35286. }
  35287. declare module BABYLON {
  35288. /**
  35289. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  35290. */
  35291. class LineEdgesRenderer extends EdgesRenderer {
  35292. /**
  35293. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  35294. * @param source LineMesh used to generate edges
  35295. * @param epsilon not important (specified angle for edge detection)
  35296. * @param checkVerticesInsteadOfIndices not important for LineMesh
  35297. */
  35298. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  35299. /**
  35300. * Always create the edge since its a line so only important things are p0 and p1
  35301. * @param faceIndex not important for LineMesh
  35302. * @param edge not important for LineMesh
  35303. * @param faceNormals not important for LineMesh
  35304. * @param p0 beginnig of line
  35305. * @param p1 end of line
  35306. */
  35307. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  35308. /**
  35309. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  35310. */
  35311. _generateEdgesLines(): void;
  35312. }
  35313. }
  35314. declare module BABYLON {
  35315. interface Scene {
  35316. /** @hidden */
  35317. _outlineRenderer: OutlineRenderer;
  35318. /**
  35319. * Gets the outline renderer associated with the scene
  35320. * @returns a OutlineRenderer
  35321. */
  35322. getOutlineRenderer(): OutlineRenderer;
  35323. }
  35324. interface AbstractMesh {
  35325. /** @hidden (Backing field) */
  35326. _renderOutline: boolean;
  35327. /**
  35328. * Gets or sets a boolean indicating if the outline must be rendered as well
  35329. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  35330. */
  35331. renderOutline: boolean;
  35332. /** @hidden (Backing field) */
  35333. _renderOverlay: boolean;
  35334. /**
  35335. * Gets or sets a boolean indicating if the overlay must be rendered as well
  35336. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  35337. */
  35338. renderOverlay: boolean;
  35339. }
  35340. /**
  35341. * This class is responsible to draw bothe outline/overlay of meshes.
  35342. * It should not be used directly but through the available method on mesh.
  35343. */
  35344. class OutlineRenderer implements ISceneComponent {
  35345. /**
  35346. * The name of the component. Each component must have a unique name.
  35347. */
  35348. name: string;
  35349. /**
  35350. * The scene the component belongs to.
  35351. */
  35352. scene: Scene;
  35353. /**
  35354. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  35355. */
  35356. zOffset: number;
  35357. private _engine;
  35358. private _effect;
  35359. private _cachedDefines;
  35360. private _savedDepthWrite;
  35361. /**
  35362. * Instantiates a new outline renderer. (There could be only one per scene).
  35363. * @param scene Defines the scene it belongs to
  35364. */
  35365. constructor(scene: Scene);
  35366. /**
  35367. * Register the component to one instance of a scene.
  35368. */
  35369. register(): void;
  35370. /**
  35371. * Rebuilds the elements related to this component in case of
  35372. * context lost for instance.
  35373. */
  35374. rebuild(): void;
  35375. /**
  35376. * Disposes the component and the associated ressources.
  35377. */
  35378. dispose(): void;
  35379. /**
  35380. * Renders the outline in the canvas.
  35381. * @param subMesh Defines the sumesh to render
  35382. * @param batch Defines the batch of meshes in case of instances
  35383. * @param useOverlay Defines if the rendering is for the overlay or the outline
  35384. */
  35385. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  35386. /**
  35387. * Returns whether or not the outline renderer is ready for a given submesh.
  35388. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  35389. * @param subMesh Defines the submesh to check readyness for
  35390. * @param useInstances Defines wheter wee are trying to render instances or not
  35391. * @returns true if ready otherwise false
  35392. */
  35393. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35394. private _beforeRenderingMesh;
  35395. private _afterRenderingMesh;
  35396. }
  35397. }
  35398. declare module BABYLON {
  35399. /**
  35400. * This represents the object necessary to create a rendering group.
  35401. * This is exclusively used and created by the rendering manager.
  35402. * To modify the behavior, you use the available helpers in your scene or meshes.
  35403. * @hidden
  35404. */
  35405. class RenderingGroup {
  35406. index: number;
  35407. private _scene;
  35408. private _opaqueSubMeshes;
  35409. private _transparentSubMeshes;
  35410. private _alphaTestSubMeshes;
  35411. private _depthOnlySubMeshes;
  35412. private _particleSystems;
  35413. private _spriteManagers;
  35414. private _opaqueSortCompareFn;
  35415. private _alphaTestSortCompareFn;
  35416. private _transparentSortCompareFn;
  35417. private _renderOpaque;
  35418. private _renderAlphaTest;
  35419. private _renderTransparent;
  35420. private _edgesRenderers;
  35421. onBeforeTransparentRendering: () => void;
  35422. /**
  35423. * Set the opaque sort comparison function.
  35424. * If null the sub meshes will be render in the order they were created
  35425. */
  35426. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35427. /**
  35428. * Set the alpha test sort comparison function.
  35429. * If null the sub meshes will be render in the order they were created
  35430. */
  35431. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35432. /**
  35433. * Set the transparent sort comparison function.
  35434. * If null the sub meshes will be render in the order they were created
  35435. */
  35436. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35437. /**
  35438. * Creates a new rendering group.
  35439. * @param index The rendering group index
  35440. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  35441. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  35442. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  35443. */
  35444. 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>);
  35445. /**
  35446. * Render all the sub meshes contained in the group.
  35447. * @param customRenderFunction Used to override the default render behaviour of the group.
  35448. * @returns true if rendered some submeshes.
  35449. */
  35450. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  35451. /**
  35452. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  35453. * @param subMeshes The submeshes to render
  35454. */
  35455. private renderOpaqueSorted;
  35456. /**
  35457. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  35458. * @param subMeshes The submeshes to render
  35459. */
  35460. private renderAlphaTestSorted;
  35461. /**
  35462. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  35463. * @param subMeshes The submeshes to render
  35464. */
  35465. private renderTransparentSorted;
  35466. /**
  35467. * Renders the submeshes in a specified order.
  35468. * @param subMeshes The submeshes to sort before render
  35469. * @param sortCompareFn The comparison function use to sort
  35470. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  35471. * @param transparent Specifies to activate blending if true
  35472. */
  35473. private static renderSorted;
  35474. /**
  35475. * Renders the submeshes in the order they were dispatched (no sort applied).
  35476. * @param subMeshes The submeshes to render
  35477. */
  35478. private static renderUnsorted;
  35479. /**
  35480. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35481. * are rendered back to front if in the same alpha index.
  35482. *
  35483. * @param a The first submesh
  35484. * @param b The second submesh
  35485. * @returns The result of the comparison
  35486. */
  35487. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  35488. /**
  35489. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35490. * are rendered back to front.
  35491. *
  35492. * @param a The first submesh
  35493. * @param b The second submesh
  35494. * @returns The result of the comparison
  35495. */
  35496. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  35497. /**
  35498. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35499. * are rendered front to back (prevent overdraw).
  35500. *
  35501. * @param a The first submesh
  35502. * @param b The second submesh
  35503. * @returns The result of the comparison
  35504. */
  35505. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  35506. /**
  35507. * Resets the different lists of submeshes to prepare a new frame.
  35508. */
  35509. prepare(): void;
  35510. dispose(): void;
  35511. /**
  35512. * Inserts the submesh in its correct queue depending on its material.
  35513. * @param subMesh The submesh to dispatch
  35514. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35515. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35516. */
  35517. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35518. dispatchSprites(spriteManager: ISpriteManager): void;
  35519. dispatchParticles(particleSystem: IParticleSystem): void;
  35520. private _renderParticles;
  35521. private _renderSprites;
  35522. }
  35523. }
  35524. declare module BABYLON {
  35525. /**
  35526. * Interface describing the different options available in the rendering manager
  35527. * regarding Auto Clear between groups.
  35528. */
  35529. interface IRenderingManagerAutoClearSetup {
  35530. /**
  35531. * Defines whether or not autoclear is enable.
  35532. */
  35533. autoClear: boolean;
  35534. /**
  35535. * Defines whether or not to autoclear the depth buffer.
  35536. */
  35537. depth: boolean;
  35538. /**
  35539. * Defines whether or not to autoclear the stencil buffer.
  35540. */
  35541. stencil: boolean;
  35542. }
  35543. /**
  35544. * This is the manager responsible of all the rendering for meshes sprites and particles.
  35545. * It is enable to manage the different groups as well as the different necessary sort functions.
  35546. * This should not be used directly aside of the few static configurations
  35547. */
  35548. class RenderingManager {
  35549. /**
  35550. * The max id used for rendering groups (not included)
  35551. */
  35552. static MAX_RENDERINGGROUPS: number;
  35553. /**
  35554. * The min id used for rendering groups (included)
  35555. */
  35556. static MIN_RENDERINGGROUPS: number;
  35557. /**
  35558. * Used to globally prevent autoclearing scenes.
  35559. */
  35560. static AUTOCLEAR: boolean;
  35561. /**
  35562. * @hidden
  35563. */
  35564. _useSceneAutoClearSetup: boolean;
  35565. private _scene;
  35566. private _renderingGroups;
  35567. private _depthStencilBufferAlreadyCleaned;
  35568. private _autoClearDepthStencil;
  35569. private _customOpaqueSortCompareFn;
  35570. private _customAlphaTestSortCompareFn;
  35571. private _customTransparentSortCompareFn;
  35572. private _renderingGroupInfo;
  35573. /**
  35574. * Instantiates a new rendering group for a particular scene
  35575. * @param scene Defines the scene the groups belongs to
  35576. */
  35577. constructor(scene: Scene);
  35578. private _clearDepthStencilBuffer;
  35579. /**
  35580. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  35581. * @hidden
  35582. */
  35583. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  35584. /**
  35585. * Resets the different information of the group to prepare a new frame
  35586. * @hidden
  35587. */
  35588. reset(): void;
  35589. /**
  35590. * Dispose and release the group and its associated resources.
  35591. * @hidden
  35592. */
  35593. dispose(): void;
  35594. /**
  35595. * Clear the info related to rendering groups preventing retention points during dispose.
  35596. */
  35597. freeRenderingGroups(): void;
  35598. private _prepareRenderingGroup;
  35599. /**
  35600. * Add a sprite manager to the rendering manager in order to render it this frame.
  35601. * @param spriteManager Define the sprite manager to render
  35602. */
  35603. dispatchSprites(spriteManager: ISpriteManager): void;
  35604. /**
  35605. * Add a particle system to the rendering manager in order to render it this frame.
  35606. * @param particleSystem Define the particle system to render
  35607. */
  35608. dispatchParticles(particleSystem: IParticleSystem): void;
  35609. /**
  35610. * Add a submesh to the manager in order to render it this frame
  35611. * @param subMesh The submesh to dispatch
  35612. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35613. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35614. */
  35615. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35616. /**
  35617. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35618. * This allowed control for front to back rendering or reversly depending of the special needs.
  35619. *
  35620. * @param renderingGroupId The rendering group id corresponding to its index
  35621. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35622. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35623. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35624. */
  35625. 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;
  35626. /**
  35627. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35628. *
  35629. * @param renderingGroupId The rendering group id corresponding to its index
  35630. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35631. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35632. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35633. */
  35634. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35635. /**
  35636. * Gets the current auto clear configuration for one rendering group of the rendering
  35637. * manager.
  35638. * @param index the rendering group index to get the information for
  35639. * @returns The auto clear setup for the requested rendering group
  35640. */
  35641. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35642. }
  35643. }
  35644. declare module BABYLON {
  35645. /**
  35646. * Renders a layer on top of an existing scene
  35647. */
  35648. class UtilityLayerRenderer implements IDisposable {
  35649. /** the original scene that will be rendered on top of */
  35650. originalScene: Scene;
  35651. private _pointerCaptures;
  35652. private _lastPointerEvents;
  35653. private static _DefaultUtilityLayer;
  35654. private static _DefaultKeepDepthUtilityLayer;
  35655. /**
  35656. * 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)
  35657. */
  35658. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  35659. /**
  35660. * 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)
  35661. */
  35662. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  35663. /**
  35664. * The scene that is rendered on top of the original scene
  35665. */
  35666. utilityLayerScene: Scene;
  35667. /**
  35668. * If the utility layer should automatically be rendered on top of existing scene
  35669. */
  35670. shouldRender: boolean;
  35671. /**
  35672. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  35673. */
  35674. onlyCheckPointerDownEvents: boolean;
  35675. /**
  35676. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  35677. */
  35678. processAllEvents: boolean;
  35679. /**
  35680. * Observable raised when the pointer move from the utility layer scene to the main scene
  35681. */
  35682. onPointerOutObservable: Observable<number>;
  35683. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  35684. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  35685. private _afterRenderObserver;
  35686. private _sceneDisposeObserver;
  35687. private _originalPointerObserver;
  35688. /**
  35689. * Instantiates a UtilityLayerRenderer
  35690. * @param originalScene the original scene that will be rendered on top of
  35691. */
  35692. constructor(
  35693. /** the original scene that will be rendered on top of */
  35694. originalScene: Scene);
  35695. private _notifyObservers;
  35696. /**
  35697. * Renders the utility layers scene on top of the original scene
  35698. */
  35699. render(): void;
  35700. /**
  35701. * Disposes of the renderer
  35702. */
  35703. dispose(): void;
  35704. private _updateCamera;
  35705. }
  35706. }
  35707. declare module BABYLON {
  35708. /**
  35709. * Class used to represent a sprite
  35710. * @see http://doc.babylonjs.com/babylon101/sprites
  35711. */
  35712. class Sprite {
  35713. /** defines the name */
  35714. name: string;
  35715. /** Gets or sets the current world position */
  35716. position: Vector3;
  35717. /** Gets or sets the main color */
  35718. color: Color4;
  35719. /** Gets or sets the width */
  35720. width: number;
  35721. /** Gets or sets the height */
  35722. height: number;
  35723. /** Gets or sets rotation angle */
  35724. angle: number;
  35725. /** Gets or sets the cell index in the sprite sheet */
  35726. cellIndex: number;
  35727. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  35728. invertU: number;
  35729. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  35730. invertV: number;
  35731. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  35732. disposeWhenFinishedAnimating: boolean;
  35733. /** Gets the list of attached animations */
  35734. animations: Animation[];
  35735. /** Gets or sets a boolean indicating if the sprite can be picked */
  35736. isPickable: boolean;
  35737. /**
  35738. * Gets or sets the associated action manager
  35739. */
  35740. actionManager: Nullable<ActionManager>;
  35741. private _animationStarted;
  35742. private _loopAnimation;
  35743. private _fromIndex;
  35744. private _toIndex;
  35745. private _delay;
  35746. private _direction;
  35747. private _manager;
  35748. private _time;
  35749. private _onAnimationEnd;
  35750. /**
  35751. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  35752. */
  35753. isVisible: boolean;
  35754. /**
  35755. * Gets or sets the sprite size
  35756. */
  35757. size: number;
  35758. /**
  35759. * Creates a new Sprite
  35760. * @param name defines the name
  35761. * @param manager defines the manager
  35762. */
  35763. constructor(
  35764. /** defines the name */
  35765. name: string, manager: ISpriteManager);
  35766. /**
  35767. * Starts an animation
  35768. * @param from defines the initial key
  35769. * @param to defines the end key
  35770. * @param loop defines if the animation must loop
  35771. * @param delay defines the start delay (in ms)
  35772. * @param onAnimationEnd defines a callback to call when animation ends
  35773. */
  35774. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  35775. /** Stops current animation (if any) */
  35776. stopAnimation(): void;
  35777. /** @hidden */
  35778. _animate(deltaTime: number): void;
  35779. /** Release associated resources */
  35780. dispose(): void;
  35781. }
  35782. }
  35783. declare module BABYLON {
  35784. /**
  35785. * Defines the minimum interface to fullfil in order to be a sprite manager.
  35786. */
  35787. interface ISpriteManager extends IDisposable {
  35788. /**
  35789. * Restricts the camera to viewing objects with the same layerMask.
  35790. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  35791. */
  35792. layerMask: number;
  35793. /**
  35794. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35795. */
  35796. isPickable: boolean;
  35797. /**
  35798. * Specifies the rendering group id for this mesh (0 by default)
  35799. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35800. */
  35801. renderingGroupId: number;
  35802. /**
  35803. * Defines the list of sprites managed by the manager.
  35804. */
  35805. sprites: Array<Sprite>;
  35806. /**
  35807. * Tests the intersection of a sprite with a specific ray.
  35808. * @param ray The ray we are sending to test the collision
  35809. * @param camera The camera space we are sending rays in
  35810. * @param predicate A predicate allowing excluding sprites from the list of object to test
  35811. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  35812. * @returns picking info or null.
  35813. */
  35814. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35815. /**
  35816. * Renders the list of sprites on screen.
  35817. */
  35818. render(): void;
  35819. }
  35820. /**
  35821. * Class used to manage multiple sprites on the same spritesheet
  35822. * @see http://doc.babylonjs.com/babylon101/sprites
  35823. */
  35824. class SpriteManager implements ISpriteManager {
  35825. /** defines the manager's name */
  35826. name: string;
  35827. /** Gets the list of sprites */
  35828. sprites: Sprite[];
  35829. /** Gets or sets the rendering group id (0 by default) */
  35830. renderingGroupId: number;
  35831. /** Gets or sets camera layer mask */
  35832. layerMask: number;
  35833. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  35834. fogEnabled: boolean;
  35835. /** Gets or sets a boolean indicating if the sprites are pickable */
  35836. isPickable: boolean;
  35837. /** Defines the default width of a cell in the spritesheet */
  35838. cellWidth: number;
  35839. /** Defines the default height of a cell in the spritesheet */
  35840. cellHeight: number;
  35841. /**
  35842. * An event triggered when the manager is disposed.
  35843. */
  35844. onDisposeObservable: Observable<SpriteManager>;
  35845. private _onDisposeObserver;
  35846. /**
  35847. * Callback called when the manager is disposed
  35848. */
  35849. onDispose: () => void;
  35850. private _capacity;
  35851. private _spriteTexture;
  35852. private _epsilon;
  35853. private _scene;
  35854. private _vertexData;
  35855. private _buffer;
  35856. private _vertexBuffers;
  35857. private _indexBuffer;
  35858. private _effectBase;
  35859. private _effectFog;
  35860. /**
  35861. * Gets or sets the spritesheet texture
  35862. */
  35863. texture: Texture;
  35864. /**
  35865. * Creates a new sprite manager
  35866. * @param name defines the manager's name
  35867. * @param imgUrl defines the sprite sheet url
  35868. * @param capacity defines the maximum allowed number of sprites
  35869. * @param cellSize defines the size of a sprite cell
  35870. * @param scene defines the hosting scene
  35871. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  35872. * @param samplingMode defines the smapling mode to use with spritesheet
  35873. */
  35874. constructor(
  35875. /** defines the manager's name */
  35876. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  35877. private _appendSpriteVertex;
  35878. /**
  35879. * Intersects the sprites with a ray
  35880. * @param ray defines the ray to intersect with
  35881. * @param camera defines the current active camera
  35882. * @param predicate defines a predicate used to select candidate sprites
  35883. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  35884. * @returns null if no hit or a PickingInfo
  35885. */
  35886. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35887. /**
  35888. * Render all child sprites
  35889. */
  35890. render(): void;
  35891. /**
  35892. * Release associated resources
  35893. */
  35894. dispose(): void;
  35895. }
  35896. }
  35897. declare module BABYLON {
  35898. interface Scene {
  35899. /** @hidden */
  35900. _pointerOverSprite: Nullable<Sprite>;
  35901. /** @hidden */
  35902. _pickedDownSprite: Nullable<Sprite>;
  35903. /** @hidden */
  35904. _tempSpritePickingRay: Nullable<Ray>;
  35905. /**
  35906. * All of the sprite managers added to this scene
  35907. * @see http://doc.babylonjs.com/babylon101/sprites
  35908. */
  35909. spriteManagers: Array<ISpriteManager>;
  35910. /**
  35911. * An event triggered when sprites rendering is about to start
  35912. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35913. */
  35914. onBeforeSpritesRenderingObservable: Observable<Scene>;
  35915. /**
  35916. * An event triggered when sprites rendering is done
  35917. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35918. */
  35919. onAfterSpritesRenderingObservable: Observable<Scene>;
  35920. /** @hidden */
  35921. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35922. /** Launch a ray to try to pick a sprite in the scene
  35923. * @param x position on screen
  35924. * @param y position on screen
  35925. * @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
  35926. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35927. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35928. * @returns a PickingInfo
  35929. */
  35930. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35931. /** Use the given ray to pick a sprite in the scene
  35932. * @param ray The ray (in world space) to use to pick meshes
  35933. * @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
  35934. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35935. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  35936. * @returns a PickingInfo
  35937. */
  35938. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35939. /**
  35940. * Force the sprite under the pointer
  35941. * @param sprite defines the sprite to use
  35942. */
  35943. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  35944. /**
  35945. * Gets the sprite under the pointer
  35946. * @returns a Sprite or null if no sprite is under the pointer
  35947. */
  35948. getPointerOverSprite(): Nullable<Sprite>;
  35949. }
  35950. /**
  35951. * Defines the sprite scene component responsible to manage sprites
  35952. * in a given scene.
  35953. */
  35954. class SpriteSceneComponent implements ISceneComponent {
  35955. /**
  35956. * The component name helpfull to identify the component in the list of scene components.
  35957. */
  35958. readonly name: string;
  35959. /**
  35960. * The scene the component belongs to.
  35961. */
  35962. scene: Scene;
  35963. /** @hidden */
  35964. private _spritePredicate;
  35965. /**
  35966. * Creates a new instance of the component for the given scene
  35967. * @param scene Defines the scene to register the component in
  35968. */
  35969. constructor(scene: Scene);
  35970. /**
  35971. * Registers the component in a given scene
  35972. */
  35973. register(): void;
  35974. /**
  35975. * Rebuilds the elements related to this component in case of
  35976. * context lost for instance.
  35977. */
  35978. rebuild(): void;
  35979. /**
  35980. * Disposes the component and the associated ressources.
  35981. */
  35982. dispose(): void;
  35983. private _pickSpriteButKeepRay;
  35984. private _pointerMove;
  35985. private _pointerDown;
  35986. private _pointerUp;
  35987. }
  35988. }
  35989. declare module BABYLON {
  35990. /**
  35991. * @hidden
  35992. **/
  35993. class _AlphaState {
  35994. private _isAlphaBlendDirty;
  35995. private _isBlendFunctionParametersDirty;
  35996. private _isBlendEquationParametersDirty;
  35997. private _isBlendConstantsDirty;
  35998. private _alphaBlend;
  35999. private _blendFunctionParameters;
  36000. private _blendEquationParameters;
  36001. private _blendConstants;
  36002. /**
  36003. * Initializes the state.
  36004. */
  36005. constructor();
  36006. readonly isDirty: boolean;
  36007. alphaBlend: boolean;
  36008. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36009. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36010. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36011. reset(): void;
  36012. apply(gl: WebGLRenderingContext): void;
  36013. }
  36014. }
  36015. declare module BABYLON {
  36016. /**
  36017. * @hidden
  36018. **/
  36019. class _DepthCullingState {
  36020. private _isDepthTestDirty;
  36021. private _isDepthMaskDirty;
  36022. private _isDepthFuncDirty;
  36023. private _isCullFaceDirty;
  36024. private _isCullDirty;
  36025. private _isZOffsetDirty;
  36026. private _isFrontFaceDirty;
  36027. private _depthTest;
  36028. private _depthMask;
  36029. private _depthFunc;
  36030. private _cull;
  36031. private _cullFace;
  36032. private _zOffset;
  36033. private _frontFace;
  36034. /**
  36035. * Initializes the state.
  36036. */
  36037. constructor();
  36038. readonly isDirty: boolean;
  36039. zOffset: number;
  36040. cullFace: Nullable<number>;
  36041. cull: Nullable<boolean>;
  36042. depthFunc: Nullable<number>;
  36043. depthMask: boolean;
  36044. depthTest: boolean;
  36045. frontFace: Nullable<number>;
  36046. reset(): void;
  36047. apply(gl: WebGLRenderingContext): void;
  36048. }
  36049. }
  36050. declare module BABYLON {
  36051. /**
  36052. * @hidden
  36053. **/
  36054. class _StencilState {
  36055. private _isStencilTestDirty;
  36056. private _isStencilMaskDirty;
  36057. private _isStencilFuncDirty;
  36058. private _isStencilOpDirty;
  36059. private _stencilTest;
  36060. private _stencilMask;
  36061. private _stencilFunc;
  36062. private _stencilFuncRef;
  36063. private _stencilFuncMask;
  36064. private _stencilOpStencilFail;
  36065. private _stencilOpDepthFail;
  36066. private _stencilOpStencilDepthPass;
  36067. readonly isDirty: boolean;
  36068. stencilFunc: number;
  36069. stencilFuncRef: number;
  36070. stencilFuncMask: number;
  36071. stencilOpStencilFail: number;
  36072. stencilOpDepthFail: number;
  36073. stencilOpStencilDepthPass: number;
  36074. stencilMask: number;
  36075. stencilTest: boolean;
  36076. constructor();
  36077. reset(): void;
  36078. apply(gl: WebGLRenderingContext): void;
  36079. }
  36080. }
  36081. declare module BABYLON {
  36082. /**
  36083. * Class used to evalaute queries containing `and` and `or` operators
  36084. */
  36085. class AndOrNotEvaluator {
  36086. /**
  36087. * Evaluate a query
  36088. * @param query defines the query to evaluate
  36089. * @param evaluateCallback defines the callback used to filter result
  36090. * @returns true if the query matches
  36091. */
  36092. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  36093. private static _HandleParenthesisContent;
  36094. private static _SimplifyNegation;
  36095. }
  36096. }
  36097. declare module BABYLON {
  36098. /**
  36099. * Defines the list of states available for a task inside a AssetsManager
  36100. */
  36101. enum AssetTaskState {
  36102. /**
  36103. * Initialization
  36104. */
  36105. INIT = 0,
  36106. /**
  36107. * Running
  36108. */
  36109. RUNNING = 1,
  36110. /**
  36111. * Done
  36112. */
  36113. DONE = 2,
  36114. /**
  36115. * Error
  36116. */
  36117. ERROR = 3
  36118. }
  36119. /**
  36120. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  36121. */
  36122. abstract class AbstractAssetTask {
  36123. /**
  36124. * Task name
  36125. */ name: string;
  36126. /**
  36127. * Callback called when the task is successful
  36128. */
  36129. onSuccess: (task: any) => void;
  36130. /**
  36131. * Callback called when the task is not successful
  36132. */
  36133. onError: (task: any, message?: string, exception?: any) => void;
  36134. /**
  36135. * Creates a new AssetsManager
  36136. * @param name defines the name of the task
  36137. */
  36138. constructor(
  36139. /**
  36140. * Task name
  36141. */ name: string);
  36142. private _isCompleted;
  36143. private _taskState;
  36144. private _errorObject;
  36145. /**
  36146. * Get if the task is completed
  36147. */
  36148. readonly isCompleted: boolean;
  36149. /**
  36150. * Gets the current state of the task
  36151. */
  36152. readonly taskState: AssetTaskState;
  36153. /**
  36154. * Gets the current error object (if task is in error)
  36155. */
  36156. readonly errorObject: {
  36157. message?: string;
  36158. exception?: any;
  36159. };
  36160. /**
  36161. * Internal only
  36162. * @hidden
  36163. */
  36164. _setErrorObject(message?: string, exception?: any): void;
  36165. /**
  36166. * Execute the current task
  36167. * @param scene defines the scene where you want your assets to be loaded
  36168. * @param onSuccess is a callback called when the task is successfully executed
  36169. * @param onError is a callback called if an error occurs
  36170. */
  36171. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36172. /**
  36173. * Execute the current task
  36174. * @param scene defines the scene where you want your assets to be loaded
  36175. * @param onSuccess is a callback called when the task is successfully executed
  36176. * @param onError is a callback called if an error occurs
  36177. */
  36178. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36179. /**
  36180. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  36181. * This can be used with failed tasks that have the reason for failure fixed.
  36182. */
  36183. reset(): void;
  36184. private onErrorCallback;
  36185. private onDoneCallback;
  36186. }
  36187. /**
  36188. * Define the interface used by progress events raised during assets loading
  36189. */
  36190. interface IAssetsProgressEvent {
  36191. /**
  36192. * Defines the number of remaining tasks to process
  36193. */
  36194. remainingCount: number;
  36195. /**
  36196. * Defines the total number of tasks
  36197. */
  36198. totalCount: number;
  36199. /**
  36200. * Defines the task that was just processed
  36201. */
  36202. task: AbstractAssetTask;
  36203. }
  36204. /**
  36205. * Class used to share progress information about assets loading
  36206. */
  36207. class AssetsProgressEvent implements IAssetsProgressEvent {
  36208. /**
  36209. * Defines the number of remaining tasks to process
  36210. */
  36211. remainingCount: number;
  36212. /**
  36213. * Defines the total number of tasks
  36214. */
  36215. totalCount: number;
  36216. /**
  36217. * Defines the task that was just processed
  36218. */
  36219. task: AbstractAssetTask;
  36220. /**
  36221. * Creates a AssetsProgressEvent
  36222. * @param remainingCount defines the number of remaining tasks to process
  36223. * @param totalCount defines the total number of tasks
  36224. * @param task defines the task that was just processed
  36225. */
  36226. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  36227. }
  36228. /**
  36229. * Define a task used by AssetsManager to load meshes
  36230. */
  36231. class MeshAssetTask extends AbstractAssetTask {
  36232. /**
  36233. * Defines the name of the task
  36234. */
  36235. name: string;
  36236. /**
  36237. * Defines the list of mesh's names you want to load
  36238. */
  36239. meshesNames: any;
  36240. /**
  36241. * Defines the root url to use as a base to load your meshes and associated resources
  36242. */
  36243. rootUrl: string;
  36244. /**
  36245. * Defines the filename of the scene to load from
  36246. */
  36247. sceneFilename: string;
  36248. /**
  36249. * Gets the list of loaded meshes
  36250. */
  36251. loadedMeshes: Array<AbstractMesh>;
  36252. /**
  36253. * Gets the list of loaded particle systems
  36254. */
  36255. loadedParticleSystems: Array<IParticleSystem>;
  36256. /**
  36257. * Gets the list of loaded skeletons
  36258. */
  36259. loadedSkeletons: Array<Skeleton>;
  36260. /**
  36261. * Callback called when the task is successful
  36262. */
  36263. onSuccess: (task: MeshAssetTask) => void;
  36264. /**
  36265. * Callback called when the task is successful
  36266. */
  36267. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  36268. /**
  36269. * Creates a new MeshAssetTask
  36270. * @param name defines the name of the task
  36271. * @param meshesNames defines the list of mesh's names you want to load
  36272. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  36273. * @param sceneFilename defines the filename of the scene to load from
  36274. */
  36275. constructor(
  36276. /**
  36277. * Defines the name of the task
  36278. */
  36279. name: string,
  36280. /**
  36281. * Defines the list of mesh's names you want to load
  36282. */
  36283. meshesNames: any,
  36284. /**
  36285. * Defines the root url to use as a base to load your meshes and associated resources
  36286. */
  36287. rootUrl: string,
  36288. /**
  36289. * Defines the filename of the scene to load from
  36290. */
  36291. sceneFilename: string);
  36292. /**
  36293. * Execute the current task
  36294. * @param scene defines the scene where you want your assets to be loaded
  36295. * @param onSuccess is a callback called when the task is successfully executed
  36296. * @param onError is a callback called if an error occurs
  36297. */
  36298. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36299. }
  36300. /**
  36301. * Define a task used by AssetsManager to load text content
  36302. */
  36303. class TextFileAssetTask extends AbstractAssetTask {
  36304. /**
  36305. * Defines the name of the task
  36306. */
  36307. name: string;
  36308. /**
  36309. * Defines the location of the file to load
  36310. */
  36311. url: string;
  36312. /**
  36313. * Gets the loaded text string
  36314. */
  36315. text: string;
  36316. /**
  36317. * Callback called when the task is successful
  36318. */
  36319. onSuccess: (task: TextFileAssetTask) => void;
  36320. /**
  36321. * Callback called when the task is successful
  36322. */
  36323. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  36324. /**
  36325. * Creates a new TextFileAssetTask object
  36326. * @param name defines the name of the task
  36327. * @param url defines the location of the file to load
  36328. */
  36329. constructor(
  36330. /**
  36331. * Defines the name of the task
  36332. */
  36333. name: string,
  36334. /**
  36335. * Defines the location of the file to load
  36336. */
  36337. url: string);
  36338. /**
  36339. * Execute the current task
  36340. * @param scene defines the scene where you want your assets to be loaded
  36341. * @param onSuccess is a callback called when the task is successfully executed
  36342. * @param onError is a callback called if an error occurs
  36343. */
  36344. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36345. }
  36346. /**
  36347. * Define a task used by AssetsManager to load binary data
  36348. */
  36349. class BinaryFileAssetTask extends AbstractAssetTask {
  36350. /**
  36351. * Defines the name of the task
  36352. */
  36353. name: string;
  36354. /**
  36355. * Defines the location of the file to load
  36356. */
  36357. url: string;
  36358. /**
  36359. * Gets the lodaded data (as an array buffer)
  36360. */
  36361. data: ArrayBuffer;
  36362. /**
  36363. * Callback called when the task is successful
  36364. */
  36365. onSuccess: (task: BinaryFileAssetTask) => void;
  36366. /**
  36367. * Callback called when the task is successful
  36368. */
  36369. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  36370. /**
  36371. * Creates a new BinaryFileAssetTask object
  36372. * @param name defines the name of the new task
  36373. * @param url defines the location of the file to load
  36374. */
  36375. constructor(
  36376. /**
  36377. * Defines the name of the task
  36378. */
  36379. name: string,
  36380. /**
  36381. * Defines the location of the file to load
  36382. */
  36383. url: string);
  36384. /**
  36385. * Execute the current task
  36386. * @param scene defines the scene where you want your assets to be loaded
  36387. * @param onSuccess is a callback called when the task is successfully executed
  36388. * @param onError is a callback called if an error occurs
  36389. */
  36390. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36391. }
  36392. /**
  36393. * Define a task used by AssetsManager to load images
  36394. */
  36395. class ImageAssetTask extends AbstractAssetTask {
  36396. /**
  36397. * Defines the name of the task
  36398. */
  36399. name: string;
  36400. /**
  36401. * Defines the location of the image to load
  36402. */
  36403. url: string;
  36404. /**
  36405. * Gets the loaded images
  36406. */
  36407. image: HTMLImageElement;
  36408. /**
  36409. * Callback called when the task is successful
  36410. */
  36411. onSuccess: (task: ImageAssetTask) => void;
  36412. /**
  36413. * Callback called when the task is successful
  36414. */
  36415. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  36416. /**
  36417. * Creates a new ImageAssetTask
  36418. * @param name defines the name of the task
  36419. * @param url defines the location of the image to load
  36420. */
  36421. constructor(
  36422. /**
  36423. * Defines the name of the task
  36424. */
  36425. name: string,
  36426. /**
  36427. * Defines the location of the image to load
  36428. */
  36429. url: string);
  36430. /**
  36431. * Execute the current task
  36432. * @param scene defines the scene where you want your assets to be loaded
  36433. * @param onSuccess is a callback called when the task is successfully executed
  36434. * @param onError is a callback called if an error occurs
  36435. */
  36436. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36437. }
  36438. /**
  36439. * Defines the interface used by texture loading tasks
  36440. */
  36441. interface ITextureAssetTask<TEX extends BaseTexture> {
  36442. /**
  36443. * Gets the loaded texture
  36444. */
  36445. texture: TEX;
  36446. }
  36447. /**
  36448. * Define a task used by AssetsManager to load 2D textures
  36449. */
  36450. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  36451. /**
  36452. * Defines the name of the task
  36453. */
  36454. name: string;
  36455. /**
  36456. * Defines the location of the file to load
  36457. */
  36458. url: string;
  36459. /**
  36460. * Defines if mipmap should not be generated (default is false)
  36461. */
  36462. noMipmap?: boolean | undefined;
  36463. /**
  36464. * Defines if texture must be inverted on Y axis (default is false)
  36465. */
  36466. invertY?: boolean | undefined;
  36467. /**
  36468. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36469. */
  36470. samplingMode: number;
  36471. /**
  36472. * Gets the loaded texture
  36473. */
  36474. texture: Texture;
  36475. /**
  36476. * Callback called when the task is successful
  36477. */
  36478. onSuccess: (task: TextureAssetTask) => void;
  36479. /**
  36480. * Callback called when the task is successful
  36481. */
  36482. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  36483. /**
  36484. * Creates a new TextureAssetTask object
  36485. * @param name defines the name of the task
  36486. * @param url defines the location of the file to load
  36487. * @param noMipmap defines if mipmap should not be generated (default is false)
  36488. * @param invertY defines if texture must be inverted on Y axis (default is false)
  36489. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36490. */
  36491. constructor(
  36492. /**
  36493. * Defines the name of the task
  36494. */
  36495. name: string,
  36496. /**
  36497. * Defines the location of the file to load
  36498. */
  36499. url: string,
  36500. /**
  36501. * Defines if mipmap should not be generated (default is false)
  36502. */
  36503. noMipmap?: boolean | undefined,
  36504. /**
  36505. * Defines if texture must be inverted on Y axis (default is false)
  36506. */
  36507. invertY?: boolean | undefined,
  36508. /**
  36509. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36510. */
  36511. samplingMode?: number);
  36512. /**
  36513. * Execute the current task
  36514. * @param scene defines the scene where you want your assets to be loaded
  36515. * @param onSuccess is a callback called when the task is successfully executed
  36516. * @param onError is a callback called if an error occurs
  36517. */
  36518. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36519. }
  36520. /**
  36521. * Define a task used by AssetsManager to load cube textures
  36522. */
  36523. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  36524. /**
  36525. * Defines the name of the task
  36526. */
  36527. name: string;
  36528. /**
  36529. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  36530. */
  36531. url: string;
  36532. /**
  36533. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  36534. */
  36535. extensions?: string[] | undefined;
  36536. /**
  36537. * Defines if mipmaps should not be generated (default is false)
  36538. */
  36539. noMipmap?: boolean | undefined;
  36540. /**
  36541. * Defines the explicit list of files (undefined by default)
  36542. */
  36543. files?: string[] | undefined;
  36544. /**
  36545. * Gets the loaded texture
  36546. */
  36547. texture: CubeTexture;
  36548. /**
  36549. * Callback called when the task is successful
  36550. */
  36551. onSuccess: (task: CubeTextureAssetTask) => void;
  36552. /**
  36553. * Callback called when the task is successful
  36554. */
  36555. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  36556. /**
  36557. * Creates a new CubeTextureAssetTask
  36558. * @param name defines the name of the task
  36559. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  36560. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  36561. * @param noMipmap defines if mipmaps should not be generated (default is false)
  36562. * @param files defines the explicit list of files (undefined by default)
  36563. */
  36564. constructor(
  36565. /**
  36566. * Defines the name of the task
  36567. */
  36568. name: string,
  36569. /**
  36570. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  36571. */
  36572. url: string,
  36573. /**
  36574. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  36575. */
  36576. extensions?: string[] | undefined,
  36577. /**
  36578. * Defines if mipmaps should not be generated (default is false)
  36579. */
  36580. noMipmap?: boolean | undefined,
  36581. /**
  36582. * Defines the explicit list of files (undefined by default)
  36583. */
  36584. files?: string[] | undefined);
  36585. /**
  36586. * Execute the current task
  36587. * @param scene defines the scene where you want your assets to be loaded
  36588. * @param onSuccess is a callback called when the task is successfully executed
  36589. * @param onError is a callback called if an error occurs
  36590. */
  36591. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36592. }
  36593. /**
  36594. * Define a task used by AssetsManager to load HDR cube textures
  36595. */
  36596. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  36597. /**
  36598. * Defines the name of the task
  36599. */
  36600. name: string;
  36601. /**
  36602. * Defines the location of the file to load
  36603. */
  36604. url: string;
  36605. /**
  36606. * Defines the desired size (the more it increases the longer the generation will be)
  36607. */
  36608. size: number;
  36609. /**
  36610. * Defines if mipmaps should not be generated (default is false)
  36611. */
  36612. noMipmap: boolean;
  36613. /**
  36614. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  36615. */
  36616. generateHarmonics: boolean;
  36617. /**
  36618. * 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)
  36619. */
  36620. gammaSpace: boolean;
  36621. /**
  36622. * Internal Use Only
  36623. */
  36624. reserved: boolean;
  36625. /**
  36626. * Gets the loaded texture
  36627. */
  36628. texture: HDRCubeTexture;
  36629. /**
  36630. * Callback called when the task is successful
  36631. */
  36632. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  36633. /**
  36634. * Callback called when the task is successful
  36635. */
  36636. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  36637. /**
  36638. * Creates a new HDRCubeTextureAssetTask object
  36639. * @param name defines the name of the task
  36640. * @param url defines the location of the file to load
  36641. * @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.
  36642. * @param noMipmap defines if mipmaps should not be generated (default is false)
  36643. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  36644. * @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)
  36645. * @param reserved Internal use only
  36646. */
  36647. constructor(
  36648. /**
  36649. * Defines the name of the task
  36650. */
  36651. name: string,
  36652. /**
  36653. * Defines the location of the file to load
  36654. */
  36655. url: string,
  36656. /**
  36657. * Defines the desired size (the more it increases the longer the generation will be)
  36658. */
  36659. size: number,
  36660. /**
  36661. * Defines if mipmaps should not be generated (default is false)
  36662. */
  36663. noMipmap?: boolean,
  36664. /**
  36665. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  36666. */
  36667. generateHarmonics?: boolean,
  36668. /**
  36669. * 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)
  36670. */
  36671. gammaSpace?: boolean,
  36672. /**
  36673. * Internal Use Only
  36674. */
  36675. reserved?: boolean);
  36676. /**
  36677. * Execute the current task
  36678. * @param scene defines the scene where you want your assets to be loaded
  36679. * @param onSuccess is a callback called when the task is successfully executed
  36680. * @param onError is a callback called if an error occurs
  36681. */
  36682. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36683. }
  36684. /**
  36685. * This class can be used to easily import assets into a scene
  36686. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  36687. */
  36688. class AssetsManager {
  36689. private _scene;
  36690. private _isLoading;
  36691. protected _tasks: AbstractAssetTask[];
  36692. protected _waitingTasksCount: number;
  36693. protected _totalTasksCount: number;
  36694. /**
  36695. * Callback called when all tasks are processed
  36696. */
  36697. onFinish: (tasks: AbstractAssetTask[]) => void;
  36698. /**
  36699. * Callback called when a task is successful
  36700. */
  36701. onTaskSuccess: (task: AbstractAssetTask) => void;
  36702. /**
  36703. * Callback called when a task had an error
  36704. */
  36705. onTaskError: (task: AbstractAssetTask) => void;
  36706. /**
  36707. * Callback called when a task is done (whatever the result is)
  36708. */
  36709. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  36710. /**
  36711. * Observable called when all tasks are processed
  36712. */
  36713. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  36714. /**
  36715. * Observable called when a task had an error
  36716. */
  36717. onTaskErrorObservable: Observable<AbstractAssetTask>;
  36718. /**
  36719. * Observable called when a task is successful
  36720. */
  36721. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  36722. /**
  36723. * Observable called when a task is done (whatever the result is)
  36724. */
  36725. onProgressObservable: Observable<IAssetsProgressEvent>;
  36726. /**
  36727. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  36728. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36729. */
  36730. useDefaultLoadingScreen: boolean;
  36731. /**
  36732. * Creates a new AssetsManager
  36733. * @param scene defines the scene to work on
  36734. */
  36735. constructor(scene: Scene);
  36736. /**
  36737. * Add a MeshAssetTask to the list of active tasks
  36738. * @param taskName defines the name of the new task
  36739. * @param meshesNames defines the name of meshes to load
  36740. * @param rootUrl defines the root url to use to locate files
  36741. * @param sceneFilename defines the filename of the scene file
  36742. * @returns a new MeshAssetTask object
  36743. */
  36744. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  36745. /**
  36746. * Add a TextFileAssetTask to the list of active tasks
  36747. * @param taskName defines the name of the new task
  36748. * @param url defines the url of the file to load
  36749. * @returns a new TextFileAssetTask object
  36750. */
  36751. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  36752. /**
  36753. * Add a BinaryFileAssetTask to the list of active tasks
  36754. * @param taskName defines the name of the new task
  36755. * @param url defines the url of the file to load
  36756. * @returns a new BinaryFileAssetTask object
  36757. */
  36758. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  36759. /**
  36760. * Add a ImageAssetTask to the list of active tasks
  36761. * @param taskName defines the name of the new task
  36762. * @param url defines the url of the file to load
  36763. * @returns a new ImageAssetTask object
  36764. */
  36765. addImageTask(taskName: string, url: string): ImageAssetTask;
  36766. /**
  36767. * Add a TextureAssetTask to the list of active tasks
  36768. * @param taskName defines the name of the new task
  36769. * @param url defines the url of the file to load
  36770. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  36771. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  36772. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  36773. * @returns a new TextureAssetTask object
  36774. */
  36775. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  36776. /**
  36777. * Add a CubeTextureAssetTask to the list of active tasks
  36778. * @param taskName defines the name of the new task
  36779. * @param url defines the url of the file to load
  36780. * @param extensions defines the extension to use to load the cube map (can be null)
  36781. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  36782. * @param files defines the list of files to load (can be null)
  36783. * @returns a new CubeTextureAssetTask object
  36784. */
  36785. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  36786. /**
  36787. *
  36788. * Add a HDRCubeTextureAssetTask to the list of active tasks
  36789. * @param taskName defines the name of the new task
  36790. * @param url defines the url of the file to load
  36791. * @param size defines the size you want for the cubemap (can be null)
  36792. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  36793. * @param generateHarmonics defines if you want to automatically generate (true by default)
  36794. * @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)
  36795. * @param reserved Internal use only
  36796. * @returns a new HDRCubeTextureAssetTask object
  36797. */
  36798. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  36799. /**
  36800. * Remove a task from the assets manager.
  36801. * @param task the task to remove
  36802. */
  36803. removeTask(task: AbstractAssetTask): void;
  36804. private _decreaseWaitingTasksCount;
  36805. private _runTask;
  36806. /**
  36807. * Reset the AssetsManager and remove all tasks
  36808. * @return the current instance of the AssetsManager
  36809. */
  36810. reset(): AssetsManager;
  36811. /**
  36812. * Start the loading process
  36813. * @return the current instance of the AssetsManager
  36814. */
  36815. load(): AssetsManager;
  36816. }
  36817. }
  36818. declare module BABYLON {
  36819. /**
  36820. * Class used to enable access to IndexedDB
  36821. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  36822. */
  36823. class Database {
  36824. private callbackManifestChecked;
  36825. private currentSceneUrl;
  36826. private db;
  36827. private _enableSceneOffline;
  36828. private _enableTexturesOffline;
  36829. private manifestVersionFound;
  36830. private mustUpdateRessources;
  36831. private hasReachedQuota;
  36832. private isSupported;
  36833. private idbFactory;
  36834. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  36835. static IsUASupportingBlobStorage: boolean;
  36836. /** Gets a boolean indicating if Database storate is enabled */
  36837. static IDBStorageEnabled: boolean;
  36838. /**
  36839. * Gets a boolean indicating if scene must be saved in the database
  36840. */
  36841. readonly enableSceneOffline: boolean;
  36842. /**
  36843. * Gets a boolean indicating if textures must be saved in the database
  36844. */
  36845. readonly enableTexturesOffline: boolean;
  36846. /**
  36847. * Creates a new Database
  36848. * @param urlToScene defines the url to load the scene
  36849. * @param callbackManifestChecked defines the callback to use when manifest is checked
  36850. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  36851. */
  36852. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  36853. private static _ParseURL;
  36854. private static _ReturnFullUrlLocation;
  36855. private _checkManifestFile;
  36856. /**
  36857. * Open the database and make it available
  36858. * @param successCallback defines the callback to call on success
  36859. * @param errorCallback defines the callback to call on error
  36860. */
  36861. openAsync(successCallback: () => void, errorCallback: () => void): void;
  36862. /**
  36863. * Loads an image from the database
  36864. * @param url defines the url to load from
  36865. * @param image defines the target DOM image
  36866. */
  36867. loadImageFromDB(url: string, image: HTMLImageElement): void;
  36868. private _loadImageFromDBAsync;
  36869. private _saveImageIntoDBAsync;
  36870. private _checkVersionFromDB;
  36871. private _loadVersionFromDBAsync;
  36872. private _saveVersionIntoDBAsync;
  36873. /**
  36874. * Loads a file from database
  36875. * @param url defines the URL to load from
  36876. * @param sceneLoaded defines a callback to call on success
  36877. * @param progressCallBack defines a callback to call when progress changed
  36878. * @param errorCallback defines a callback to call on error
  36879. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  36880. */
  36881. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  36882. private _loadFileFromDBAsync;
  36883. private _saveFileIntoDBAsync;
  36884. }
  36885. }
  36886. declare module BABYLON {
  36887. /**
  36888. * Direct draw surface info
  36889. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  36890. */
  36891. interface DDSInfo {
  36892. /**
  36893. * Width of the texture
  36894. */
  36895. width: number;
  36896. /**
  36897. * Width of the texture
  36898. */
  36899. height: number;
  36900. /**
  36901. * Number of Mipmaps for the texture
  36902. * @see https://en.wikipedia.org/wiki/Mipmap
  36903. */
  36904. mipmapCount: number;
  36905. /**
  36906. * If the textures format is a known fourCC format
  36907. * @see https://www.fourcc.org/
  36908. */
  36909. isFourCC: boolean;
  36910. /**
  36911. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  36912. */
  36913. isRGB: boolean;
  36914. /**
  36915. * If the texture is a lumincance format
  36916. */
  36917. isLuminance: boolean;
  36918. /**
  36919. * If this is a cube texture
  36920. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  36921. */
  36922. isCube: boolean;
  36923. /**
  36924. * If the texture is a compressed format eg. FOURCC_DXT1
  36925. */
  36926. isCompressed: boolean;
  36927. /**
  36928. * The dxgiFormat of the texture
  36929. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  36930. */
  36931. dxgiFormat: number;
  36932. /**
  36933. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  36934. */
  36935. textureType: number;
  36936. /**
  36937. * Sphericle polynomial created for the dds texture
  36938. */
  36939. sphericalPolynomial?: SphericalPolynomial;
  36940. }
  36941. /**
  36942. * Class used to provide DDS decompression tools
  36943. */
  36944. class DDSTools {
  36945. /**
  36946. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  36947. */
  36948. static StoreLODInAlphaChannel: boolean;
  36949. /**
  36950. * Gets DDS information from an array buffer
  36951. * @param arrayBuffer defines the array buffer to read data from
  36952. * @returns the DDS information
  36953. */
  36954. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  36955. private static _FloatView;
  36956. private static _Int32View;
  36957. private static _ToHalfFloat;
  36958. private static _FromHalfFloat;
  36959. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  36960. private static _GetHalfFloatRGBAArrayBuffer;
  36961. private static _GetFloatRGBAArrayBuffer;
  36962. private static _GetFloatAsUIntRGBAArrayBuffer;
  36963. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  36964. private static _GetRGBAArrayBuffer;
  36965. private static _ExtractLongWordOrder;
  36966. private static _GetRGBArrayBuffer;
  36967. private static _GetLuminanceArrayBuffer;
  36968. /**
  36969. * Uploads DDS Levels to a Babylon Texture
  36970. * @hidden
  36971. */
  36972. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  36973. }
  36974. }
  36975. declare module BABYLON {
  36976. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36977. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36978. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36979. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36980. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36981. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36982. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36983. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36984. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36985. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36986. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36987. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36988. /**
  36989. * Decorator used to define property that can be serialized as reference to a camera
  36990. * @param sourceName defines the name of the property to decorate
  36991. */
  36992. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36993. /**
  36994. * Class used to help serialization objects
  36995. */
  36996. class SerializationHelper {
  36997. /**
  36998. * Static function used to serialized a specific entity
  36999. * @param entity defines the entity to serialize
  37000. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37001. * @returns a JSON compatible object representing the serialization of the entity
  37002. */
  37003. static Serialize<T>(entity: T, serializationObject?: any): any;
  37004. /**
  37005. * Creates a new entity from a serialization data object
  37006. * @param creationFunction defines a function used to instanciated the new entity
  37007. * @param source defines the source serialization data
  37008. * @param scene defines the hosting scene
  37009. * @param rootUrl defines the root url for resources
  37010. * @returns a new entity
  37011. */
  37012. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37013. /**
  37014. * Clones an object
  37015. * @param creationFunction defines the function used to instanciate the new object
  37016. * @param source defines the source object
  37017. * @returns the cloned object
  37018. */
  37019. static Clone<T>(creationFunction: () => T, source: T): T;
  37020. /**
  37021. * Instanciates a new object based on a source one (some data will be shared between both object)
  37022. * @param creationFunction defines the function used to instanciate the new object
  37023. * @param source defines the source object
  37024. * @returns the new object
  37025. */
  37026. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37027. }
  37028. }
  37029. declare module BABYLON {
  37030. /**
  37031. * Wrapper class for promise with external resolve and reject.
  37032. */
  37033. class Deferred<T> {
  37034. /**
  37035. * The promise associated with this deferred object.
  37036. */
  37037. readonly promise: Promise<T>;
  37038. private _resolve;
  37039. private _reject;
  37040. /**
  37041. * The resolve method of the promise associated with this deferred object.
  37042. */
  37043. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37044. /**
  37045. * The reject method of the promise associated with this deferred object.
  37046. */
  37047. readonly reject: (reason?: any) => void;
  37048. /**
  37049. * Constructor for this deferred object.
  37050. */
  37051. constructor();
  37052. }
  37053. }
  37054. declare module BABYLON {
  37055. /**
  37056. * Raw texture data and descriptor sufficient for WebGL texture upload
  37057. */
  37058. interface EnvironmentTextureInfo {
  37059. /**
  37060. * Version of the environment map
  37061. */
  37062. version: number;
  37063. /**
  37064. * Width of image
  37065. */
  37066. width: number;
  37067. /**
  37068. * Irradiance information stored in the file.
  37069. */
  37070. irradiance: any;
  37071. /**
  37072. * Specular information stored in the file.
  37073. */
  37074. specular: any;
  37075. }
  37076. /**
  37077. * Sets of helpers addressing the serialization and deserialization of environment texture
  37078. * stored in a BabylonJS env file.
  37079. * Those files are usually stored as .env files.
  37080. */
  37081. class EnvironmentTextureTools {
  37082. /**
  37083. * Magic number identifying the env file.
  37084. */
  37085. private static _MagicBytes;
  37086. /**
  37087. * Gets the environment info from an env file.
  37088. * @param data The array buffer containing the .env bytes.
  37089. * @returns the environment file info (the json header) if successfully parsed.
  37090. */
  37091. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  37092. /**
  37093. * Creates an environment texture from a loaded cube texture.
  37094. * @param texture defines the cube texture to convert in env file
  37095. * @return a promise containing the environment data if succesfull.
  37096. */
  37097. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  37098. /**
  37099. * Creates a JSON representation of the spherical data.
  37100. * @param texture defines the texture containing the polynomials
  37101. * @return the JSON representation of the spherical info
  37102. */
  37103. private static _CreateEnvTextureIrradiance;
  37104. /**
  37105. * Uploads the texture info contained in the env file to the GPU.
  37106. * @param texture defines the internal texture to upload to
  37107. * @param arrayBuffer defines the buffer cotaining the data to load
  37108. * @param info defines the texture info retrieved through the GetEnvInfo method
  37109. * @returns a promise
  37110. */
  37111. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  37112. /**
  37113. * Uploads the levels of image data to the GPU.
  37114. * @param texture defines the internal texture to upload to
  37115. * @param imageData defines the array buffer views of image data [mipmap][face]
  37116. * @returns a promise
  37117. */
  37118. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  37119. /**
  37120. * Uploads spherical polynomials information to the texture.
  37121. * @param texture defines the texture we are trying to upload the information to
  37122. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  37123. */
  37124. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  37125. }
  37126. }
  37127. declare module BABYLON {
  37128. /**
  37129. * Class used to help managing file picking and drag'n'drop
  37130. */
  37131. class FilesInput {
  37132. /**
  37133. * List of files ready to be loaded
  37134. */
  37135. static FilesToLoad: {
  37136. [key: string]: File;
  37137. };
  37138. /**
  37139. * Callback called when a file is processed
  37140. */
  37141. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  37142. private _engine;
  37143. private _currentScene;
  37144. private _sceneLoadedCallback;
  37145. private _progressCallback;
  37146. private _additionalRenderLoopLogicCallback;
  37147. private _textureLoadingCallback;
  37148. private _startingProcessingFilesCallback;
  37149. private _onReloadCallback;
  37150. private _errorCallback;
  37151. private _elementToMonitor;
  37152. private _sceneFileToLoad;
  37153. private _filesToLoad;
  37154. /**
  37155. * Creates a new FilesInput
  37156. * @param engine defines the rendering engine
  37157. * @param scene defines the hosting scene
  37158. * @param sceneLoadedCallback callback called when scene is loaded
  37159. * @param progressCallback callback called to track progress
  37160. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  37161. * @param textureLoadingCallback callback called when a texture is loading
  37162. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  37163. * @param onReloadCallback callback called when a reload is requested
  37164. * @param errorCallback callback call if an error occurs
  37165. */
  37166. 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);
  37167. private _dragEnterHandler;
  37168. private _dragOverHandler;
  37169. private _dropHandler;
  37170. /**
  37171. * Calls this function to listen to drag'n'drop events on a specific DOM element
  37172. * @param elementToMonitor defines the DOM element to track
  37173. */
  37174. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  37175. /**
  37176. * Release all associated resources
  37177. */
  37178. dispose(): void;
  37179. private renderFunction;
  37180. private drag;
  37181. private drop;
  37182. private _traverseFolder;
  37183. private _processFiles;
  37184. /**
  37185. * Load files from a drop event
  37186. * @param event defines the drop event to use as source
  37187. */
  37188. loadFiles(event: any): void;
  37189. private _processReload;
  37190. /**
  37191. * Reload the current scene from the loaded files
  37192. */
  37193. reload(): void;
  37194. }
  37195. }
  37196. declare module BABYLON {
  37197. /**
  37198. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  37199. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  37200. */
  37201. class KhronosTextureContainer {
  37202. /** contents of the KTX container file */
  37203. arrayBuffer: any;
  37204. private static HEADER_LEN;
  37205. private static COMPRESSED_2D;
  37206. private static COMPRESSED_3D;
  37207. private static TEX_2D;
  37208. private static TEX_3D;
  37209. /**
  37210. * Gets the openGL type
  37211. */
  37212. glType: number;
  37213. /**
  37214. * Gets the openGL type size
  37215. */
  37216. glTypeSize: number;
  37217. /**
  37218. * Gets the openGL format
  37219. */
  37220. glFormat: number;
  37221. /**
  37222. * Gets the openGL internal format
  37223. */
  37224. glInternalFormat: number;
  37225. /**
  37226. * Gets the base internal format
  37227. */
  37228. glBaseInternalFormat: number;
  37229. /**
  37230. * Gets image width in pixel
  37231. */
  37232. pixelWidth: number;
  37233. /**
  37234. * Gets image height in pixel
  37235. */
  37236. pixelHeight: number;
  37237. /**
  37238. * Gets image depth in pixels
  37239. */
  37240. pixelDepth: number;
  37241. /**
  37242. * Gets the number of array elements
  37243. */
  37244. numberOfArrayElements: number;
  37245. /**
  37246. * Gets the number of faces
  37247. */
  37248. numberOfFaces: number;
  37249. /**
  37250. * Gets the number of mipmap levels
  37251. */
  37252. numberOfMipmapLevels: number;
  37253. /**
  37254. * Gets the bytes of key value data
  37255. */
  37256. bytesOfKeyValueData: number;
  37257. /**
  37258. * Gets the load type
  37259. */
  37260. loadType: number;
  37261. /**
  37262. * Creates a new KhronosTextureContainer
  37263. * @param arrayBuffer contents of the KTX container file
  37264. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  37265. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  37266. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  37267. */
  37268. constructor(
  37269. /** contents of the KTX container file */
  37270. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  37271. /**
  37272. * Revert the endianness of a value.
  37273. * Not as fast hardware based, but will probably never need to use
  37274. * @param val defines the value to convert
  37275. * @returns the new value
  37276. */
  37277. switchEndianness(val: number): number;
  37278. /**
  37279. * Uploads KTX content to a Babylon Texture.
  37280. * It is assumed that the texture has already been created & is currently bound
  37281. * @hidden
  37282. */
  37283. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  37284. private _upload2DCompressedLevels;
  37285. }
  37286. }
  37287. declare module BABYLON {
  37288. /**
  37289. * A class serves as a medium between the observable and its observers
  37290. */
  37291. class EventState {
  37292. /**
  37293. * Create a new EventState
  37294. * @param mask defines the mask associated with this state
  37295. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37296. * @param target defines the original target of the state
  37297. * @param currentTarget defines the current target of the state
  37298. */
  37299. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  37300. /**
  37301. * Initialize the current event state
  37302. * @param mask defines the mask associated with this state
  37303. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37304. * @param target defines the original target of the state
  37305. * @param currentTarget defines the current target of the state
  37306. * @returns the current event state
  37307. */
  37308. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  37309. /**
  37310. * An Observer can set this property to true to prevent subsequent observers of being notified
  37311. */
  37312. skipNextObservers: boolean;
  37313. /**
  37314. * Get the mask value that were used to trigger the event corresponding to this EventState object
  37315. */
  37316. mask: number;
  37317. /**
  37318. * The object that originally notified the event
  37319. */
  37320. target?: any;
  37321. /**
  37322. * The current object in the bubbling phase
  37323. */
  37324. currentTarget?: any;
  37325. /**
  37326. * This will be populated with the return value of the last function that was executed.
  37327. * If it is the first function in the callback chain it will be the event data.
  37328. */
  37329. lastReturnValue?: any;
  37330. }
  37331. /**
  37332. * Represent an Observer registered to a given Observable object.
  37333. */
  37334. class Observer<T> {
  37335. /**
  37336. * Defines the callback to call when the observer is notified
  37337. */
  37338. callback: (eventData: T, eventState: EventState) => void;
  37339. /**
  37340. * Defines the mask of the observer (used to filter notifications)
  37341. */
  37342. mask: number;
  37343. /**
  37344. * Defines the current scope used to restore the JS context
  37345. */
  37346. scope: any;
  37347. /** @hidden */
  37348. _willBeUnregistered: boolean;
  37349. /**
  37350. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  37351. */
  37352. unregisterOnNextCall: boolean;
  37353. /**
  37354. * Creates a new observer
  37355. * @param callback defines the callback to call when the observer is notified
  37356. * @param mask defines the mask of the observer (used to filter notifications)
  37357. * @param scope defines the current scope used to restore the JS context
  37358. */
  37359. constructor(
  37360. /**
  37361. * Defines the callback to call when the observer is notified
  37362. */
  37363. callback: (eventData: T, eventState: EventState) => void,
  37364. /**
  37365. * Defines the mask of the observer (used to filter notifications)
  37366. */
  37367. mask: number,
  37368. /**
  37369. * Defines the current scope used to restore the JS context
  37370. */
  37371. scope?: any);
  37372. }
  37373. /**
  37374. * Represent a list of observers registered to multiple Observables object.
  37375. */
  37376. class MultiObserver<T> {
  37377. private _observers;
  37378. private _observables;
  37379. /**
  37380. * Release associated resources
  37381. */
  37382. dispose(): void;
  37383. /**
  37384. * Raise a callback when one of the observable will notify
  37385. * @param observables defines a list of observables to watch
  37386. * @param callback defines the callback to call on notification
  37387. * @param mask defines the mask used to filter notifications
  37388. * @param scope defines the current scope used to restore the JS context
  37389. * @returns the new MultiObserver
  37390. */
  37391. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  37392. }
  37393. /**
  37394. * The Observable class is a simple implementation of the Observable pattern.
  37395. *
  37396. * 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.
  37397. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  37398. * 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).
  37399. * 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.
  37400. */
  37401. class Observable<T> {
  37402. private _observers;
  37403. private _eventState;
  37404. private _onObserverAdded;
  37405. /**
  37406. * Creates a new observable
  37407. * @param onObserverAdded defines a callback to call when a new observer is added
  37408. */
  37409. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  37410. /**
  37411. * Create a new Observer with the specified callback
  37412. * @param callback the callback that will be executed for that Observer
  37413. * @param mask the mask used to filter observers
  37414. * @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.
  37415. * @param scope optional scope for the callback to be called from
  37416. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  37417. * @returns the new observer created for the callback
  37418. */
  37419. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  37420. /**
  37421. * Create a new Observer with the specified callback and unregisters after the next notification
  37422. * @param callback the callback that will be executed for that Observer
  37423. * @returns the new observer created for the callback
  37424. */
  37425. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  37426. /**
  37427. * Remove an Observer from the Observable object
  37428. * @param observer the instance of the Observer to remove
  37429. * @returns false if it doesn't belong to this Observable
  37430. */
  37431. remove(observer: Nullable<Observer<T>>): boolean;
  37432. /**
  37433. * Remove a callback from the Observable object
  37434. * @param callback the callback to remove
  37435. * @param scope optional scope. If used only the callbacks with this scope will be removed
  37436. * @returns false if it doesn't belong to this Observable
  37437. */
  37438. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  37439. private _deferUnregister;
  37440. private _remove;
  37441. /**
  37442. * Notify all Observers by calling their respective callback with the given data
  37443. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  37444. * @param eventData defines the data to send to all observers
  37445. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  37446. * @param target defines the original target of the state
  37447. * @param currentTarget defines the current target of the state
  37448. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  37449. */
  37450. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  37451. /**
  37452. * Calling this will execute each callback, expecting it to be a promise or return a value.
  37453. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  37454. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  37455. * and it is crucial that all callbacks will be executed.
  37456. * The order of the callbacks is kept, callbacks are not executed parallel.
  37457. *
  37458. * @param eventData The data to be sent to each callback
  37459. * @param mask is used to filter observers defaults to -1
  37460. * @param target defines the callback target (see EventState)
  37461. * @param currentTarget defines he current object in the bubbling phase
  37462. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  37463. */
  37464. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  37465. /**
  37466. * Notify a specific observer
  37467. * @param observer defines the observer to notify
  37468. * @param eventData defines the data to be sent to each callback
  37469. * @param mask is used to filter observers defaults to -1
  37470. */
  37471. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  37472. /**
  37473. * Gets a boolean indicating if the observable has at least one observer
  37474. * @returns true is the Observable has at least one Observer registered
  37475. */
  37476. hasObservers(): boolean;
  37477. /**
  37478. * Clear the list of observers
  37479. */
  37480. clear(): void;
  37481. /**
  37482. * Clone the current observable
  37483. * @returns a new observable
  37484. */
  37485. clone(): Observable<T>;
  37486. /**
  37487. * Does this observable handles observer registered with a given mask
  37488. * @param mask defines the mask to be tested
  37489. * @return whether or not one observer registered with the given mask is handeled
  37490. **/
  37491. hasSpecificMask(mask?: number): boolean;
  37492. }
  37493. }
  37494. declare module BABYLON {
  37495. /**
  37496. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37497. */
  37498. class PerformanceMonitor {
  37499. private _enabled;
  37500. private _rollingFrameTime;
  37501. private _lastFrameTimeMs;
  37502. /**
  37503. * constructor
  37504. * @param frameSampleSize The number of samples required to saturate the sliding window
  37505. */
  37506. constructor(frameSampleSize?: number);
  37507. /**
  37508. * Samples current frame
  37509. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37510. */
  37511. sampleFrame(timeMs?: number): void;
  37512. /**
  37513. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37514. */
  37515. readonly averageFrameTime: number;
  37516. /**
  37517. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37518. */
  37519. readonly averageFrameTimeVariance: number;
  37520. /**
  37521. * Returns the frame time of the most recent frame
  37522. */
  37523. readonly instantaneousFrameTime: number;
  37524. /**
  37525. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37526. */
  37527. readonly averageFPS: number;
  37528. /**
  37529. * Returns the average framerate in frames per second using the most recent frame time
  37530. */
  37531. readonly instantaneousFPS: number;
  37532. /**
  37533. * Returns true if enough samples have been taken to completely fill the sliding window
  37534. */
  37535. readonly isSaturated: boolean;
  37536. /**
  37537. * Enables contributions to the sliding window sample set
  37538. */
  37539. enable(): void;
  37540. /**
  37541. * Disables contributions to the sliding window sample set
  37542. * Samples will not be interpolated over the disabled period
  37543. */
  37544. disable(): void;
  37545. /**
  37546. * Returns true if sampling is enabled
  37547. */
  37548. readonly isEnabled: boolean;
  37549. /**
  37550. * Resets performance monitor
  37551. */
  37552. reset(): void;
  37553. }
  37554. /**
  37555. * RollingAverage
  37556. *
  37557. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37558. */
  37559. class RollingAverage {
  37560. /**
  37561. * Current average
  37562. */
  37563. average: number;
  37564. /**
  37565. * Current variance
  37566. */
  37567. variance: number;
  37568. protected _samples: Array<number>;
  37569. protected _sampleCount: number;
  37570. protected _pos: number;
  37571. protected _m2: number;
  37572. /**
  37573. * constructor
  37574. * @param length The number of samples required to saturate the sliding window
  37575. */
  37576. constructor(length: number);
  37577. /**
  37578. * Adds a sample to the sample set
  37579. * @param v The sample value
  37580. */
  37581. add(v: number): void;
  37582. /**
  37583. * Returns previously added values or null if outside of history or outside the sliding window domain
  37584. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37585. * @return Value previously recorded with add() or null if outside of range
  37586. */
  37587. history(i: number): number;
  37588. /**
  37589. * Returns true if enough samples have been taken to completely fill the sliding window
  37590. * @return true if sample-set saturated
  37591. */
  37592. isSaturated(): boolean;
  37593. /**
  37594. * Resets the rolling average (equivalent to 0 samples taken so far)
  37595. */
  37596. reset(): void;
  37597. /**
  37598. * Wraps a value around the sample range boundaries
  37599. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37600. * @return Wrapped position in sample range
  37601. */
  37602. protected _wrapPosition(i: number): number;
  37603. }
  37604. }
  37605. declare module BABYLON {
  37606. /**
  37607. * Helper class that provides a small promise polyfill
  37608. */
  37609. class PromisePolyfill {
  37610. /**
  37611. * Static function used to check if the polyfill is required
  37612. * If this is the case then the function will inject the polyfill to window.Promise
  37613. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37614. */
  37615. static Apply(force?: boolean): void;
  37616. }
  37617. }
  37618. declare module BABYLON {
  37619. /**
  37620. * Defines the root class used to create scene optimization to use with SceneOptimizer
  37621. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37622. */
  37623. class SceneOptimization {
  37624. /**
  37625. * Defines the priority of this optimization (0 by default which means first in the list)
  37626. */
  37627. priority: number;
  37628. /**
  37629. * Gets a string describing the action executed by the current optimization
  37630. * @returns description string
  37631. */
  37632. getDescription(): string;
  37633. /**
  37634. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37635. * @param scene defines the current scene where to apply this optimization
  37636. * @param optimizer defines the current optimizer
  37637. * @returns true if everything that can be done was applied
  37638. */
  37639. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37640. /**
  37641. * Creates the SceneOptimization object
  37642. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37643. * @param desc defines the description associated with the optimization
  37644. */
  37645. constructor(
  37646. /**
  37647. * Defines the priority of this optimization (0 by default which means first in the list)
  37648. */
  37649. priority?: number);
  37650. }
  37651. /**
  37652. * Defines an optimization used to reduce the size of render target textures
  37653. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37654. */
  37655. class TextureOptimization extends SceneOptimization {
  37656. /**
  37657. * Defines the priority of this optimization (0 by default which means first in the list)
  37658. */
  37659. priority: number;
  37660. /**
  37661. * 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
  37662. */
  37663. maximumSize: number;
  37664. /**
  37665. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  37666. */
  37667. step: number;
  37668. /**
  37669. * Gets a string describing the action executed by the current optimization
  37670. * @returns description string
  37671. */
  37672. getDescription(): string;
  37673. /**
  37674. * Creates the TextureOptimization object
  37675. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37676. * @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
  37677. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  37678. */
  37679. constructor(
  37680. /**
  37681. * Defines the priority of this optimization (0 by default which means first in the list)
  37682. */
  37683. priority?: number,
  37684. /**
  37685. * 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
  37686. */
  37687. maximumSize?: number,
  37688. /**
  37689. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  37690. */
  37691. step?: number);
  37692. /**
  37693. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37694. * @param scene defines the current scene where to apply this optimization
  37695. * @param optimizer defines the current optimizer
  37696. * @returns true if everything that can be done was applied
  37697. */
  37698. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37699. }
  37700. /**
  37701. * Defines an optimization used to increase or decrease the rendering resolution
  37702. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37703. */
  37704. class HardwareScalingOptimization extends SceneOptimization {
  37705. /**
  37706. * Defines the priority of this optimization (0 by default which means first in the list)
  37707. */
  37708. priority: number;
  37709. /**
  37710. * Defines the maximum scale to use (2 by default)
  37711. */
  37712. maximumScale: number;
  37713. /**
  37714. * Defines the step to use between two passes (0.5 by default)
  37715. */
  37716. step: number;
  37717. private _currentScale;
  37718. private _directionOffset;
  37719. /**
  37720. * Gets a string describing the action executed by the current optimization
  37721. * @return description string
  37722. */
  37723. getDescription(): string;
  37724. /**
  37725. * Creates the HardwareScalingOptimization object
  37726. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37727. * @param maximumScale defines the maximum scale to use (2 by default)
  37728. * @param step defines the step to use between two passes (0.5 by default)
  37729. */
  37730. constructor(
  37731. /**
  37732. * Defines the priority of this optimization (0 by default which means first in the list)
  37733. */
  37734. priority?: number,
  37735. /**
  37736. * Defines the maximum scale to use (2 by default)
  37737. */
  37738. maximumScale?: number,
  37739. /**
  37740. * Defines the step to use between two passes (0.5 by default)
  37741. */
  37742. step?: number);
  37743. /**
  37744. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37745. * @param scene defines the current scene where to apply this optimization
  37746. * @param optimizer defines the current optimizer
  37747. * @returns true if everything that can be done was applied
  37748. */
  37749. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37750. }
  37751. /**
  37752. * Defines an optimization used to remove shadows
  37753. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37754. */
  37755. class ShadowsOptimization extends SceneOptimization {
  37756. /**
  37757. * Gets a string describing the action executed by the current optimization
  37758. * @return description string
  37759. */
  37760. getDescription(): string;
  37761. /**
  37762. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37763. * @param scene defines the current scene where to apply this optimization
  37764. * @param optimizer defines the current optimizer
  37765. * @returns true if everything that can be done was applied
  37766. */
  37767. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37768. }
  37769. /**
  37770. * Defines an optimization used to turn post-processes off
  37771. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37772. */
  37773. class PostProcessesOptimization extends SceneOptimization {
  37774. /**
  37775. * Gets a string describing the action executed by the current optimization
  37776. * @return description string
  37777. */
  37778. getDescription(): string;
  37779. /**
  37780. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37781. * @param scene defines the current scene where to apply this optimization
  37782. * @param optimizer defines the current optimizer
  37783. * @returns true if everything that can be done was applied
  37784. */
  37785. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37786. }
  37787. /**
  37788. * Defines an optimization used to turn lens flares off
  37789. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37790. */
  37791. class LensFlaresOptimization extends SceneOptimization {
  37792. /**
  37793. * Gets a string describing the action executed by the current optimization
  37794. * @return description string
  37795. */
  37796. getDescription(): string;
  37797. /**
  37798. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37799. * @param scene defines the current scene where to apply this optimization
  37800. * @param optimizer defines the current optimizer
  37801. * @returns true if everything that can be done was applied
  37802. */
  37803. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37804. }
  37805. /**
  37806. * Defines an optimization based on user defined callback.
  37807. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37808. */
  37809. class CustomOptimization extends SceneOptimization {
  37810. /**
  37811. * Callback called to apply the custom optimization.
  37812. */
  37813. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  37814. /**
  37815. * Callback called to get custom description
  37816. */
  37817. onGetDescription: () => string;
  37818. /**
  37819. * Gets a string describing the action executed by the current optimization
  37820. * @returns description string
  37821. */
  37822. getDescription(): string;
  37823. /**
  37824. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37825. * @param scene defines the current scene where to apply this optimization
  37826. * @param optimizer defines the current optimizer
  37827. * @returns true if everything that can be done was applied
  37828. */
  37829. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37830. }
  37831. /**
  37832. * Defines an optimization used to turn particles off
  37833. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37834. */
  37835. class ParticlesOptimization extends SceneOptimization {
  37836. /**
  37837. * Gets a string describing the action executed by the current optimization
  37838. * @return description string
  37839. */
  37840. getDescription(): string;
  37841. /**
  37842. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37843. * @param scene defines the current scene where to apply this optimization
  37844. * @param optimizer defines the current optimizer
  37845. * @returns true if everything that can be done was applied
  37846. */
  37847. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37848. }
  37849. /**
  37850. * Defines an optimization used to turn render targets off
  37851. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37852. */
  37853. class RenderTargetsOptimization extends SceneOptimization {
  37854. /**
  37855. * Gets a string describing the action executed by the current optimization
  37856. * @return description string
  37857. */
  37858. getDescription(): string;
  37859. /**
  37860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37861. * @param scene defines the current scene where to apply this optimization
  37862. * @param optimizer defines the current optimizer
  37863. * @returns true if everything that can be done was applied
  37864. */
  37865. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37866. }
  37867. /**
  37868. * Defines an optimization used to merge meshes with compatible materials
  37869. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37870. */
  37871. class MergeMeshesOptimization extends SceneOptimization {
  37872. private static _UpdateSelectionTree;
  37873. /**
  37874. * Gets or sets a boolean which defines if optimization octree has to be updated
  37875. */
  37876. /**
  37877. * Gets or sets a boolean which defines if optimization octree has to be updated
  37878. */
  37879. static UpdateSelectionTree: boolean;
  37880. /**
  37881. * Gets a string describing the action executed by the current optimization
  37882. * @return description string
  37883. */
  37884. getDescription(): string;
  37885. private _canBeMerged;
  37886. /**
  37887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37888. * @param scene defines the current scene where to apply this optimization
  37889. * @param optimizer defines the current optimizer
  37890. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  37891. * @returns true if everything that can be done was applied
  37892. */
  37893. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  37894. }
  37895. /**
  37896. * Defines a list of options used by SceneOptimizer
  37897. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37898. */
  37899. class SceneOptimizerOptions {
  37900. /**
  37901. * Defines the target frame rate to reach (60 by default)
  37902. */
  37903. targetFrameRate: number;
  37904. /**
  37905. * Defines the interval between two checkes (2000ms by default)
  37906. */
  37907. trackerDuration: number;
  37908. /**
  37909. * Gets the list of optimizations to apply
  37910. */
  37911. optimizations: SceneOptimization[];
  37912. /**
  37913. * Creates a new list of options used by SceneOptimizer
  37914. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  37915. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  37916. */
  37917. constructor(
  37918. /**
  37919. * Defines the target frame rate to reach (60 by default)
  37920. */
  37921. targetFrameRate?: number,
  37922. /**
  37923. * Defines the interval between two checkes (2000ms by default)
  37924. */
  37925. trackerDuration?: number);
  37926. /**
  37927. * Add a new optimization
  37928. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  37929. * @returns the current SceneOptimizerOptions
  37930. */
  37931. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  37932. /**
  37933. * Add a new custom optimization
  37934. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  37935. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  37936. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37937. * @returns the current SceneOptimizerOptions
  37938. */
  37939. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  37940. /**
  37941. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  37942. * @param targetFrameRate defines the target frame rate (60 by default)
  37943. * @returns a SceneOptimizerOptions object
  37944. */
  37945. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  37946. /**
  37947. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  37948. * @param targetFrameRate defines the target frame rate (60 by default)
  37949. * @returns a SceneOptimizerOptions object
  37950. */
  37951. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  37952. /**
  37953. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  37954. * @param targetFrameRate defines the target frame rate (60 by default)
  37955. * @returns a SceneOptimizerOptions object
  37956. */
  37957. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  37958. }
  37959. /**
  37960. * Class used to run optimizations in order to reach a target frame rate
  37961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37962. */
  37963. class SceneOptimizer implements IDisposable {
  37964. private _isRunning;
  37965. private _options;
  37966. private _scene;
  37967. private _currentPriorityLevel;
  37968. private _targetFrameRate;
  37969. private _trackerDuration;
  37970. private _currentFrameRate;
  37971. private _sceneDisposeObserver;
  37972. private _improvementMode;
  37973. /**
  37974. * Defines an observable called when the optimizer reaches the target frame rate
  37975. */
  37976. onSuccessObservable: Observable<SceneOptimizer>;
  37977. /**
  37978. * Defines an observable called when the optimizer enables an optimization
  37979. */
  37980. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  37981. /**
  37982. * Defines an observable called when the optimizer is not able to reach the target frame rate
  37983. */
  37984. onFailureObservable: Observable<SceneOptimizer>;
  37985. /**
  37986. * Gets a boolean indicating if the optimizer is in improvement mode
  37987. */
  37988. readonly isInImprovementMode: boolean;
  37989. /**
  37990. * Gets the current priority level (0 at start)
  37991. */
  37992. readonly currentPriorityLevel: number;
  37993. /**
  37994. * Gets the current frame rate checked by the SceneOptimizer
  37995. */
  37996. readonly currentFrameRate: number;
  37997. /**
  37998. * Gets or sets the current target frame rate (60 by default)
  37999. */
  38000. /**
  38001. * Gets or sets the current target frame rate (60 by default)
  38002. */
  38003. targetFrameRate: number;
  38004. /**
  38005. * Gets or sets the current interval between two checks (every 2000ms by default)
  38006. */
  38007. /**
  38008. * Gets or sets the current interval between two checks (every 2000ms by default)
  38009. */
  38010. trackerDuration: number;
  38011. /**
  38012. * Gets the list of active optimizations
  38013. */
  38014. readonly optimizations: SceneOptimization[];
  38015. /**
  38016. * Creates a new SceneOptimizer
  38017. * @param scene defines the scene to work on
  38018. * @param options defines the options to use with the SceneOptimizer
  38019. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38020. * @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)
  38021. */
  38022. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38023. /**
  38024. * Stops the current optimizer
  38025. */
  38026. stop(): void;
  38027. /**
  38028. * Reset the optimizer to initial step (current priority level = 0)
  38029. */
  38030. reset(): void;
  38031. /**
  38032. * Start the optimizer. By default it will try to reach a specific framerate
  38033. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38034. */
  38035. start(): void;
  38036. private _checkCurrentState;
  38037. /**
  38038. * Release all resources
  38039. */
  38040. dispose(): void;
  38041. /**
  38042. * Helper function to create a SceneOptimizer with one single line of code
  38043. * @param scene defines the scene to work on
  38044. * @param options defines the options to use with the SceneOptimizer
  38045. * @param onSuccess defines a callback to call on success
  38046. * @param onFailure defines a callback to call on failure
  38047. * @returns the new SceneOptimizer object
  38048. */
  38049. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38050. }
  38051. }
  38052. declare module BABYLON {
  38053. /**
  38054. * Class used to serialize a scene into a string
  38055. */
  38056. class SceneSerializer {
  38057. /**
  38058. * Clear cache used by a previous serialization
  38059. */
  38060. static ClearCache(): void;
  38061. /**
  38062. * Serialize a scene into a JSON compatible object
  38063. * @param scene defines the scene to serialize
  38064. * @returns a JSON compatible object
  38065. */
  38066. static Serialize(scene: Scene): any;
  38067. /**
  38068. * Serialize a mesh into a JSON compatible object
  38069. * @param toSerialize defines the mesh to serialize
  38070. * @param withParents defines if parents must be serialized as well
  38071. * @param withChildren defines if children must be serialized as well
  38072. * @returns a JSON compatible object
  38073. */
  38074. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  38075. }
  38076. }
  38077. declare module BABYLON {
  38078. /**
  38079. * Defines an array and its length.
  38080. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  38081. */
  38082. interface ISmartArrayLike<T> {
  38083. /**
  38084. * The data of the array.
  38085. */
  38086. data: Array<T>;
  38087. /**
  38088. * The active length of the array.
  38089. */
  38090. length: number;
  38091. }
  38092. /**
  38093. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38094. */
  38095. class SmartArray<T> implements ISmartArrayLike<T> {
  38096. /**
  38097. * The full set of data from the array.
  38098. */
  38099. data: Array<T>;
  38100. /**
  38101. * The active length of the array.
  38102. */
  38103. length: number;
  38104. protected _id: number;
  38105. /**
  38106. * Instantiates a Smart Array.
  38107. * @param capacity defines the default capacity of the array.
  38108. */
  38109. constructor(capacity: number);
  38110. /**
  38111. * Pushes a value at the end of the active data.
  38112. * @param value defines the object to push in the array.
  38113. */
  38114. push(value: T): void;
  38115. /**
  38116. * Iterates over the active data and apply the lambda to them.
  38117. * @param func defines the action to apply on each value.
  38118. */
  38119. forEach(func: (content: T) => void): void;
  38120. /**
  38121. * Sorts the full sets of data.
  38122. * @param compareFn defines the comparison function to apply.
  38123. */
  38124. sort(compareFn: (a: T, b: T) => number): void;
  38125. /**
  38126. * Resets the active data to an empty array.
  38127. */
  38128. reset(): void;
  38129. /**
  38130. * Releases all the data from the array as well as the array.
  38131. */
  38132. dispose(): void;
  38133. /**
  38134. * Concats the active data with a given array.
  38135. * @param array defines the data to concatenate with.
  38136. */
  38137. concat(array: any): void;
  38138. /**
  38139. * Returns the position of a value in the active data.
  38140. * @param value defines the value to find the index for
  38141. * @returns the index if found in the active data otherwise -1
  38142. */
  38143. indexOf(value: T): number;
  38144. /**
  38145. * Returns whether an element is part of the active data.
  38146. * @param value defines the value to look for
  38147. * @returns true if found in the active data otherwise false
  38148. */
  38149. contains(value: T): boolean;
  38150. private static _GlobalId;
  38151. }
  38152. /**
  38153. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38154. * The data in this array can only be present once
  38155. */
  38156. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  38157. private _duplicateId;
  38158. /**
  38159. * Pushes a value at the end of the active data.
  38160. * THIS DOES NOT PREVENT DUPPLICATE DATA
  38161. * @param value defines the object to push in the array.
  38162. */
  38163. push(value: T): void;
  38164. /**
  38165. * Pushes a value at the end of the active data.
  38166. * If the data is already present, it won t be added again
  38167. * @param value defines the object to push in the array.
  38168. * @returns true if added false if it was already present
  38169. */
  38170. pushNoDuplicate(value: T): boolean;
  38171. /**
  38172. * Resets the active data to an empty array.
  38173. */
  38174. reset(): void;
  38175. /**
  38176. * Concats the active data with a given array.
  38177. * This ensures no dupplicate will be present in the result.
  38178. * @param array defines the data to concatenate with.
  38179. */
  38180. concatWithNoDuplicate(array: any): void;
  38181. }
  38182. }
  38183. declare module BABYLON {
  38184. /**
  38185. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38186. * The underlying implementation relies on an associative array to ensure the best performances.
  38187. * The value can be anything including 'null' but except 'undefined'
  38188. */
  38189. class StringDictionary<T> {
  38190. /**
  38191. * This will clear this dictionary and copy the content from the 'source' one.
  38192. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38193. * @param source the dictionary to take the content from and copy to this dictionary
  38194. */
  38195. copyFrom(source: StringDictionary<T>): void;
  38196. /**
  38197. * Get a value based from its key
  38198. * @param key the given key to get the matching value from
  38199. * @return the value if found, otherwise undefined is returned
  38200. */
  38201. get(key: string): T | undefined;
  38202. /**
  38203. * Get a value from its key or add it if it doesn't exist.
  38204. * This method will ensure you that a given key/data will be present in the dictionary.
  38205. * @param key the given key to get the matching value from
  38206. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38207. * The factory will only be invoked if there's no data for the given key.
  38208. * @return the value corresponding to the key.
  38209. */
  38210. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38211. /**
  38212. * Get a value from its key if present in the dictionary otherwise add it
  38213. * @param key the key to get the value from
  38214. * @param val if there's no such key/value pair in the dictionary add it with this value
  38215. * @return the value corresponding to the key
  38216. */
  38217. getOrAdd(key: string, val: T): T;
  38218. /**
  38219. * Check if there's a given key in the dictionary
  38220. * @param key the key to check for
  38221. * @return true if the key is present, false otherwise
  38222. */
  38223. contains(key: string): boolean;
  38224. /**
  38225. * Add a new key and its corresponding value
  38226. * @param key the key to add
  38227. * @param value the value corresponding to the key
  38228. * @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
  38229. */
  38230. add(key: string, value: T): boolean;
  38231. /**
  38232. * Update a specific value associated to a key
  38233. * @param key defines the key to use
  38234. * @param value defines the value to store
  38235. * @returns true if the value was updated (or false if the key was not found)
  38236. */
  38237. set(key: string, value: T): boolean;
  38238. /**
  38239. * Get the element of the given key and remove it from the dictionary
  38240. * @param key defines the key to search
  38241. * @returns the value associated with the key or null if not found
  38242. */
  38243. getAndRemove(key: string): Nullable<T>;
  38244. /**
  38245. * Remove a key/value from the dictionary.
  38246. * @param key the key to remove
  38247. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38248. */
  38249. remove(key: string): boolean;
  38250. /**
  38251. * Clear the whole content of the dictionary
  38252. */
  38253. clear(): void;
  38254. /**
  38255. * Gets the current count
  38256. */
  38257. readonly count: number;
  38258. /**
  38259. * Execute a callback on each key/val of the dictionary.
  38260. * Note that you can remove any element in this dictionary in the callback implementation
  38261. * @param callback the callback to execute on a given key/value pair
  38262. */
  38263. forEach(callback: (key: string, val: T) => void): void;
  38264. /**
  38265. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38266. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38267. * Note that you can remove any element in this dictionary in the callback implementation
  38268. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38269. * @returns the first item
  38270. */
  38271. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38272. private _count;
  38273. private _data;
  38274. }
  38275. }
  38276. declare module BABYLON {
  38277. /**
  38278. * Class used to store custom tags
  38279. */
  38280. class Tags {
  38281. /**
  38282. * Adds support for tags on the given object
  38283. * @param obj defines the object to use
  38284. */
  38285. static EnableFor(obj: any): void;
  38286. /**
  38287. * Removes tags support
  38288. * @param obj defines the object to use
  38289. */
  38290. static DisableFor(obj: any): void;
  38291. /**
  38292. * Gets a boolean indicating if the given object has tags
  38293. * @param obj defines the object to use
  38294. * @returns a boolean
  38295. */
  38296. static HasTags(obj: any): boolean;
  38297. /**
  38298. * Gets the tags available on a given object
  38299. * @param obj defines the object to use
  38300. * @param asString defines if the tags must be returned as a string instead of an array of strings
  38301. * @returns the tags
  38302. */
  38303. static GetTags(obj: any, asString?: boolean): any;
  38304. /**
  38305. * Adds tags to an object
  38306. * @param obj defines the object to use
  38307. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  38308. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  38309. */
  38310. static AddTagsTo(obj: any, tagsString: string): void;
  38311. /**
  38312. * @hidden
  38313. */
  38314. static _AddTagTo(obj: any, tag: string): void;
  38315. /**
  38316. * Removes specific tags from a specific object
  38317. * @param obj defines the object to use
  38318. * @param tagsString defines the tags to remove
  38319. */
  38320. static RemoveTagsFrom(obj: any, tagsString: string): void;
  38321. /**
  38322. * @hidden
  38323. */
  38324. static _RemoveTagFrom(obj: any, tag: string): void;
  38325. /**
  38326. * Defines if tags hosted on an object match a given query
  38327. * @param obj defines the object to use
  38328. * @param tagsQuery defines the tag query
  38329. * @returns a boolean
  38330. */
  38331. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  38332. }
  38333. }
  38334. declare module BABYLON {
  38335. /**
  38336. * Class used to host texture specific utilities
  38337. */
  38338. class TextureTools {
  38339. /**
  38340. * Uses the GPU to create a copy texture rescaled at a given size
  38341. * @param texture Texture to copy from
  38342. * @param width defines the desired width
  38343. * @param height defines the desired height
  38344. * @param useBilinearMode defines if bilinear mode has to be used
  38345. * @return the generated texture
  38346. */
  38347. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  38348. /**
  38349. * Gets an environment BRDF texture for a given scene
  38350. * @param scene defines the hosting scene
  38351. * @returns the environment BRDF texture
  38352. */
  38353. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  38354. private static _environmentBRDFBase64Texture;
  38355. }
  38356. }
  38357. declare module BABYLON {
  38358. /**
  38359. * Based on jsTGALoader - Javascript loader for TGA file
  38360. * By Vincent Thibault
  38361. * @see http://blog.robrowser.com/javascript-tga-loader.html
  38362. */
  38363. class TGATools {
  38364. private static _TYPE_INDEXED;
  38365. private static _TYPE_RGB;
  38366. private static _TYPE_GREY;
  38367. private static _TYPE_RLE_INDEXED;
  38368. private static _TYPE_RLE_RGB;
  38369. private static _TYPE_RLE_GREY;
  38370. private static _ORIGIN_MASK;
  38371. private static _ORIGIN_SHIFT;
  38372. private static _ORIGIN_BL;
  38373. private static _ORIGIN_BR;
  38374. private static _ORIGIN_UL;
  38375. private static _ORIGIN_UR;
  38376. /**
  38377. * Gets the header of a TGA file
  38378. * @param data defines the TGA data
  38379. * @returns the header
  38380. */
  38381. static GetTGAHeader(data: Uint8Array): any;
  38382. /**
  38383. * Uploads TGA content to a Babylon Texture
  38384. * @hidden
  38385. */
  38386. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  38387. /** @hidden */
  38388. 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;
  38389. /** @hidden */
  38390. 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;
  38391. /** @hidden */
  38392. 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;
  38393. /** @hidden */
  38394. 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;
  38395. /** @hidden */
  38396. 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;
  38397. /** @hidden */
  38398. 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;
  38399. }
  38400. }
  38401. declare module BABYLON {
  38402. /**
  38403. * Interface containing an array of animations
  38404. */
  38405. interface IAnimatable {
  38406. /**
  38407. * Array of animations
  38408. */
  38409. animations: Array<Animation>;
  38410. }
  38411. /** Interface used by value gradients (color, factor, ...) */
  38412. interface IValueGradient {
  38413. /**
  38414. * Gets or sets the gradient value (between 0 and 1)
  38415. */
  38416. gradient: number;
  38417. }
  38418. /** Class used to store color4 gradient */
  38419. class ColorGradient implements IValueGradient {
  38420. /**
  38421. * Gets or sets the gradient value (between 0 and 1)
  38422. */
  38423. gradient: number;
  38424. /**
  38425. * Gets or sets first associated color
  38426. */
  38427. color1: Color4;
  38428. /**
  38429. * Gets or sets second associated color
  38430. */
  38431. color2?: Color4;
  38432. /**
  38433. * Will get a color picked randomly between color1 and color2.
  38434. * If color2 is undefined then color1 will be used
  38435. * @param result defines the target Color4 to store the result in
  38436. */
  38437. getColorToRef(result: Color4): void;
  38438. }
  38439. /** Class used to store color 3 gradient */
  38440. class Color3Gradient implements IValueGradient {
  38441. /**
  38442. * Gets or sets the gradient value (between 0 and 1)
  38443. */
  38444. gradient: number;
  38445. /**
  38446. * Gets or sets the associated color
  38447. */
  38448. color: Color3;
  38449. }
  38450. /** Class used to store factor gradient */
  38451. class FactorGradient implements IValueGradient {
  38452. /**
  38453. * Gets or sets the gradient value (between 0 and 1)
  38454. */
  38455. gradient: number;
  38456. /**
  38457. * Gets or sets first associated factor
  38458. */
  38459. factor1: number;
  38460. /**
  38461. * Gets or sets second associated factor
  38462. */
  38463. factor2?: number;
  38464. /**
  38465. * Will get a number picked randomly between factor1 and factor2.
  38466. * If factor2 is undefined then factor1 will be used
  38467. * @returns the picked number
  38468. */
  38469. getFactor(): number;
  38470. }
  38471. /**
  38472. * @ignore
  38473. * Application error to support additional information when loading a file
  38474. */
  38475. class LoadFileError extends Error {
  38476. /** defines the optional XHR request */
  38477. request?: XMLHttpRequest | undefined;
  38478. private static _setPrototypeOf;
  38479. /**
  38480. * Creates a new LoadFileError
  38481. * @param message defines the message of the error
  38482. * @param request defines the optional XHR request
  38483. */
  38484. constructor(message: string,
  38485. /** defines the optional XHR request */
  38486. request?: XMLHttpRequest | undefined);
  38487. }
  38488. /**
  38489. * Class used to define a retry strategy when error happens while loading assets
  38490. */
  38491. class RetryStrategy {
  38492. /**
  38493. * Function used to defines an exponential back off strategy
  38494. * @param maxRetries defines the maximum number of retries (3 by default)
  38495. * @param baseInterval defines the interval between retries
  38496. * @returns the strategy function to use
  38497. */
  38498. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  38499. }
  38500. /**
  38501. * File request interface
  38502. */
  38503. interface IFileRequest {
  38504. /**
  38505. * Raised when the request is complete (success or error).
  38506. */
  38507. onCompleteObservable: Observable<IFileRequest>;
  38508. /**
  38509. * Aborts the request for a file.
  38510. */
  38511. abort: () => void;
  38512. }
  38513. /**
  38514. * Class containing a set of static utilities functions
  38515. */
  38516. class Tools {
  38517. /**
  38518. * Gets or sets the base URL to use to load assets
  38519. */
  38520. static BaseUrl: string;
  38521. /**
  38522. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38523. */
  38524. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  38525. /**
  38526. * Default behaviour for cors in the application.
  38527. * It can be a string if the expected behavior is identical in the entire app.
  38528. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38529. */
  38530. static CorsBehavior: string | ((url: string | string[]) => string);
  38531. /**
  38532. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38533. * @ignorenaming
  38534. */
  38535. static UseFallbackTexture: boolean;
  38536. /**
  38537. * Use this object to register external classes like custom textures or material
  38538. * to allow the laoders to instantiate them
  38539. */
  38540. static RegisteredExternalClasses: {
  38541. [key: string]: Object;
  38542. };
  38543. /**
  38544. * Texture content used if a texture cannot loaded
  38545. * @ignorenaming
  38546. */
  38547. static fallbackTexture: string;
  38548. /**
  38549. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38550. * @param u defines the coordinate on X axis
  38551. * @param v defines the coordinate on Y axis
  38552. * @param width defines the width of the source data
  38553. * @param height defines the height of the source data
  38554. * @param pixels defines the source byte array
  38555. * @param color defines the output color
  38556. */
  38557. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  38558. /**
  38559. * Interpolates between a and b via alpha
  38560. * @param a The lower value (returned when alpha = 0)
  38561. * @param b The upper value (returned when alpha = 1)
  38562. * @param alpha The interpolation-factor
  38563. * @return The mixed value
  38564. */
  38565. static Mix(a: number, b: number, alpha: number): number;
  38566. /**
  38567. * Tries to instantiate a new object from a given class name
  38568. * @param className defines the class name to instantiate
  38569. * @returns the new object or null if the system was not able to do the instantiation
  38570. */
  38571. static Instantiate(className: string): any;
  38572. /**
  38573. * Provides a slice function that will work even on IE
  38574. * @param data defines the array to slice
  38575. * @param start defines the start of the data (optional)
  38576. * @param end defines the end of the data (optional)
  38577. * @returns the new sliced array
  38578. */
  38579. static Slice<T>(data: T, start?: number, end?: number): T;
  38580. /**
  38581. * Polyfill for setImmediate
  38582. * @param action defines the action to execute after the current execution block
  38583. */
  38584. static SetImmediate(action: () => void): void;
  38585. /**
  38586. * Function indicating if a number is an exponent of 2
  38587. * @param value defines the value to test
  38588. * @returns true if the value is an exponent of 2
  38589. */
  38590. static IsExponentOfTwo(value: number): boolean;
  38591. private static _tmpFloatArray;
  38592. /**
  38593. * Returns the nearest 32-bit single precision float representation of a Number
  38594. * @param value A Number. If the parameter is of a different type, it will get converted
  38595. * to a number or to NaN if it cannot be converted
  38596. * @returns number
  38597. */
  38598. static FloatRound(value: number): number;
  38599. /**
  38600. * Find the next highest power of two.
  38601. * @param x Number to start search from.
  38602. * @return Next highest power of two.
  38603. */
  38604. static CeilingPOT(x: number): number;
  38605. /**
  38606. * Find the next lowest power of two.
  38607. * @param x Number to start search from.
  38608. * @return Next lowest power of two.
  38609. */
  38610. static FloorPOT(x: number): number;
  38611. /**
  38612. * Find the nearest power of two.
  38613. * @param x Number to start search from.
  38614. * @return Next nearest power of two.
  38615. */
  38616. static NearestPOT(x: number): number;
  38617. /**
  38618. * Get the closest exponent of two
  38619. * @param value defines the value to approximate
  38620. * @param max defines the maximum value to return
  38621. * @param mode defines how to define the closest value
  38622. * @returns closest exponent of two of the given value
  38623. */
  38624. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  38625. /**
  38626. * Extracts the filename from a path
  38627. * @param path defines the path to use
  38628. * @returns the filename
  38629. */
  38630. static GetFilename(path: string): string;
  38631. /**
  38632. * Extracts the "folder" part of a path (everything before the filename).
  38633. * @param uri The URI to extract the info from
  38634. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38635. * @returns The "folder" part of the path
  38636. */
  38637. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38638. /**
  38639. * Extracts text content from a DOM element hierarchy
  38640. * @param element defines the root element
  38641. * @returns a string
  38642. */
  38643. static GetDOMTextContent(element: HTMLElement): string;
  38644. /**
  38645. * Convert an angle in radians to degrees
  38646. * @param angle defines the angle to convert
  38647. * @returns the angle in degrees
  38648. */
  38649. static ToDegrees(angle: number): number;
  38650. /**
  38651. * Convert an angle in degrees to radians
  38652. * @param angle defines the angle to convert
  38653. * @returns the angle in radians
  38654. */
  38655. static ToRadians(angle: number): number;
  38656. /**
  38657. * Encode a buffer to a base64 string
  38658. * @param buffer defines the buffer to encode
  38659. * @returns the encoded string
  38660. */
  38661. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  38662. /**
  38663. * Extracts minimum and maximum values from a list of indexed positions
  38664. * @param positions defines the positions to use
  38665. * @param indices defines the indices to the positions
  38666. * @param indexStart defines the start index
  38667. * @param indexCount defines the end index
  38668. * @param bias defines bias value to add to the result
  38669. * @return minimum and maximum values
  38670. */
  38671. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  38672. minimum: Vector3;
  38673. maximum: Vector3;
  38674. };
  38675. /**
  38676. * Extracts minimum and maximum values from a list of positions
  38677. * @param positions defines the positions to use
  38678. * @param start defines the start index in the positions array
  38679. * @param count defines the number of positions to handle
  38680. * @param bias defines bias value to add to the result
  38681. * @param stride defines the stride size to use (distance between two positions in the positions array)
  38682. * @return minimum and maximum values
  38683. */
  38684. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  38685. minimum: Vector3;
  38686. maximum: Vector3;
  38687. };
  38688. /**
  38689. * Returns an array if obj is not an array
  38690. * @param obj defines the object to evaluate as an array
  38691. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38692. * @returns either obj directly if obj is an array or a new array containing obj
  38693. */
  38694. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38695. /**
  38696. * Gets the pointer prefix to use
  38697. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38698. */
  38699. static GetPointerPrefix(): string;
  38700. /**
  38701. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  38702. * @param func - the function to be called
  38703. * @param requester - the object that will request the next frame. Falls back to window.
  38704. * @returns frame number
  38705. */
  38706. static QueueNewFrame(func: () => void, requester?: any): number;
  38707. /**
  38708. * Ask the browser to promote the current element to fullscreen rendering mode
  38709. * @param element defines the DOM element to promote
  38710. */
  38711. static RequestFullscreen(element: HTMLElement): void;
  38712. /**
  38713. * Asks the browser to exit fullscreen mode
  38714. */
  38715. static ExitFullscreen(): void;
  38716. /**
  38717. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38718. * @param url define the url we are trying
  38719. * @param element define the dom element where to configure the cors policy
  38720. */
  38721. static SetCorsBehavior(url: string | string[], element: {
  38722. crossOrigin: string | null;
  38723. }): void;
  38724. /**
  38725. * Removes unwanted characters from an url
  38726. * @param url defines the url to clean
  38727. * @returns the cleaned url
  38728. */
  38729. static CleanUrl(url: string): string;
  38730. /**
  38731. * Gets or sets a function used to pre-process url before using them to load assets
  38732. */
  38733. static PreprocessUrl: (url: string) => string;
  38734. /**
  38735. * Loads an image as an HTMLImageElement.
  38736. * @param input url string, ArrayBuffer, or Blob to load
  38737. * @param onLoad callback called when the image successfully loads
  38738. * @param onError callback called when the image fails to load
  38739. * @param database database for caching
  38740. * @returns the HTMLImageElement of the loaded image
  38741. */
  38742. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  38743. /**
  38744. * Loads a file
  38745. * @param url url string, ArrayBuffer, or Blob to load
  38746. * @param onSuccess callback called when the file successfully loads
  38747. * @param onProgress callback called while file is loading (if the server supports this mode)
  38748. * @param database database for caching
  38749. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38750. * @param onError callback called when the file fails to load
  38751. * @returns a file request object
  38752. */
  38753. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  38754. /**
  38755. * Load a script (identified by an url). When the url returns, the
  38756. * content of this file is added into a new script element, attached to the DOM (body element)
  38757. * @param scriptUrl defines the url of the script to laod
  38758. * @param onSuccess defines the callback called when the script is loaded
  38759. * @param onError defines the callback to call if an error occurs
  38760. */
  38761. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  38762. /**
  38763. * Loads a file from a blob
  38764. * @param fileToLoad defines the blob to use
  38765. * @param callback defines the callback to call when data is loaded
  38766. * @param progressCallback defines the callback to call during loading process
  38767. * @returns a file request object
  38768. */
  38769. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38770. /**
  38771. * Loads a file
  38772. * @param fileToLoad defines the file to load
  38773. * @param callback defines the callback to call when data is loaded
  38774. * @param progressCallBack defines the callback to call during loading process
  38775. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38776. * @returns a file request object
  38777. */
  38778. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  38779. /**
  38780. * Creates a data url from a given string content
  38781. * @param content defines the content to convert
  38782. * @returns the new data url link
  38783. */
  38784. static FileAsURL(content: string): string;
  38785. /**
  38786. * Format the given number to a specific decimal format
  38787. * @param value defines the number to format
  38788. * @param decimals defines the number of decimals to use
  38789. * @returns the formatted string
  38790. */
  38791. static Format(value: number, decimals?: number): string;
  38792. /**
  38793. * Checks if a given vector is inside a specific range
  38794. * @param v defines the vector to test
  38795. * @param min defines the minimum range
  38796. * @param max defines the maximum range
  38797. */
  38798. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  38799. /**
  38800. * Tries to copy an object by duplicating every property
  38801. * @param source defines the source object
  38802. * @param destination defines the target object
  38803. * @param doNotCopyList defines a list of properties to avoid
  38804. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38805. */
  38806. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38807. /**
  38808. * Gets a boolean indicating if the given object has no own property
  38809. * @param obj defines the object to test
  38810. * @returns true if object has no own property
  38811. */
  38812. static IsEmpty(obj: any): boolean;
  38813. /**
  38814. * Function used to register events at window level
  38815. * @param events defines the events to register
  38816. */
  38817. static RegisterTopRootEvents(events: {
  38818. name: string;
  38819. handler: Nullable<(e: FocusEvent) => any>;
  38820. }[]): void;
  38821. /**
  38822. * Function used to unregister events from window level
  38823. * @param events defines the events to unregister
  38824. */
  38825. static UnregisterTopRootEvents(events: {
  38826. name: string;
  38827. handler: Nullable<(e: FocusEvent) => any>;
  38828. }[]): void;
  38829. /**
  38830. * Dumps the current bound framebuffer
  38831. * @param width defines the rendering width
  38832. * @param height defines the rendering height
  38833. * @param engine defines the hosting engine
  38834. * @param successCallback defines the callback triggered once the data are available
  38835. * @param mimeType defines the mime type of the result
  38836. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38837. */
  38838. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38839. /**
  38840. * Converts the canvas data to blob.
  38841. * This acts as a polyfill for browsers not supporting the to blob function.
  38842. * @param canvas Defines the canvas to extract the data from
  38843. * @param successCallback Defines the callback triggered once the data are available
  38844. * @param mimeType Defines the mime type of the result
  38845. */
  38846. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38847. /**
  38848. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38849. * @param successCallback defines the callback triggered once the data are available
  38850. * @param mimeType defines the mime type of the result
  38851. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38852. */
  38853. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38854. /**
  38855. * Downloads a blob in the browser
  38856. * @param blob defines the blob to download
  38857. * @param fileName defines the name of the downloaded file
  38858. */
  38859. static Download(blob: Blob, fileName: string): void;
  38860. /**
  38861. * Captures a screenshot of the current rendering
  38862. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38863. * @param engine defines the rendering engine
  38864. * @param camera defines the source camera
  38865. * @param size This parameter can be set to a single number or to an object with the
  38866. * following (optional) properties: precision, width, height. If a single number is passed,
  38867. * it will be used for both width and height. If an object is passed, the screenshot size
  38868. * will be derived from the parameters. The precision property is a multiplier allowing
  38869. * rendering at a higher or lower resolution
  38870. * @param successCallback defines the callback receives a single parameter which contains the
  38871. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38872. * src parameter of an <img> to display it
  38873. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38874. * Check your browser for supported MIME types
  38875. */
  38876. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  38877. /**
  38878. * Generates an image screenshot from the specified camera.
  38879. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38880. * @param engine The engine to use for rendering
  38881. * @param camera The camera to use for rendering
  38882. * @param size This parameter can be set to a single number or to an object with the
  38883. * following (optional) properties: precision, width, height. If a single number is passed,
  38884. * it will be used for both width and height. If an object is passed, the screenshot size
  38885. * will be derived from the parameters. The precision property is a multiplier allowing
  38886. * rendering at a higher or lower resolution
  38887. * @param successCallback The callback receives a single parameter which contains the
  38888. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38889. * src parameter of an <img> to display it
  38890. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38891. * Check your browser for supported MIME types
  38892. * @param samples Texture samples (default: 1)
  38893. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38894. * @param fileName A name for for the downloaded file.
  38895. */
  38896. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38897. /**
  38898. * Validates if xhr data is correct
  38899. * @param xhr defines the request to validate
  38900. * @param dataType defines the expected data type
  38901. * @returns true if data is correct
  38902. */
  38903. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  38904. /**
  38905. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38906. * Be aware Math.random() could cause collisions, but:
  38907. * "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"
  38908. * @returns a pseudo random id
  38909. */
  38910. static RandomId(): string;
  38911. /**
  38912. * Test if the given uri is a base64 string
  38913. * @param uri The uri to test
  38914. * @return True if the uri is a base64 string or false otherwise
  38915. */
  38916. static IsBase64(uri: string): boolean;
  38917. /**
  38918. * Decode the given base64 uri.
  38919. * @param uri The uri to decode
  38920. * @return The decoded base64 data.
  38921. */
  38922. static DecodeBase64(uri: string): ArrayBuffer;
  38923. /**
  38924. * No log
  38925. */
  38926. static readonly NoneLogLevel: number;
  38927. /**
  38928. * Only message logs
  38929. */
  38930. static readonly MessageLogLevel: number;
  38931. /**
  38932. * Only warning logs
  38933. */
  38934. static readonly WarningLogLevel: number;
  38935. /**
  38936. * Only error logs
  38937. */
  38938. static readonly ErrorLogLevel: number;
  38939. /**
  38940. * All logs
  38941. */
  38942. static readonly AllLogLevel: number;
  38943. private static _LogCache;
  38944. /**
  38945. * Gets a value indicating the number of loading errors
  38946. * @ignorenaming
  38947. */
  38948. static errorsCount: number;
  38949. /**
  38950. * Callback called when a new log is added
  38951. */
  38952. static OnNewCacheEntry: (entry: string) => void;
  38953. private static _AddLogEntry;
  38954. private static _FormatMessage;
  38955. private static _LogDisabled;
  38956. private static _LogEnabled;
  38957. private static _WarnDisabled;
  38958. private static _WarnEnabled;
  38959. private static _ErrorDisabled;
  38960. private static _ErrorEnabled;
  38961. /**
  38962. * Log a message to the console
  38963. */
  38964. static Log: (message: string) => void;
  38965. /**
  38966. * Write a warning message to the console
  38967. */
  38968. static Warn: (message: string) => void;
  38969. /**
  38970. * Write an error message to the console
  38971. */
  38972. static Error: (message: string) => void;
  38973. /**
  38974. * Gets current log cache (list of logs)
  38975. */
  38976. static readonly LogCache: string;
  38977. /**
  38978. * Clears the log cache
  38979. */
  38980. static ClearLogCache(): void;
  38981. /**
  38982. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38983. */
  38984. static LogLevels: number;
  38985. /**
  38986. * Checks if the loaded document was accessed via `file:`-Protocol.
  38987. * @returns boolean
  38988. */
  38989. static IsFileURL(): boolean;
  38990. /**
  38991. * Checks if the window object exists
  38992. * @returns true if the window object exists
  38993. */
  38994. static IsWindowObjectExist(): boolean;
  38995. /**
  38996. * No performance log
  38997. */
  38998. static readonly PerformanceNoneLogLevel: number;
  38999. /**
  39000. * Use user marks to log performance
  39001. */
  39002. static readonly PerformanceUserMarkLogLevel: number;
  39003. /**
  39004. * Log performance to the console
  39005. */
  39006. static readonly PerformanceConsoleLogLevel: number;
  39007. private static _performance;
  39008. /**
  39009. * Sets the current performance log level
  39010. */
  39011. static PerformanceLogLevel: number;
  39012. private static _StartPerformanceCounterDisabled;
  39013. private static _EndPerformanceCounterDisabled;
  39014. private static _StartUserMark;
  39015. private static _EndUserMark;
  39016. private static _StartPerformanceConsole;
  39017. private static _EndPerformanceConsole;
  39018. /**
  39019. * Starts a performance counter
  39020. */
  39021. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39022. /**
  39023. * Ends a specific performance coutner
  39024. */
  39025. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39026. /**
  39027. * Gets either window.performance.now() if supported or Date.now() else
  39028. */
  39029. static readonly Now: number;
  39030. /**
  39031. * This method will return the name of the class used to create the instance of the given object.
  39032. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39033. * @param object the object to get the class name from
  39034. * @param isType defines if the object is actually a type
  39035. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39036. */
  39037. static GetClassName(object: any, isType?: boolean): string;
  39038. /**
  39039. * Gets the first element of an array satisfying a given predicate
  39040. * @param array defines the array to browse
  39041. * @param predicate defines the predicate to use
  39042. * @returns null if not found or the element
  39043. */
  39044. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39045. /**
  39046. * This method will return the name of the full name of the class, including its owning module (if any).
  39047. * 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).
  39048. * @param object the object to get the class name from
  39049. * @param isType defines if the object is actually a type
  39050. * @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.
  39051. * @ignorenaming
  39052. */
  39053. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39054. /**
  39055. * Returns a promise that resolves after the given amount of time.
  39056. * @param delay Number of milliseconds to delay
  39057. * @returns Promise that resolves after the given amount of time
  39058. */
  39059. static DelayAsync(delay: number): Promise<void>;
  39060. /**
  39061. * Gets the current gradient from an array of IValueGradient
  39062. * @param ratio defines the current ratio to get
  39063. * @param gradients defines the array of IValueGradient
  39064. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  39065. */
  39066. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  39067. }
  39068. /**
  39069. * This class is used to track a performance counter which is number based.
  39070. * The user has access to many properties which give statistics of different nature.
  39071. *
  39072. * The implementer can track two kinds of Performance Counter: time and count.
  39073. * 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.
  39074. * 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.
  39075. */
  39076. class PerfCounter {
  39077. /**
  39078. * Gets or sets a global boolean to turn on and off all the counters
  39079. */
  39080. static Enabled: boolean;
  39081. /**
  39082. * Returns the smallest value ever
  39083. */
  39084. readonly min: number;
  39085. /**
  39086. * Returns the biggest value ever
  39087. */
  39088. readonly max: number;
  39089. /**
  39090. * Returns the average value since the performance counter is running
  39091. */
  39092. readonly average: number;
  39093. /**
  39094. * Returns the average value of the last second the counter was monitored
  39095. */
  39096. readonly lastSecAverage: number;
  39097. /**
  39098. * Returns the current value
  39099. */
  39100. readonly current: number;
  39101. /**
  39102. * Gets the accumulated total
  39103. */
  39104. readonly total: number;
  39105. /**
  39106. * Gets the total value count
  39107. */
  39108. readonly count: number;
  39109. /**
  39110. * Creates a new counter
  39111. */
  39112. constructor();
  39113. /**
  39114. * Call this method to start monitoring a new frame.
  39115. * 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.
  39116. */
  39117. fetchNewFrame(): void;
  39118. /**
  39119. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  39120. * @param newCount the count value to add to the monitored count
  39121. * @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.
  39122. */
  39123. addCount(newCount: number, fetchResult: boolean): void;
  39124. /**
  39125. * Start monitoring this performance counter
  39126. */
  39127. beginMonitoring(): void;
  39128. /**
  39129. * Compute the time lapsed since the previous beginMonitoring() call.
  39130. * @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
  39131. */
  39132. endMonitoring(newFrame?: boolean): void;
  39133. private _fetchResult;
  39134. private _startMonitoringTime;
  39135. private _min;
  39136. private _max;
  39137. private _average;
  39138. private _current;
  39139. private _totalValueCount;
  39140. private _totalAccumulated;
  39141. private _lastSecAverage;
  39142. private _lastSecAccumulated;
  39143. private _lastSecTime;
  39144. private _lastSecValueCount;
  39145. }
  39146. /**
  39147. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39148. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39149. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39150. * @param name The name of the class, case should be preserved
  39151. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39152. */
  39153. function className(name: string, module?: string): (target: Object) => void;
  39154. /**
  39155. * An implementation of a loop for asynchronous functions.
  39156. */
  39157. class AsyncLoop {
  39158. /**
  39159. * Defines the number of iterations for the loop
  39160. */
  39161. iterations: number;
  39162. /**
  39163. * Defines the current index of the loop.
  39164. */
  39165. index: number;
  39166. private _done;
  39167. private _fn;
  39168. private _successCallback;
  39169. /**
  39170. * Constructor.
  39171. * @param iterations the number of iterations.
  39172. * @param func the function to run each iteration
  39173. * @param successCallback the callback that will be called upon succesful execution
  39174. * @param offset starting offset.
  39175. */
  39176. constructor(
  39177. /**
  39178. * Defines the number of iterations for the loop
  39179. */
  39180. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39181. /**
  39182. * Execute the next iteration. Must be called after the last iteration was finished.
  39183. */
  39184. executeNext(): void;
  39185. /**
  39186. * Break the loop and run the success callback.
  39187. */
  39188. breakLoop(): void;
  39189. /**
  39190. * Create and run an async loop.
  39191. * @param iterations the number of iterations.
  39192. * @param fn the function to run each iteration
  39193. * @param successCallback the callback that will be called upon succesful execution
  39194. * @param offset starting offset.
  39195. * @returns the created async loop object
  39196. */
  39197. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39198. /**
  39199. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39200. * @param iterations total number of iterations
  39201. * @param syncedIterations number of synchronous iterations in each async iteration.
  39202. * @param fn the function to call each iteration.
  39203. * @param callback a success call back that will be called when iterating stops.
  39204. * @param breakFunction a break condition (optional)
  39205. * @param timeout timeout settings for the setTimeout function. default - 0.
  39206. * @returns the created async loop object
  39207. */
  39208. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39209. }
  39210. }
  39211. interface HTMLCanvasElement {
  39212. /** Track wether a record is in progress */
  39213. isRecording: boolean;
  39214. /** Capture Stream method defined by some browsers */
  39215. captureStream(fps?: number): MediaStream;
  39216. }
  39217. interface MediaRecorder {
  39218. /** Starts recording */
  39219. start(timeSlice: number): void;
  39220. /** Stops recording */
  39221. stop(): void;
  39222. /** Event raised when an error arised. */
  39223. onerror: (event: ErrorEvent) => void;
  39224. /** Event raised when the recording stops. */
  39225. onstop: (event: Event) => void;
  39226. /** Event raised when a new chunk of data is available and should be tracked. */
  39227. ondataavailable: (event: Event) => void;
  39228. }
  39229. interface MediaRecorderOptions {
  39230. /** The mime type you want to use as the recording container for the new MediaRecorder */
  39231. mimeType?: string;
  39232. /** The chosen bitrate for the audio component of the media. */
  39233. audioBitsPerSecond?: number;
  39234. /** The chosen bitrate for the video component of the media. */
  39235. videoBitsPerSecond?: number;
  39236. /** 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. */
  39237. bitsPerSecond?: number;
  39238. }
  39239. interface MediaRecorderConstructor {
  39240. /**
  39241. * A reference to the prototype.
  39242. */
  39243. readonly prototype: MediaRecorder;
  39244. /**
  39245. * Creates a new MediaRecorder.
  39246. * @param stream Defines the stream to record.
  39247. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  39248. */
  39249. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  39250. }
  39251. /**
  39252. * MediaRecoreder object available in some browsers.
  39253. */
  39254. declare var MediaRecorder: MediaRecorderConstructor;
  39255. declare module BABYLON {
  39256. /**
  39257. * This represents the different options avilable for the video capture.
  39258. */
  39259. interface VideoRecorderOptions {
  39260. /** Defines the mime type of the video */
  39261. mimeType: string;
  39262. /** Defines the video the video should be recorded at */
  39263. fps: number;
  39264. /** Defines the chunk size for the recording data */
  39265. recordChunckSize: number;
  39266. }
  39267. /**
  39268. * This can helps recording videos from BabylonJS.
  39269. * This is based on the available WebRTC functionalities of the browser.
  39270. *
  39271. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  39272. */
  39273. class VideoRecorder {
  39274. private static readonly _defaultOptions;
  39275. /**
  39276. * Returns wehther or not the VideoRecorder is available in your browser.
  39277. * @param engine Defines the Babylon Engine to check the support for
  39278. * @returns true if supported otherwise false
  39279. */
  39280. static IsSupported(engine: Engine): boolean;
  39281. private readonly _options;
  39282. private _canvas;
  39283. private _mediaRecorder;
  39284. private _recordedChunks;
  39285. private _fileName;
  39286. private _resolve;
  39287. private _reject;
  39288. /**
  39289. * True wether a recording is already in progress.
  39290. */
  39291. readonly isRecording: boolean;
  39292. /**
  39293. * Create a new VideoCapture object which can help converting what you see in Babylon to
  39294. * a video file.
  39295. * @param engine Defines the BabylonJS Engine you wish to record
  39296. * @param options Defines options that can be used to customized the capture
  39297. */
  39298. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  39299. /**
  39300. * Stops the current recording before the default capture timeout passed in the startRecording
  39301. * functions.
  39302. */
  39303. stopRecording(): void;
  39304. /**
  39305. * Starts recording the canvas for a max duration specified in parameters.
  39306. * @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.
  39307. * @param maxDuration Defines the maximum recording time in seconds.
  39308. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  39309. * @return a promise callback at the end of the recording with the video data in Blob.
  39310. */
  39311. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  39312. /**
  39313. * Releases internal resources used during the recording.
  39314. */
  39315. dispose(): void;
  39316. private _handleDataAvailable;
  39317. private _handleError;
  39318. private _handleStop;
  39319. }
  39320. }
  39321. declare module BABYLON {
  39322. /**
  39323. * Defines the potential axis of a Joystick
  39324. */
  39325. enum JoystickAxis {
  39326. /** X axis */
  39327. X = 0,
  39328. /** Y axis */
  39329. Y = 1,
  39330. /** Z axis */
  39331. Z = 2
  39332. }
  39333. /**
  39334. * Class used to define virtual joystick (used in touch mode)
  39335. */
  39336. class VirtualJoystick {
  39337. /**
  39338. * Gets or sets a boolean indicating that left and right values must be inverted
  39339. */
  39340. reverseLeftRight: boolean;
  39341. /**
  39342. * Gets or sets a boolean indicating that up and down values must be inverted
  39343. */
  39344. reverseUpDown: boolean;
  39345. /**
  39346. * Gets the offset value for the position (ie. the change of the position value)
  39347. */
  39348. deltaPosition: Vector3;
  39349. /**
  39350. * Gets a boolean indicating if the virtual joystick was pressed
  39351. */
  39352. pressed: boolean;
  39353. private static _globalJoystickIndex;
  39354. private static vjCanvas;
  39355. private static vjCanvasContext;
  39356. private static vjCanvasWidth;
  39357. private static vjCanvasHeight;
  39358. private static halfWidth;
  39359. private _action;
  39360. private _axisTargetedByLeftAndRight;
  39361. private _axisTargetedByUpAndDown;
  39362. private _joystickSensibility;
  39363. private _inversedSensibility;
  39364. private _joystickPointerID;
  39365. private _joystickColor;
  39366. private _joystickPointerPos;
  39367. private _joystickPreviousPointerPos;
  39368. private _joystickPointerStartPos;
  39369. private _deltaJoystickVector;
  39370. private _leftJoystick;
  39371. private _touches;
  39372. private _onPointerDownHandlerRef;
  39373. private _onPointerMoveHandlerRef;
  39374. private _onPointerUpHandlerRef;
  39375. private _onResize;
  39376. /**
  39377. * Creates a new virtual joystick
  39378. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39379. */
  39380. constructor(leftJoystick?: boolean);
  39381. /**
  39382. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39383. * @param newJoystickSensibility defines the new sensibility
  39384. */
  39385. setJoystickSensibility(newJoystickSensibility: number): void;
  39386. private _onPointerDown;
  39387. private _onPointerMove;
  39388. private _onPointerUp;
  39389. /**
  39390. * Change the color of the virtual joystick
  39391. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39392. */
  39393. setJoystickColor(newColor: string): void;
  39394. /**
  39395. * Defines a callback to call when the joystick is touched
  39396. * @param action defines the callback
  39397. */
  39398. setActionOnTouch(action: () => any): void;
  39399. /**
  39400. * Defines which axis you'd like to control for left & right
  39401. * @param axis defines the axis to use
  39402. */
  39403. setAxisForLeftRight(axis: JoystickAxis): void;
  39404. /**
  39405. * Defines which axis you'd like to control for up & down
  39406. * @param axis defines the axis to use
  39407. */
  39408. setAxisForUpDown(axis: JoystickAxis): void;
  39409. private _drawVirtualJoystick;
  39410. /**
  39411. * Release internal HTML canvas
  39412. */
  39413. releaseCanvas(): void;
  39414. }
  39415. }
  39416. declare module BABYLON {
  39417. /**
  39418. * Helper class to push actions to a pool of workers.
  39419. */
  39420. class WorkerPool implements IDisposable {
  39421. private _workerInfos;
  39422. private _pendingActions;
  39423. /**
  39424. * Constructor
  39425. * @param workers Array of workers to use for actions
  39426. */
  39427. constructor(workers: Array<Worker>);
  39428. /**
  39429. * Terminates all workers and clears any pending actions.
  39430. */
  39431. dispose(): void;
  39432. /**
  39433. * Pushes an action to the worker pool. If all the workers are active, the action will be
  39434. * pended until a worker has completed its action.
  39435. * @param action The action to perform. Call onComplete when the action is complete.
  39436. */
  39437. push(action: (worker: Worker, onComplete: () => void) => void): void;
  39438. private _execute;
  39439. }
  39440. }
  39441. declare module BABYLON {
  39442. /**
  39443. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39444. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39445. */
  39446. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39447. /**
  39448. * Gets the name of the behavior.
  39449. */
  39450. readonly name: string;
  39451. private _zoomStopsAnimation;
  39452. private _idleRotationSpeed;
  39453. private _idleRotationWaitTime;
  39454. private _idleRotationSpinupTime;
  39455. /**
  39456. * Sets the flag that indicates if user zooming should stop animation.
  39457. */
  39458. /**
  39459. * Gets the flag that indicates if user zooming should stop animation.
  39460. */
  39461. zoomStopsAnimation: boolean;
  39462. /**
  39463. * Sets the default speed at which the camera rotates around the model.
  39464. */
  39465. /**
  39466. * Gets the default speed at which the camera rotates around the model.
  39467. */
  39468. idleRotationSpeed: number;
  39469. /**
  39470. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39471. */
  39472. /**
  39473. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39474. */
  39475. idleRotationWaitTime: number;
  39476. /**
  39477. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39478. */
  39479. /**
  39480. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39481. */
  39482. idleRotationSpinupTime: number;
  39483. /**
  39484. * Gets a value indicating if the camera is currently rotating because of this behavior
  39485. */
  39486. readonly rotationInProgress: boolean;
  39487. private _onPrePointerObservableObserver;
  39488. private _onAfterCheckInputsObserver;
  39489. private _attachedCamera;
  39490. private _isPointerDown;
  39491. private _lastFrameTime;
  39492. private _lastInteractionTime;
  39493. private _cameraRotationSpeed;
  39494. /**
  39495. * Initializes the behavior.
  39496. */
  39497. init(): void;
  39498. /**
  39499. * Attaches the behavior to its arc rotate camera.
  39500. * @param camera Defines the camera to attach the behavior to
  39501. */
  39502. attach(camera: ArcRotateCamera): void;
  39503. /**
  39504. * Detaches the behavior from its current arc rotate camera.
  39505. */
  39506. detach(): void;
  39507. /**
  39508. * Returns true if user is scrolling.
  39509. * @return true if user is scrolling.
  39510. */
  39511. private _userIsZooming;
  39512. private _lastFrameRadius;
  39513. private _shouldAnimationStopForInteraction;
  39514. /**
  39515. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39516. */
  39517. private _applyUserInteraction;
  39518. private _userIsMoving;
  39519. }
  39520. }
  39521. declare module BABYLON {
  39522. /**
  39523. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39524. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39525. */
  39526. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39527. /**
  39528. * Gets the name of the behavior.
  39529. */
  39530. readonly name: string;
  39531. /**
  39532. * The easing function used by animations
  39533. */
  39534. static EasingFunction: BackEase;
  39535. /**
  39536. * The easing mode used by animations
  39537. */
  39538. static EasingMode: number;
  39539. /**
  39540. * The duration of the animation, in milliseconds
  39541. */
  39542. transitionDuration: number;
  39543. /**
  39544. * Length of the distance animated by the transition when lower radius is reached
  39545. */
  39546. lowerRadiusTransitionRange: number;
  39547. /**
  39548. * Length of the distance animated by the transition when upper radius is reached
  39549. */
  39550. upperRadiusTransitionRange: number;
  39551. private _autoTransitionRange;
  39552. /**
  39553. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39554. */
  39555. /**
  39556. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39557. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39558. */
  39559. autoTransitionRange: boolean;
  39560. private _attachedCamera;
  39561. private _onAfterCheckInputsObserver;
  39562. private _onMeshTargetChangedObserver;
  39563. /**
  39564. * Initializes the behavior.
  39565. */
  39566. init(): void;
  39567. /**
  39568. * Attaches the behavior to its arc rotate camera.
  39569. * @param camera Defines the camera to attach the behavior to
  39570. */
  39571. attach(camera: ArcRotateCamera): void;
  39572. /**
  39573. * Detaches the behavior from its current arc rotate camera.
  39574. */
  39575. detach(): void;
  39576. private _radiusIsAnimating;
  39577. private _radiusBounceTransition;
  39578. private _animatables;
  39579. private _cachedWheelPrecision;
  39580. /**
  39581. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39582. * @param radiusLimit The limit to check against.
  39583. * @return Bool to indicate if at limit.
  39584. */
  39585. private _isRadiusAtLimit;
  39586. /**
  39587. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39588. * @param radiusDelta The delta by which to animate to. Can be negative.
  39589. */
  39590. private _applyBoundRadiusAnimation;
  39591. /**
  39592. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39593. */
  39594. protected _clearAnimationLocks(): void;
  39595. /**
  39596. * Stops and removes all animations that have been applied to the camera
  39597. */
  39598. stopAllAnimations(): void;
  39599. }
  39600. }
  39601. declare module BABYLON {
  39602. /**
  39603. * 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.
  39604. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39605. */
  39606. class FramingBehavior implements Behavior<ArcRotateCamera> {
  39607. /**
  39608. * Gets the name of the behavior.
  39609. */
  39610. readonly name: string;
  39611. private _mode;
  39612. private _radiusScale;
  39613. private _positionScale;
  39614. private _defaultElevation;
  39615. private _elevationReturnTime;
  39616. private _elevationReturnWaitTime;
  39617. private _zoomStopsAnimation;
  39618. private _framingTime;
  39619. /**
  39620. * The easing function used by animations
  39621. */
  39622. static EasingFunction: ExponentialEase;
  39623. /**
  39624. * The easing mode used by animations
  39625. */
  39626. static EasingMode: number;
  39627. /**
  39628. * Sets the current mode used by the behavior
  39629. */
  39630. /**
  39631. * Gets current mode used by the behavior.
  39632. */
  39633. mode: number;
  39634. /**
  39635. * Sets the scale applied to the radius (1 by default)
  39636. */
  39637. /**
  39638. * Gets the scale applied to the radius
  39639. */
  39640. radiusScale: number;
  39641. /**
  39642. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39643. */
  39644. /**
  39645. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39646. */
  39647. positionScale: number;
  39648. /**
  39649. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39650. * behaviour is triggered, in radians.
  39651. */
  39652. /**
  39653. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39654. * behaviour is triggered, in radians.
  39655. */
  39656. defaultElevation: number;
  39657. /**
  39658. * Sets the time (in milliseconds) taken to return to the default beta position.
  39659. * Negative value indicates camera should not return to default.
  39660. */
  39661. /**
  39662. * Gets the time (in milliseconds) taken to return to the default beta position.
  39663. * Negative value indicates camera should not return to default.
  39664. */
  39665. elevationReturnTime: number;
  39666. /**
  39667. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39668. */
  39669. /**
  39670. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39671. */
  39672. elevationReturnWaitTime: number;
  39673. /**
  39674. * Sets the flag that indicates if user zooming should stop animation.
  39675. */
  39676. /**
  39677. * Gets the flag that indicates if user zooming should stop animation.
  39678. */
  39679. zoomStopsAnimation: boolean;
  39680. /**
  39681. * Sets the transition time when framing the mesh, in milliseconds
  39682. */
  39683. /**
  39684. * Gets the transition time when framing the mesh, in milliseconds
  39685. */
  39686. framingTime: number;
  39687. /**
  39688. * Define if the behavior should automatically change the configured
  39689. * camera limits and sensibilities.
  39690. */
  39691. autoCorrectCameraLimitsAndSensibility: boolean;
  39692. private _onPrePointerObservableObserver;
  39693. private _onAfterCheckInputsObserver;
  39694. private _onMeshTargetChangedObserver;
  39695. private _attachedCamera;
  39696. private _isPointerDown;
  39697. private _lastInteractionTime;
  39698. /**
  39699. * Initializes the behavior.
  39700. */
  39701. init(): void;
  39702. /**
  39703. * Attaches the behavior to its arc rotate camera.
  39704. * @param camera Defines the camera to attach the behavior to
  39705. */
  39706. attach(camera: ArcRotateCamera): void;
  39707. /**
  39708. * Detaches the behavior from its current arc rotate camera.
  39709. */
  39710. detach(): void;
  39711. private _animatables;
  39712. private _betaIsAnimating;
  39713. private _betaTransition;
  39714. private _radiusTransition;
  39715. private _vectorTransition;
  39716. /**
  39717. * Targets the given mesh and updates zoom level accordingly.
  39718. * @param mesh The mesh to target.
  39719. * @param radius Optional. If a cached radius position already exists, overrides default.
  39720. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39721. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39722. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39723. */
  39724. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39725. /**
  39726. * Targets the given mesh with its children and updates zoom level accordingly.
  39727. * @param mesh The mesh to target.
  39728. * @param radius Optional. If a cached radius position already exists, overrides default.
  39729. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39730. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39731. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39732. */
  39733. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39734. /**
  39735. * Targets the given meshes with their children and updates zoom level accordingly.
  39736. * @param meshes The mesh to target.
  39737. * @param radius Optional. If a cached radius position already exists, overrides default.
  39738. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39739. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39740. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39741. */
  39742. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39743. /**
  39744. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39745. * @param minimumWorld Determines the smaller position of the bounding box extend
  39746. * @param maximumWorld Determines the bigger position of the bounding box extend
  39747. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39748. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39749. */
  39750. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39751. /**
  39752. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39753. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39754. * frustum width.
  39755. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39756. * to fully enclose the mesh in the viewing frustum.
  39757. */
  39758. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39759. /**
  39760. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39761. * is automatically returned to its default position (expected to be above ground plane).
  39762. */
  39763. private _maintainCameraAboveGround;
  39764. /**
  39765. * Returns the frustum slope based on the canvas ratio and camera FOV
  39766. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39767. */
  39768. private _getFrustumSlope;
  39769. /**
  39770. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39771. */
  39772. private _clearAnimationLocks;
  39773. /**
  39774. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39775. */
  39776. private _applyUserInteraction;
  39777. /**
  39778. * Stops and removes all animations that have been applied to the camera
  39779. */
  39780. stopAllAnimations(): void;
  39781. /**
  39782. * Gets a value indicating if the user is moving the camera
  39783. */
  39784. readonly isUserIsMoving: boolean;
  39785. /**
  39786. * The camera can move all the way towards the mesh.
  39787. */
  39788. static IgnoreBoundsSizeMode: number;
  39789. /**
  39790. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39791. */
  39792. static FitFrustumSidesMode: number;
  39793. }
  39794. }
  39795. declare module BABYLON {
  39796. /**
  39797. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39798. */
  39799. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  39800. private ui;
  39801. /**
  39802. * The name of the behavior
  39803. */
  39804. name: string;
  39805. /**
  39806. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39807. */
  39808. distanceAwayFromFace: number;
  39809. /**
  39810. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39811. */
  39812. distanceAwayFromBottomOfFace: number;
  39813. private _faceVectors;
  39814. private _target;
  39815. private _scene;
  39816. private _onRenderObserver;
  39817. private _tmpMatrix;
  39818. private _tmpVector;
  39819. /**
  39820. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39821. * @param ui The transform node that should be attched to the mesh
  39822. */
  39823. constructor(ui: BABYLON.TransformNode);
  39824. /**
  39825. * Initializes the behavior
  39826. */
  39827. init(): void;
  39828. private _closestFace;
  39829. private _zeroVector;
  39830. private _lookAtTmpMatrix;
  39831. private _lookAtToRef;
  39832. /**
  39833. * Attaches the AttachToBoxBehavior to the passed in mesh
  39834. * @param target The mesh that the specified node will be attached to
  39835. */
  39836. attach(target: BABYLON.Mesh): void;
  39837. /**
  39838. * Detaches the behavior from the mesh
  39839. */
  39840. detach(): void;
  39841. }
  39842. }
  39843. declare module BABYLON {
  39844. /**
  39845. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39846. */
  39847. class FadeInOutBehavior implements Behavior<Mesh> {
  39848. /**
  39849. * Time in milliseconds to delay before fading in (Default: 0)
  39850. */
  39851. delay: number;
  39852. /**
  39853. * Time in milliseconds for the mesh to fade in (Default: 300)
  39854. */
  39855. fadeInTime: number;
  39856. private _millisecondsPerFrame;
  39857. private _hovered;
  39858. private _hoverValue;
  39859. private _ownerNode;
  39860. /**
  39861. * Instatiates the FadeInOutBehavior
  39862. */
  39863. constructor();
  39864. /**
  39865. * The name of the behavior
  39866. */
  39867. readonly name: string;
  39868. /**
  39869. * Initializes the behavior
  39870. */
  39871. init(): void;
  39872. /**
  39873. * Attaches the fade behavior on the passed in mesh
  39874. * @param ownerNode The mesh that will be faded in/out once attached
  39875. */
  39876. attach(ownerNode: Mesh): void;
  39877. /**
  39878. * Detaches the behavior from the mesh
  39879. */
  39880. detach(): void;
  39881. /**
  39882. * Triggers the mesh to begin fading in or out
  39883. * @param value if the object should fade in or out (true to fade in)
  39884. */
  39885. fadeIn(value: boolean): void;
  39886. private _update;
  39887. private _setAllVisibility;
  39888. }
  39889. }
  39890. declare module BABYLON {
  39891. /**
  39892. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39893. */
  39894. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39895. private _dragBehaviorA;
  39896. private _dragBehaviorB;
  39897. private _startDistance;
  39898. private _initialScale;
  39899. private _targetScale;
  39900. private _ownerNode;
  39901. private _sceneRenderObserver;
  39902. /**
  39903. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39904. */
  39905. constructor();
  39906. /**
  39907. * The name of the behavior
  39908. */
  39909. readonly name: string;
  39910. /**
  39911. * Initializes the behavior
  39912. */
  39913. init(): void;
  39914. private _getCurrentDistance;
  39915. /**
  39916. * Attaches the scale behavior the passed in mesh
  39917. * @param ownerNode The mesh that will be scaled around once attached
  39918. */
  39919. attach(ownerNode: Mesh): void;
  39920. /**
  39921. * Detaches the behavior from the mesh
  39922. */
  39923. detach(): void;
  39924. }
  39925. }
  39926. declare module BABYLON {
  39927. /**
  39928. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39929. */
  39930. class PointerDragBehavior implements Behavior<Mesh> {
  39931. private static _AnyMouseID;
  39932. private _attachedNode;
  39933. private _dragPlane;
  39934. private _scene;
  39935. private _pointerObserver;
  39936. private _beforeRenderObserver;
  39937. private static _planeScene;
  39938. /**
  39939. * 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)
  39940. */
  39941. maxDragAngle: number;
  39942. /**
  39943. * @hidden
  39944. */
  39945. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39946. /**
  39947. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39948. */
  39949. currentDraggingPointerID: number;
  39950. /**
  39951. * The last position where the pointer hit the drag plane in world space
  39952. */
  39953. lastDragPosition: Vector3;
  39954. /**
  39955. * If the behavior is currently in a dragging state
  39956. */
  39957. dragging: boolean;
  39958. /**
  39959. * 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)
  39960. */
  39961. dragDeltaRatio: number;
  39962. /**
  39963. * If the drag plane orientation should be updated during the dragging (Default: true)
  39964. */
  39965. updateDragPlane: boolean;
  39966. private _debugMode;
  39967. private _moving;
  39968. /**
  39969. * Fires each time the attached mesh is dragged with the pointer
  39970. * * delta between last drag position and current drag position in world space
  39971. * * dragDistance along the drag axis
  39972. * * dragPlaneNormal normal of the current drag plane used during the drag
  39973. * * dragPlanePoint in world space where the drag intersects the drag plane
  39974. */
  39975. onDragObservable: Observable<{
  39976. delta: Vector3;
  39977. dragPlanePoint: Vector3;
  39978. dragPlaneNormal: Vector3;
  39979. dragDistance: number;
  39980. pointerId: number;
  39981. }>;
  39982. /**
  39983. * Fires each time a drag begins (eg. mouse down on mesh)
  39984. */
  39985. onDragStartObservable: Observable<{
  39986. dragPlanePoint: Vector3;
  39987. pointerId: number;
  39988. }>;
  39989. /**
  39990. * Fires each time a drag ends (eg. mouse release after drag)
  39991. */
  39992. onDragEndObservable: Observable<{
  39993. dragPlanePoint: Vector3;
  39994. pointerId: number;
  39995. }>;
  39996. /**
  39997. * If the attached mesh should be moved when dragged
  39998. */
  39999. moveAttached: boolean;
  40000. /**
  40001. * If the drag behavior will react to drag events (Default: true)
  40002. */
  40003. enabled: boolean;
  40004. /**
  40005. * If camera controls should be detached during the drag
  40006. */
  40007. detachCameraControls: boolean;
  40008. /**
  40009. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40010. */
  40011. useObjectOrienationForDragging: boolean;
  40012. private _options;
  40013. /**
  40014. * Creates a pointer drag behavior that can be attached to a mesh
  40015. * @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)
  40016. */
  40017. constructor(options?: {
  40018. dragAxis?: Vector3;
  40019. dragPlaneNormal?: Vector3;
  40020. });
  40021. /**
  40022. * The name of the behavior
  40023. */
  40024. readonly name: string;
  40025. /**
  40026. * Initializes the behavior
  40027. */
  40028. init(): void;
  40029. private _tmpVector;
  40030. private _alternatePickedPoint;
  40031. private _worldDragAxis;
  40032. private _targetPosition;
  40033. private _attachedElement;
  40034. /**
  40035. * Attaches the drag behavior the passed in mesh
  40036. * @param ownerNode The mesh that will be dragged around once attached
  40037. */
  40038. attach(ownerNode: Mesh): void;
  40039. /**
  40040. * Force relase the drag action by code.
  40041. */
  40042. releaseDrag(): void;
  40043. private _startDragRay;
  40044. private _lastPointerRay;
  40045. /**
  40046. * Simulates the start of a pointer drag event on the behavior
  40047. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40048. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40049. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40050. */
  40051. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40052. private _startDrag;
  40053. private _dragDelta;
  40054. private _moveDrag;
  40055. private _pickWithRayOnDragPlane;
  40056. private _pointA;
  40057. private _pointB;
  40058. private _pointC;
  40059. private _lineA;
  40060. private _lineB;
  40061. private _localAxis;
  40062. private _lookAt;
  40063. private _updateDragPlanePosition;
  40064. /**
  40065. * Detaches the behavior from the mesh
  40066. */
  40067. detach(): void;
  40068. }
  40069. }
  40070. declare module BABYLON {
  40071. /**
  40072. * 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
  40073. */
  40074. class SixDofDragBehavior implements Behavior<Mesh> {
  40075. private static _virtualScene;
  40076. private _ownerNode;
  40077. private _sceneRenderObserver;
  40078. private _scene;
  40079. private _targetPosition;
  40080. private _virtualOriginMesh;
  40081. private _virtualDragMesh;
  40082. private _pointerObserver;
  40083. private _moving;
  40084. private _startingOrientation;
  40085. /**
  40086. * 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)
  40087. */
  40088. private zDragFactor;
  40089. /**
  40090. * If the behavior is currently in a dragging state
  40091. */
  40092. dragging: boolean;
  40093. /**
  40094. * 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)
  40095. */
  40096. dragDeltaRatio: number;
  40097. /**
  40098. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40099. */
  40100. currentDraggingPointerID: number;
  40101. /**
  40102. * If camera controls should be detached during the drag
  40103. */
  40104. detachCameraControls: boolean;
  40105. /**
  40106. * Fires each time a drag starts
  40107. */
  40108. onDragStartObservable: Observable<{}>;
  40109. /**
  40110. * Fires each time a drag ends (eg. mouse release after drag)
  40111. */
  40112. onDragEndObservable: Observable<{}>;
  40113. /**
  40114. * 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
  40115. */
  40116. constructor();
  40117. /**
  40118. * The name of the behavior
  40119. */
  40120. readonly name: string;
  40121. /**
  40122. * Initializes the behavior
  40123. */
  40124. init(): void;
  40125. /**
  40126. * Attaches the scale behavior the passed in mesh
  40127. * @param ownerNode The mesh that will be scaled around once attached
  40128. */
  40129. attach(ownerNode: Mesh): void;
  40130. /**
  40131. * Detaches the behavior from the mesh
  40132. */
  40133. detach(): void;
  40134. }
  40135. }
  40136. declare module BABYLON {
  40137. /**
  40138. * Contains an array of blocks representing the octree
  40139. */
  40140. interface IOctreeContainer<T> {
  40141. /**
  40142. * Blocks within the octree
  40143. */
  40144. blocks: Array<OctreeBlock<T>>;
  40145. }
  40146. /**
  40147. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40148. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40149. */
  40150. class Octree<T> {
  40151. /** 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.) */
  40152. maxDepth: number;
  40153. /**
  40154. * Blocks within the octree containing objects
  40155. */
  40156. blocks: Array<OctreeBlock<T>>;
  40157. /**
  40158. * Content stored in the octree
  40159. */
  40160. dynamicContent: T[];
  40161. private _maxBlockCapacity;
  40162. private _selectionContent;
  40163. private _creationFunc;
  40164. /**
  40165. * Creates a octree
  40166. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40167. * @param creationFunc function to be used to instatiate the octree
  40168. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40169. * @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.)
  40170. */
  40171. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40172. /** 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.) */
  40173. maxDepth?: number);
  40174. /**
  40175. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40176. * @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);
  40177. * @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);
  40178. * @param entries meshes to be added to the octree blocks
  40179. */
  40180. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40181. /**
  40182. * Adds a mesh to the octree
  40183. * @param entry Mesh to add to the octree
  40184. */
  40185. addMesh(entry: T): void;
  40186. /**
  40187. * Selects an array of meshes within the frustum
  40188. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40189. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40190. * @returns array of meshes within the frustum
  40191. */
  40192. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40193. /**
  40194. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40195. * @param sphereCenter defines the bounding sphere center
  40196. * @param sphereRadius defines the bounding sphere radius
  40197. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40198. * @returns an array of objects that intersect the sphere
  40199. */
  40200. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40201. /**
  40202. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40203. * @param ray defines the ray to test with
  40204. * @returns array of intersected objects
  40205. */
  40206. intersectsRay(ray: Ray): SmartArray<T>;
  40207. /**
  40208. * @hidden
  40209. */
  40210. 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;
  40211. /**
  40212. * Adds a mesh into the octree block if it intersects the block
  40213. */
  40214. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40215. /**
  40216. * Adds a submesh into the octree block if it intersects the block
  40217. */
  40218. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40219. }
  40220. }
  40221. declare module BABYLON {
  40222. /**
  40223. * Class used to store a cell in an octree
  40224. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40225. */
  40226. class OctreeBlock<T> {
  40227. /**
  40228. * Gets the content of the current block
  40229. */
  40230. entries: T[];
  40231. /**
  40232. * Gets the list of block children
  40233. */
  40234. blocks: Array<OctreeBlock<T>>;
  40235. private _depth;
  40236. private _maxDepth;
  40237. private _capacity;
  40238. private _minPoint;
  40239. private _maxPoint;
  40240. private _boundingVectors;
  40241. private _creationFunc;
  40242. /**
  40243. * Creates a new block
  40244. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40245. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40246. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40247. * @param depth defines the current depth of this block in the octree
  40248. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40249. * @param creationFunc defines a callback to call when an element is added to the block
  40250. */
  40251. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40252. /**
  40253. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40254. */
  40255. readonly capacity: number;
  40256. /**
  40257. * Gets the minimum vector (in world space) of the block's bounding box
  40258. */
  40259. readonly minPoint: Vector3;
  40260. /**
  40261. * Gets the maximum vector (in world space) of the block's bounding box
  40262. */
  40263. readonly maxPoint: Vector3;
  40264. /**
  40265. * Add a new element to this block
  40266. * @param entry defines the element to add
  40267. */
  40268. addEntry(entry: T): void;
  40269. /**
  40270. * Add an array of elements to this block
  40271. * @param entries defines the array of elements to add
  40272. */
  40273. addEntries(entries: T[]): void;
  40274. /**
  40275. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40276. * @param frustumPlanes defines the frustum planes to test
  40277. * @param selection defines the array to store current content if selection is positive
  40278. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40279. */
  40280. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40281. /**
  40282. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40283. * @param sphereCenter defines the bounding sphere center
  40284. * @param sphereRadius defines the bounding sphere radius
  40285. * @param selection defines the array to store current content if selection is positive
  40286. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40287. */
  40288. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40289. /**
  40290. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40291. * @param ray defines the ray to test with
  40292. * @param selection defines the array to store current content if selection is positive
  40293. */
  40294. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40295. /**
  40296. * Subdivide the content into child blocks (this block will then be empty)
  40297. */
  40298. createInnerBlocks(): void;
  40299. }
  40300. }
  40301. declare module BABYLON {
  40302. interface Scene {
  40303. /**
  40304. * @hidden
  40305. * Backing Filed
  40306. */
  40307. _selectionOctree: Octree<AbstractMesh>;
  40308. /**
  40309. * Gets the octree used to boost mesh selection (picking)
  40310. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40311. */
  40312. selectionOctree: Octree<AbstractMesh>;
  40313. /**
  40314. * Creates or updates the octree used to boost selection (picking)
  40315. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40316. * @param maxCapacity defines the maximum capacity per leaf
  40317. * @param maxDepth defines the maximum depth of the octree
  40318. * @returns an octree of AbstractMesh
  40319. */
  40320. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40321. }
  40322. interface AbstractMesh {
  40323. /**
  40324. * @hidden
  40325. * Backing Field
  40326. */
  40327. _submeshesOctree: Octree<SubMesh>;
  40328. /**
  40329. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40330. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40331. * @param maxCapacity defines the maximum size of each block (64 by default)
  40332. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40333. * @returns the new octree
  40334. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40335. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40336. */
  40337. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40338. }
  40339. /**
  40340. * Defines the octree scene component responsible to manage any octrees
  40341. * in a given scene.
  40342. */
  40343. class OctreeSceneComponent {
  40344. /**
  40345. * The component name helpfull to identify the component in the list of scene components.
  40346. */
  40347. readonly name: string;
  40348. /**
  40349. * The scene the component belongs to.
  40350. */
  40351. scene: Scene;
  40352. /**
  40353. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40354. */
  40355. readonly checksIsEnabled: boolean;
  40356. /**
  40357. * Creates a new instance of the component for the given scene
  40358. * @param scene Defines the scene to register the component in
  40359. */
  40360. constructor(scene: Scene);
  40361. /**
  40362. * Registers the component in a given scene
  40363. */
  40364. register(): void;
  40365. /**
  40366. * Return the list of active meshes
  40367. * @returns the list of active meshes
  40368. */
  40369. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40370. /**
  40371. * Return the list of active sub meshes
  40372. * @param mesh The mesh to get the candidates sub meshes from
  40373. * @returns the list of active sub meshes
  40374. */
  40375. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40376. private _tempRay;
  40377. /**
  40378. * Return the list of sub meshes intersecting with a given local ray
  40379. * @param mesh defines the mesh to find the submesh for
  40380. * @param localRay defines the ray in local space
  40381. * @returns the list of intersecting sub meshes
  40382. */
  40383. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40384. /**
  40385. * Return the list of sub meshes colliding with a collider
  40386. * @param mesh defines the mesh to find the submesh for
  40387. * @param collider defines the collider to evaluate the collision against
  40388. * @returns the list of colliding sub meshes
  40389. */
  40390. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40391. /**
  40392. * Rebuilds the elements related to this component in case of
  40393. * context lost for instance.
  40394. */
  40395. rebuild(): void;
  40396. /**
  40397. * Disposes the component and the associated ressources.
  40398. */
  40399. dispose(): void;
  40400. }
  40401. }
  40402. declare module BABYLON {
  40403. /**
  40404. * Manage the gamepad inputs to control an arc rotate camera.
  40405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40406. */
  40407. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40408. /**
  40409. * Defines the camera the input is attached to.
  40410. */
  40411. camera: ArcRotateCamera;
  40412. /**
  40413. * Defines the gamepad the input is gathering event from.
  40414. */
  40415. gamepad: Nullable<Gamepad>;
  40416. /**
  40417. * Defines the gamepad rotation sensiblity.
  40418. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40419. */
  40420. gamepadRotationSensibility: number;
  40421. /**
  40422. * Defines the gamepad move sensiblity.
  40423. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40424. */
  40425. gamepadMoveSensibility: number;
  40426. private _onGamepadConnectedObserver;
  40427. private _onGamepadDisconnectedObserver;
  40428. /**
  40429. * Attach the input controls to a specific dom element to get the input from.
  40430. * @param element Defines the element the controls should be listened from
  40431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40432. */
  40433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40434. /**
  40435. * Detach the current controls from the specified dom element.
  40436. * @param element Defines the element to stop listening the inputs from
  40437. */
  40438. detachControl(element: Nullable<HTMLElement>): void;
  40439. /**
  40440. * Update the current camera state depending on the inputs that have been used this frame.
  40441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40442. */
  40443. checkInputs(): void;
  40444. /**
  40445. * Gets the class name of the current intput.
  40446. * @returns the class name
  40447. */
  40448. getClassName(): string;
  40449. /**
  40450. * Get the friendly name associated with the input class.
  40451. * @returns the input friendly name
  40452. */
  40453. getSimpleName(): string;
  40454. }
  40455. }
  40456. declare module BABYLON {
  40457. /**
  40458. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40460. */
  40461. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40462. /**
  40463. * Defines the camera the input is attached to.
  40464. */
  40465. camera: ArcRotateCamera;
  40466. /**
  40467. * Defines the list of key codes associated with the up action (increase alpha)
  40468. */
  40469. keysUp: number[];
  40470. /**
  40471. * Defines the list of key codes associated with the down action (decrease alpha)
  40472. */
  40473. keysDown: number[];
  40474. /**
  40475. * Defines the list of key codes associated with the left action (increase beta)
  40476. */
  40477. keysLeft: number[];
  40478. /**
  40479. * Defines the list of key codes associated with the right action (decrease beta)
  40480. */
  40481. keysRight: number[];
  40482. /**
  40483. * Defines the list of key codes associated with the reset action.
  40484. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40485. */
  40486. keysReset: number[];
  40487. /**
  40488. * Defines the panning sensibility of the inputs.
  40489. * (How fast is the camera paning)
  40490. */
  40491. panningSensibility: number;
  40492. /**
  40493. * Defines the zooming sensibility of the inputs.
  40494. * (How fast is the camera zooming)
  40495. */
  40496. zoomingSensibility: number;
  40497. /**
  40498. * Defines wether maintaining the alt key down switch the movement mode from
  40499. * orientation to zoom.
  40500. */
  40501. useAltToZoom: boolean;
  40502. /**
  40503. * Rotation speed of the camera
  40504. */
  40505. angularSpeed: number;
  40506. private _keys;
  40507. private _ctrlPressed;
  40508. private _altPressed;
  40509. private _onCanvasBlurObserver;
  40510. private _onKeyboardObserver;
  40511. private _engine;
  40512. private _scene;
  40513. /**
  40514. * Attach the input controls to a specific dom element to get the input from.
  40515. * @param element Defines the element the controls should be listened from
  40516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40517. */
  40518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40519. /**
  40520. * Detach the current controls from the specified dom element.
  40521. * @param element Defines the element to stop listening the inputs from
  40522. */
  40523. detachControl(element: Nullable<HTMLElement>): void;
  40524. /**
  40525. * Update the current camera state depending on the inputs that have been used this frame.
  40526. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40527. */
  40528. checkInputs(): void;
  40529. /**
  40530. * Gets the class name of the current intput.
  40531. * @returns the class name
  40532. */
  40533. getClassName(): string;
  40534. /**
  40535. * Get the friendly name associated with the input class.
  40536. * @returns the input friendly name
  40537. */
  40538. getSimpleName(): string;
  40539. }
  40540. }
  40541. declare module BABYLON {
  40542. /**
  40543. * Manage the mouse wheel inputs to control an arc rotate camera.
  40544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40545. */
  40546. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40547. /**
  40548. * Defines the camera the input is attached to.
  40549. */
  40550. camera: ArcRotateCamera;
  40551. /**
  40552. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40553. */
  40554. wheelPrecision: number;
  40555. /**
  40556. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40557. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40558. */
  40559. wheelDeltaPercentage: number;
  40560. private _wheel;
  40561. private _observer;
  40562. /**
  40563. * Attach the input controls to a specific dom element to get the input from.
  40564. * @param element Defines the element the controls should be listened from
  40565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40566. */
  40567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40568. /**
  40569. * Detach the current controls from the specified dom element.
  40570. * @param element Defines the element to stop listening the inputs from
  40571. */
  40572. detachControl(element: Nullable<HTMLElement>): void;
  40573. /**
  40574. * Gets the class name of the current intput.
  40575. * @returns the class name
  40576. */
  40577. getClassName(): string;
  40578. /**
  40579. * Get the friendly name associated with the input class.
  40580. * @returns the input friendly name
  40581. */
  40582. getSimpleName(): string;
  40583. }
  40584. }
  40585. declare module BABYLON {
  40586. /**
  40587. * Manage the pointers inputs to control an arc rotate camera.
  40588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40589. */
  40590. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  40591. /**
  40592. * Defines the camera the input is attached to.
  40593. */
  40594. camera: ArcRotateCamera;
  40595. /**
  40596. * Defines the buttons associated with the input to handle camera move.
  40597. */
  40598. buttons: number[];
  40599. /**
  40600. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40601. */
  40602. angularSensibilityX: number;
  40603. /**
  40604. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40605. */
  40606. angularSensibilityY: number;
  40607. /**
  40608. * Defines the pointer pinch precision or how fast is the camera zooming.
  40609. */
  40610. pinchPrecision: number;
  40611. /**
  40612. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  40613. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40614. */
  40615. pinchDeltaPercentage: number;
  40616. /**
  40617. * Defines the pointer panning sensibility or how fast is the camera moving.
  40618. */
  40619. panningSensibility: number;
  40620. /**
  40621. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  40622. */
  40623. multiTouchPanning: boolean;
  40624. /**
  40625. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  40626. */
  40627. multiTouchPanAndZoom: boolean;
  40628. /**
  40629. * Revers pinch action direction.
  40630. */
  40631. pinchInwards: boolean;
  40632. private _isPanClick;
  40633. private _pointerInput;
  40634. private _observer;
  40635. private _onMouseMove;
  40636. private _onGestureStart;
  40637. private _onGesture;
  40638. private _MSGestureHandler;
  40639. private _onLostFocus;
  40640. private _onContextMenu;
  40641. /**
  40642. * Attach the input controls to a specific dom element to get the input from.
  40643. * @param element Defines the element the controls should be listened from
  40644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40645. */
  40646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40647. /**
  40648. * Detach the current controls from the specified dom element.
  40649. * @param element Defines the element to stop listening the inputs from
  40650. */
  40651. detachControl(element: Nullable<HTMLElement>): void;
  40652. /**
  40653. * Gets the class name of the current intput.
  40654. * @returns the class name
  40655. */
  40656. getClassName(): string;
  40657. /**
  40658. * Get the friendly name associated with the input class.
  40659. * @returns the input friendly name
  40660. */
  40661. getSimpleName(): string;
  40662. }
  40663. }
  40664. declare module BABYLON {
  40665. /**
  40666. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40668. */
  40669. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40670. /**
  40671. * Defines the camera the input is attached to.
  40672. */
  40673. camera: ArcRotateCamera;
  40674. /**
  40675. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40676. */
  40677. alphaCorrection: number;
  40678. /**
  40679. * Defines a correction factor applied on the beta value retrieved from the orientation events.
  40680. */
  40681. betaCorrection: number;
  40682. /**
  40683. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40684. */
  40685. gammaCorrection: number;
  40686. private _alpha;
  40687. private _gamma;
  40688. private _dirty;
  40689. private _deviceOrientationHandler;
  40690. /**
  40691. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40692. */
  40693. constructor();
  40694. /**
  40695. * Attach the input controls to a specific dom element to get the input from.
  40696. * @param element Defines the element the controls should be listened from
  40697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40698. */
  40699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40700. /** @hidden */
  40701. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40702. /**
  40703. * Update the current camera state depending on the inputs that have been used this frame.
  40704. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40705. */
  40706. checkInputs(): void;
  40707. /**
  40708. * Detach the current controls from the specified dom element.
  40709. * @param element Defines the element to stop listening the inputs from
  40710. */
  40711. detachControl(element: Nullable<HTMLElement>): void;
  40712. /**
  40713. * Gets the class name of the current intput.
  40714. * @returns the class name
  40715. */
  40716. getClassName(): string;
  40717. /**
  40718. * Get the friendly name associated with the input class.
  40719. * @returns the input friendly name
  40720. */
  40721. getSimpleName(): string;
  40722. }
  40723. }
  40724. declare module BABYLON {
  40725. /**
  40726. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40727. * Screen rotation is taken into account.
  40728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40729. */
  40730. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40731. private _camera;
  40732. private _screenOrientationAngle;
  40733. private _constantTranform;
  40734. private _screenQuaternion;
  40735. private _alpha;
  40736. private _beta;
  40737. private _gamma;
  40738. /**
  40739. * Instantiates a new input
  40740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40741. */
  40742. constructor();
  40743. /**
  40744. * Define the camera controlled by the input.
  40745. */
  40746. camera: FreeCamera;
  40747. /**
  40748. * Attach the input controls to a specific dom element to get the input from.
  40749. * @param element Defines the element the controls should be listened from
  40750. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40751. */
  40752. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40753. private _orientationChanged;
  40754. private _deviceOrientation;
  40755. /**
  40756. * Detach the current controls from the specified dom element.
  40757. * @param element Defines the element to stop listening the inputs from
  40758. */
  40759. detachControl(element: Nullable<HTMLElement>): void;
  40760. /**
  40761. * Update the current camera state depending on the inputs that have been used this frame.
  40762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40763. */
  40764. checkInputs(): void;
  40765. /**
  40766. * Gets the class name of the current intput.
  40767. * @returns the class name
  40768. */
  40769. getClassName(): string;
  40770. /**
  40771. * Get the friendly name associated with the input class.
  40772. * @returns the input friendly name
  40773. */
  40774. getSimpleName(): string;
  40775. }
  40776. }
  40777. declare module BABYLON {
  40778. /**
  40779. * Manage the gamepad inputs to control a free camera.
  40780. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40781. */
  40782. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40783. /**
  40784. * Define the camera the input is attached to.
  40785. */
  40786. camera: FreeCamera;
  40787. /**
  40788. * Define the Gamepad controlling the input
  40789. */
  40790. gamepad: Nullable<Gamepad>;
  40791. /**
  40792. * Defines the gamepad rotation sensiblity.
  40793. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40794. */
  40795. gamepadAngularSensibility: number;
  40796. /**
  40797. * Defines the gamepad move sensiblity.
  40798. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40799. */
  40800. gamepadMoveSensibility: number;
  40801. private _onGamepadConnectedObserver;
  40802. private _onGamepadDisconnectedObserver;
  40803. private _cameraTransform;
  40804. private _deltaTransform;
  40805. private _vector3;
  40806. private _vector2;
  40807. /**
  40808. * Attach the input controls to a specific dom element to get the input from.
  40809. * @param element Defines the element the controls should be listened from
  40810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40811. */
  40812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40813. /**
  40814. * Detach the current controls from the specified dom element.
  40815. * @param element Defines the element to stop listening the inputs from
  40816. */
  40817. detachControl(element: Nullable<HTMLElement>): void;
  40818. /**
  40819. * Update the current camera state depending on the inputs that have been used this frame.
  40820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40821. */
  40822. checkInputs(): void;
  40823. /**
  40824. * Gets the class name of the current intput.
  40825. * @returns the class name
  40826. */
  40827. getClassName(): string;
  40828. /**
  40829. * Get the friendly name associated with the input class.
  40830. * @returns the input friendly name
  40831. */
  40832. getSimpleName(): string;
  40833. }
  40834. }
  40835. declare module BABYLON {
  40836. /**
  40837. * Manage the keyboard inputs to control the movement of a free camera.
  40838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40839. */
  40840. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  40841. /**
  40842. * Defines the camera the input is attached to.
  40843. */
  40844. camera: FreeCamera;
  40845. /**
  40846. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  40847. */
  40848. keysUp: number[];
  40849. /**
  40850. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  40851. */
  40852. keysDown: number[];
  40853. /**
  40854. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  40855. */
  40856. keysLeft: number[];
  40857. /**
  40858. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  40859. */
  40860. keysRight: number[];
  40861. private _keys;
  40862. private _onCanvasBlurObserver;
  40863. private _onKeyboardObserver;
  40864. private _engine;
  40865. private _scene;
  40866. /**
  40867. * Attach the input controls to a specific dom element to get the input from.
  40868. * @param element Defines the element the controls should be listened from
  40869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40870. */
  40871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40872. /**
  40873. * Detach the current controls from the specified dom element.
  40874. * @param element Defines the element to stop listening the inputs from
  40875. */
  40876. detachControl(element: Nullable<HTMLElement>): void;
  40877. /**
  40878. * Update the current camera state depending on the inputs that have been used this frame.
  40879. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40880. */
  40881. checkInputs(): void;
  40882. /**
  40883. * Gets the class name of the current intput.
  40884. * @returns the class name
  40885. */
  40886. getClassName(): string;
  40887. /** @hidden */
  40888. _onLostFocus(e: FocusEvent): void;
  40889. /**
  40890. * Get the friendly name associated with the input class.
  40891. * @returns the input friendly name
  40892. */
  40893. getSimpleName(): string;
  40894. }
  40895. }
  40896. declare module BABYLON {
  40897. /**
  40898. * Manage the mouse inputs to control the movement of a free camera.
  40899. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40900. */
  40901. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  40902. /**
  40903. * Define if touch is enabled in the mouse input
  40904. */
  40905. touchEnabled: boolean;
  40906. /**
  40907. * Defines the camera the input is attached to.
  40908. */
  40909. camera: FreeCamera;
  40910. /**
  40911. * Defines the buttons associated with the input to handle camera move.
  40912. */
  40913. buttons: number[];
  40914. /**
  40915. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  40916. */
  40917. angularSensibility: number;
  40918. private _pointerInput;
  40919. private _onMouseMove;
  40920. private _observer;
  40921. private previousPosition;
  40922. /**
  40923. * Manage the mouse inputs to control the movement of a free camera.
  40924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40925. * @param touchEnabled Defines if touch is enabled or not
  40926. */
  40927. constructor(
  40928. /**
  40929. * Define if touch is enabled in the mouse input
  40930. */
  40931. touchEnabled?: boolean);
  40932. /**
  40933. * Attach the input controls to a specific dom element to get the input from.
  40934. * @param element Defines the element the controls should be listened from
  40935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40936. */
  40937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40938. /**
  40939. * Detach the current controls from the specified dom element.
  40940. * @param element Defines the element to stop listening the inputs from
  40941. */
  40942. detachControl(element: Nullable<HTMLElement>): void;
  40943. /**
  40944. * Gets the class name of the current intput.
  40945. * @returns the class name
  40946. */
  40947. getClassName(): string;
  40948. /**
  40949. * Get the friendly name associated with the input class.
  40950. * @returns the input friendly name
  40951. */
  40952. getSimpleName(): string;
  40953. }
  40954. }
  40955. declare module BABYLON {
  40956. /**
  40957. * Manage the touch inputs to control the movement of a free camera.
  40958. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40959. */
  40960. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  40961. /**
  40962. * Defines the camera the input is attached to.
  40963. */
  40964. camera: FreeCamera;
  40965. /**
  40966. * Defines the touch sensibility for rotation.
  40967. * The higher the faster.
  40968. */
  40969. touchAngularSensibility: number;
  40970. /**
  40971. * Defines the touch sensibility for move.
  40972. * The higher the faster.
  40973. */
  40974. touchMoveSensibility: number;
  40975. private _offsetX;
  40976. private _offsetY;
  40977. private _pointerPressed;
  40978. private _pointerInput;
  40979. private _observer;
  40980. private _onLostFocus;
  40981. /**
  40982. * Attach the input controls to a specific dom element to get the input from.
  40983. * @param element Defines the element the controls should be listened from
  40984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40985. */
  40986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40987. /**
  40988. * Detach the current controls from the specified dom element.
  40989. * @param element Defines the element to stop listening the inputs from
  40990. */
  40991. detachControl(element: Nullable<HTMLElement>): void;
  40992. /**
  40993. * Update the current camera state depending on the inputs that have been used this frame.
  40994. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40995. */
  40996. checkInputs(): void;
  40997. /**
  40998. * Gets the class name of the current intput.
  40999. * @returns the class name
  41000. */
  41001. getClassName(): string;
  41002. /**
  41003. * Get the friendly name associated with the input class.
  41004. * @returns the input friendly name
  41005. */
  41006. getSimpleName(): string;
  41007. }
  41008. }
  41009. declare module BABYLON {
  41010. /**
  41011. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41013. */
  41014. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41015. /**
  41016. * Defines the camera the input is attached to.
  41017. */
  41018. camera: FreeCamera;
  41019. private _leftjoystick;
  41020. private _rightjoystick;
  41021. /**
  41022. * Gets the left stick of the virtual joystick.
  41023. * @returns The virtual Joystick
  41024. */
  41025. getLeftJoystick(): VirtualJoystick;
  41026. /**
  41027. * Gets the right stick of the virtual joystick.
  41028. * @returns The virtual Joystick
  41029. */
  41030. getRightJoystick(): VirtualJoystick;
  41031. /**
  41032. * Update the current camera state depending on the inputs that have been used this frame.
  41033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41034. */
  41035. checkInputs(): void;
  41036. /**
  41037. * Attach the input controls to a specific dom element to get the input from.
  41038. * @param element Defines the element the controls should be listened from
  41039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41040. */
  41041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41042. /**
  41043. * Detach the current controls from the specified dom element.
  41044. * @param element Defines the element to stop listening the inputs from
  41045. */
  41046. detachControl(element: Nullable<HTMLElement>): void;
  41047. /**
  41048. * Gets the class name of the current intput.
  41049. * @returns the class name
  41050. */
  41051. getClassName(): string;
  41052. /**
  41053. * Get the friendly name associated with the input class.
  41054. * @returns the input friendly name
  41055. */
  41056. getSimpleName(): string;
  41057. }
  41058. }
  41059. declare module BABYLON {
  41060. /**
  41061. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41062. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41063. */
  41064. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41065. /**
  41066. * Creates a new AnaglyphArcRotateCamera
  41067. * @param name defines camera name
  41068. * @param alpha defines alpha angle (in radians)
  41069. * @param beta defines beta angle (in radians)
  41070. * @param radius defines radius
  41071. * @param target defines camera target
  41072. * @param interaxialDistance defines distance between each color axis
  41073. * @param scene defines the hosting scene
  41074. */
  41075. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41076. /**
  41077. * Gets camera class name
  41078. * @returns AnaglyphArcRotateCamera
  41079. */
  41080. getClassName(): string;
  41081. }
  41082. }
  41083. declare module BABYLON {
  41084. /**
  41085. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41086. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41087. */
  41088. class AnaglyphFreeCamera extends FreeCamera {
  41089. /**
  41090. * Creates a new AnaglyphFreeCamera
  41091. * @param name defines camera name
  41092. * @param position defines initial position
  41093. * @param interaxialDistance defines distance between each color axis
  41094. * @param scene defines the hosting scene
  41095. */
  41096. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41097. /**
  41098. * Gets camera class name
  41099. * @returns AnaglyphFreeCamera
  41100. */
  41101. getClassName(): string;
  41102. }
  41103. }
  41104. declare module BABYLON {
  41105. /**
  41106. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41107. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41108. */
  41109. class AnaglyphGamepadCamera extends GamepadCamera {
  41110. /**
  41111. * Creates a new AnaglyphGamepadCamera
  41112. * @param name defines camera name
  41113. * @param position defines initial position
  41114. * @param interaxialDistance defines distance between each color axis
  41115. * @param scene defines the hosting scene
  41116. */
  41117. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41118. /**
  41119. * Gets camera class name
  41120. * @returns AnaglyphGamepadCamera
  41121. */
  41122. getClassName(): string;
  41123. }
  41124. }
  41125. declare module BABYLON {
  41126. /**
  41127. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41128. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41129. */
  41130. class AnaglyphUniversalCamera extends UniversalCamera {
  41131. /**
  41132. * Creates a new AnaglyphUniversalCamera
  41133. * @param name defines camera name
  41134. * @param position defines initial position
  41135. * @param interaxialDistance defines distance between each color axis
  41136. * @param scene defines the hosting scene
  41137. */
  41138. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41139. /**
  41140. * Gets camera class name
  41141. * @returns AnaglyphUniversalCamera
  41142. */
  41143. getClassName(): string;
  41144. }
  41145. }
  41146. declare module BABYLON {
  41147. /**
  41148. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41149. * @see http://doc.babylonjs.com/features/cameras
  41150. */
  41151. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41152. /**
  41153. * Creates a new StereoscopicArcRotateCamera
  41154. * @param name defines camera name
  41155. * @param alpha defines alpha angle (in radians)
  41156. * @param beta defines beta angle (in radians)
  41157. * @param radius defines radius
  41158. * @param target defines camera target
  41159. * @param interaxialDistance defines distance between each color axis
  41160. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41161. * @param scene defines the hosting scene
  41162. */
  41163. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41164. /**
  41165. * Gets camera class name
  41166. * @returns StereoscopicArcRotateCamera
  41167. */
  41168. getClassName(): string;
  41169. }
  41170. }
  41171. declare module BABYLON {
  41172. /**
  41173. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41174. * @see http://doc.babylonjs.com/features/cameras
  41175. */
  41176. class StereoscopicFreeCamera extends FreeCamera {
  41177. /**
  41178. * Creates a new StereoscopicFreeCamera
  41179. * @param name defines camera name
  41180. * @param position defines initial position
  41181. * @param interaxialDistance defines distance between each color axis
  41182. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41183. * @param scene defines the hosting scene
  41184. */
  41185. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41186. /**
  41187. * Gets camera class name
  41188. * @returns StereoscopicFreeCamera
  41189. */
  41190. getClassName(): string;
  41191. }
  41192. }
  41193. declare module BABYLON {
  41194. /**
  41195. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41196. * @see http://doc.babylonjs.com/features/cameras
  41197. */
  41198. class StereoscopicGamepadCamera extends GamepadCamera {
  41199. /**
  41200. * Creates a new StereoscopicGamepadCamera
  41201. * @param name defines camera name
  41202. * @param position defines initial position
  41203. * @param interaxialDistance defines distance between each color axis
  41204. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41205. * @param scene defines the hosting scene
  41206. */
  41207. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41208. /**
  41209. * Gets camera class name
  41210. * @returns StereoscopicGamepadCamera
  41211. */
  41212. getClassName(): string;
  41213. }
  41214. }
  41215. declare module BABYLON {
  41216. /**
  41217. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41218. * @see http://doc.babylonjs.com/features/cameras
  41219. */
  41220. class StereoscopicUniversalCamera extends UniversalCamera {
  41221. /**
  41222. * Creates a new StereoscopicUniversalCamera
  41223. * @param name defines camera name
  41224. * @param position defines initial position
  41225. * @param interaxialDistance defines distance between each color axis
  41226. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41227. * @param scene defines the hosting scene
  41228. */
  41229. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41230. /**
  41231. * Gets camera class name
  41232. * @returns StereoscopicUniversalCamera
  41233. */
  41234. getClassName(): string;
  41235. }
  41236. }
  41237. declare module BABYLON {
  41238. /**
  41239. * This represents all the required metrics to create a VR camera.
  41240. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41241. */
  41242. class VRCameraMetrics {
  41243. /**
  41244. * Define the horizontal resolution off the screen.
  41245. */
  41246. hResolution: number;
  41247. /**
  41248. * Define the vertical resolution off the screen.
  41249. */
  41250. vResolution: number;
  41251. /**
  41252. * Define the horizontal screen size.
  41253. */
  41254. hScreenSize: number;
  41255. /**
  41256. * Define the vertical screen size.
  41257. */
  41258. vScreenSize: number;
  41259. /**
  41260. * Define the vertical screen center position.
  41261. */
  41262. vScreenCenter: number;
  41263. /**
  41264. * Define the distance of the eyes to the screen.
  41265. */
  41266. eyeToScreenDistance: number;
  41267. /**
  41268. * Define the distance between both lenses
  41269. */
  41270. lensSeparationDistance: number;
  41271. /**
  41272. * Define the distance between both viewer's eyes.
  41273. */
  41274. interpupillaryDistance: number;
  41275. /**
  41276. * Define the distortion factor of the VR postprocess.
  41277. * Please, touch with care.
  41278. */
  41279. distortionK: number[];
  41280. /**
  41281. * Define the chromatic aberration correction factors for the VR post process.
  41282. */
  41283. chromaAbCorrection: number[];
  41284. /**
  41285. * Define the scale factor of the post process.
  41286. * The smaller the better but the slower.
  41287. */
  41288. postProcessScaleFactor: number;
  41289. /**
  41290. * Define an offset for the lens center.
  41291. */
  41292. lensCenterOffset: number;
  41293. /**
  41294. * Define if the current vr camera should compensate the distortion of the lense or not.
  41295. */
  41296. compensateDistortion: boolean;
  41297. /**
  41298. * Gets the rendering aspect ratio based on the provided resolutions.
  41299. */
  41300. readonly aspectRatio: number;
  41301. /**
  41302. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41303. */
  41304. readonly aspectRatioFov: number;
  41305. /**
  41306. * @hidden
  41307. */
  41308. readonly leftHMatrix: Matrix;
  41309. /**
  41310. * @hidden
  41311. */
  41312. readonly rightHMatrix: Matrix;
  41313. /**
  41314. * @hidden
  41315. */
  41316. readonly leftPreViewMatrix: Matrix;
  41317. /**
  41318. * @hidden
  41319. */
  41320. readonly rightPreViewMatrix: Matrix;
  41321. /**
  41322. * Get the default VRMetrics based on the most generic setup.
  41323. * @returns the default vr metrics
  41324. */
  41325. static GetDefault(): VRCameraMetrics;
  41326. }
  41327. }
  41328. declare module BABYLON {
  41329. /**
  41330. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41331. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41332. */
  41333. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41334. /**
  41335. * Creates a new VRDeviceOrientationArcRotateCamera
  41336. * @param name defines camera name
  41337. * @param alpha defines the camera rotation along the logitudinal axis
  41338. * @param beta defines the camera rotation along the latitudinal axis
  41339. * @param radius defines the camera distance from its target
  41340. * @param target defines the camera target
  41341. * @param scene defines the scene the camera belongs to
  41342. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41343. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41344. */
  41345. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41346. /**
  41347. * Gets camera class name
  41348. * @returns VRDeviceOrientationArcRotateCamera
  41349. */
  41350. getClassName(): string;
  41351. }
  41352. }
  41353. declare module BABYLON {
  41354. /**
  41355. * Camera used to simulate VR rendering (based on FreeCamera)
  41356. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41357. */
  41358. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41359. /**
  41360. * Creates a new VRDeviceOrientationFreeCamera
  41361. * @param name defines camera name
  41362. * @param position defines the start position of the camera
  41363. * @param scene defines the scene the camera belongs to
  41364. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41365. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41366. */
  41367. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41368. /**
  41369. * Gets camera class name
  41370. * @returns VRDeviceOrientationFreeCamera
  41371. */
  41372. getClassName(): string;
  41373. }
  41374. }
  41375. declare module BABYLON {
  41376. /**
  41377. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41378. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41379. */
  41380. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41381. /**
  41382. * Creates a new VRDeviceOrientationGamepadCamera
  41383. * @param name defines camera name
  41384. * @param position defines the start position of the camera
  41385. * @param scene defines the scene the camera belongs to
  41386. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41387. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41388. */
  41389. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41390. /**
  41391. * Gets camera class name
  41392. * @returns VRDeviceOrientationGamepadCamera
  41393. */
  41394. getClassName(): string;
  41395. }
  41396. }
  41397. declare module BABYLON {
  41398. /**
  41399. * Options to modify the vr teleportation behavior.
  41400. */
  41401. interface VRTeleportationOptions {
  41402. /**
  41403. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41404. */
  41405. floorMeshName?: string;
  41406. /**
  41407. * A list of meshes to be used as the teleportation floor. (default: empty)
  41408. */
  41409. floorMeshes?: Mesh[];
  41410. }
  41411. /**
  41412. * Options to modify the vr experience helper's behavior.
  41413. */
  41414. interface VRExperienceHelperOptions extends WebVROptions {
  41415. /**
  41416. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41417. */
  41418. createDeviceOrientationCamera?: boolean;
  41419. /**
  41420. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41421. */
  41422. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41423. /**
  41424. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41425. */
  41426. laserToggle?: boolean;
  41427. /**
  41428. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41429. */
  41430. floorMeshes?: Mesh[];
  41431. }
  41432. /**
  41433. * Helps to quickly add VR support to an existing scene.
  41434. * See http://doc.babylonjs.com/how_to/webvr_helper
  41435. */
  41436. class VRExperienceHelper {
  41437. /** Options to modify the vr experience helper's behavior. */
  41438. webVROptions: VRExperienceHelperOptions;
  41439. private _scene;
  41440. private _position;
  41441. private _btnVR;
  41442. private _btnVRDisplayed;
  41443. private _webVRsupported;
  41444. private _webVRready;
  41445. private _webVRrequesting;
  41446. private _webVRpresenting;
  41447. private _hasEnteredVR;
  41448. private _fullscreenVRpresenting;
  41449. private _canvas;
  41450. private _webVRCamera;
  41451. private _vrDeviceOrientationCamera;
  41452. private _deviceOrientationCamera;
  41453. private _existingCamera;
  41454. private _onKeyDown;
  41455. private _onVrDisplayPresentChange;
  41456. private _onVRDisplayChanged;
  41457. private _onVRRequestPresentStart;
  41458. private _onVRRequestPresentComplete;
  41459. /**
  41460. * Observable raised when entering VR.
  41461. */
  41462. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41463. /**
  41464. * Observable raised when exiting VR.
  41465. */
  41466. onExitingVRObservable: Observable<VRExperienceHelper>;
  41467. /**
  41468. * Observable raised when controller mesh is loaded.
  41469. */
  41470. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41471. /** Return this.onEnteringVRObservable
  41472. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41473. */
  41474. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41475. /** Return this.onExitingVRObservable
  41476. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41477. */
  41478. readonly onExitingVR: Observable<VRExperienceHelper>;
  41479. /** Return this.onControllerMeshLoadedObservable
  41480. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41481. */
  41482. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41483. private _rayLength;
  41484. private _useCustomVRButton;
  41485. private _teleportationRequested;
  41486. private _teleportActive;
  41487. private _floorMeshName;
  41488. private _floorMeshesCollection;
  41489. private _rotationAllowed;
  41490. private _teleportBackwardsVector;
  41491. private _teleportationTarget;
  41492. private _isDefaultTeleportationTarget;
  41493. private _postProcessMove;
  41494. private _teleportationFillColor;
  41495. private _teleportationBorderColor;
  41496. private _rotationAngle;
  41497. private _haloCenter;
  41498. private _cameraGazer;
  41499. private _padSensibilityUp;
  41500. private _padSensibilityDown;
  41501. private _leftController;
  41502. private _rightController;
  41503. /**
  41504. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41505. */
  41506. onNewMeshSelected: Observable<AbstractMesh>;
  41507. /**
  41508. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41509. */
  41510. onNewMeshPicked: Observable<PickingInfo>;
  41511. private _circleEase;
  41512. /**
  41513. * Observable raised before camera teleportation
  41514. */
  41515. onBeforeCameraTeleport: Observable<Vector3>;
  41516. /**
  41517. * Observable raised after camera teleportation
  41518. */
  41519. onAfterCameraTeleport: Observable<Vector3>;
  41520. /**
  41521. * Observable raised when current selected mesh gets unselected
  41522. */
  41523. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41524. private _raySelectionPredicate;
  41525. /**
  41526. * To be optionaly changed by user to define custom ray selection
  41527. */
  41528. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41529. /**
  41530. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41531. */
  41532. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41533. /**
  41534. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41535. */
  41536. teleportationEnabled: boolean;
  41537. private _defaultHeight;
  41538. private _teleportationInitialized;
  41539. private _interactionsEnabled;
  41540. private _interactionsRequested;
  41541. private _displayGaze;
  41542. private _displayLaserPointer;
  41543. /**
  41544. * The mesh used to display where the user is going to teleport.
  41545. */
  41546. /**
  41547. * Sets the mesh to be used to display where the user is going to teleport.
  41548. */
  41549. teleportationTarget: Mesh;
  41550. /**
  41551. * 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
  41552. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41553. * See http://doc.babylonjs.com/resources/baking_transformations
  41554. */
  41555. gazeTrackerMesh: Mesh;
  41556. /**
  41557. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41558. */
  41559. updateGazeTrackerScale: boolean;
  41560. /**
  41561. * The gaze tracking mesh corresponding to the left controller
  41562. */
  41563. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41564. /**
  41565. * The gaze tracking mesh corresponding to the right controller
  41566. */
  41567. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41568. /**
  41569. * If the ray of the gaze should be displayed.
  41570. */
  41571. /**
  41572. * Sets if the ray of the gaze should be displayed.
  41573. */
  41574. displayGaze: boolean;
  41575. /**
  41576. * If the ray of the LaserPointer should be displayed.
  41577. */
  41578. /**
  41579. * Sets if the ray of the LaserPointer should be displayed.
  41580. */
  41581. displayLaserPointer: boolean;
  41582. /**
  41583. * The deviceOrientationCamera used as the camera when not in VR.
  41584. */
  41585. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41586. /**
  41587. * Based on the current WebVR support, returns the current VR camera used.
  41588. */
  41589. readonly currentVRCamera: Nullable<Camera>;
  41590. /**
  41591. * The webVRCamera which is used when in VR.
  41592. */
  41593. readonly webVRCamera: WebVRFreeCamera;
  41594. /**
  41595. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41596. */
  41597. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41598. private readonly _teleportationRequestInitiated;
  41599. /**
  41600. * Instantiates a VRExperienceHelper.
  41601. * Helps to quickly add VR support to an existing scene.
  41602. * @param scene The scene the VRExperienceHelper belongs to.
  41603. * @param webVROptions Options to modify the vr experience helper's behavior.
  41604. */
  41605. constructor(scene: Scene,
  41606. /** Options to modify the vr experience helper's behavior. */
  41607. webVROptions?: VRExperienceHelperOptions);
  41608. private _onDefaultMeshLoaded;
  41609. private _onResize;
  41610. private _onFullscreenChange;
  41611. /**
  41612. * Gets a value indicating if we are currently in VR mode.
  41613. */
  41614. readonly isInVRMode: boolean;
  41615. private onVrDisplayPresentChange;
  41616. private onVRDisplayChanged;
  41617. private moveButtonToBottomRight;
  41618. private displayVRButton;
  41619. private updateButtonVisibility;
  41620. /**
  41621. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41622. * Otherwise, will use the fullscreen API.
  41623. */
  41624. enterVR(): void;
  41625. /**
  41626. * Attempt to exit VR, or fullscreen.
  41627. */
  41628. exitVR(): void;
  41629. /**
  41630. * The position of the vr experience helper.
  41631. */
  41632. /**
  41633. * Sets the position of the vr experience helper.
  41634. */
  41635. position: Vector3;
  41636. /**
  41637. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41638. */
  41639. enableInteractions(): void;
  41640. private readonly _noControllerIsActive;
  41641. private beforeRender;
  41642. private _isTeleportationFloor;
  41643. /**
  41644. * Adds a floor mesh to be used for teleportation.
  41645. * @param floorMesh the mesh to be used for teleportation.
  41646. */
  41647. addFloorMesh(floorMesh: Mesh): void;
  41648. /**
  41649. * Removes a floor mesh from being used for teleportation.
  41650. * @param floorMesh the mesh to be removed.
  41651. */
  41652. removeFloorMesh(floorMesh: Mesh): void;
  41653. /**
  41654. * Enables interactions and teleportation using the VR controllers and gaze.
  41655. * @param vrTeleportationOptions options to modify teleportation behavior.
  41656. */
  41657. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41658. private _onNewGamepadConnected;
  41659. private _tryEnableInteractionOnController;
  41660. private _onNewGamepadDisconnected;
  41661. private _enableInteractionOnController;
  41662. private _checkTeleportWithRay;
  41663. private _checkRotate;
  41664. private _checkTeleportBackwards;
  41665. private _enableTeleportationOnController;
  41666. private _createTeleportationCircles;
  41667. private _displayTeleportationTarget;
  41668. private _hideTeleportationTarget;
  41669. private _rotateCamera;
  41670. private _moveTeleportationSelectorTo;
  41671. private _workingVector;
  41672. private _workingQuaternion;
  41673. private _workingMatrix;
  41674. /**
  41675. * Teleports the users feet to the desired location
  41676. * @param location The location where the user's feet should be placed
  41677. */
  41678. teleportCamera(location: Vector3): void;
  41679. private _convertNormalToDirectionOfRay;
  41680. private _castRayAndSelectObject;
  41681. private _notifySelectedMeshUnselected;
  41682. /**
  41683. * Sets the color of the laser ray from the vr controllers.
  41684. * @param color new color for the ray.
  41685. */
  41686. changeLaserColor(color: Color3): void;
  41687. /**
  41688. * Sets the color of the ray from the vr headsets gaze.
  41689. * @param color new color for the ray.
  41690. */
  41691. changeGazeColor(color: Color3): void;
  41692. /**
  41693. * Exits VR and disposes of the vr experience helper
  41694. */
  41695. dispose(): void;
  41696. /**
  41697. * Gets the name of the VRExperienceHelper class
  41698. * @returns "VRExperienceHelper"
  41699. */
  41700. getClassName(): string;
  41701. }
  41702. }
  41703. declare module BABYLON {
  41704. /**
  41705. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  41706. * IMPORTANT!! The data is right-hand data.
  41707. * @export
  41708. * @interface DevicePose
  41709. */
  41710. interface DevicePose {
  41711. /**
  41712. * The position of the device, values in array are [x,y,z].
  41713. */
  41714. readonly position: Nullable<Float32Array>;
  41715. /**
  41716. * The linearVelocity of the device, values in array are [x,y,z].
  41717. */
  41718. readonly linearVelocity: Nullable<Float32Array>;
  41719. /**
  41720. * The linearAcceleration of the device, values in array are [x,y,z].
  41721. */
  41722. readonly linearAcceleration: Nullable<Float32Array>;
  41723. /**
  41724. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  41725. */
  41726. readonly orientation: Nullable<Float32Array>;
  41727. /**
  41728. * The angularVelocity of the device, values in array are [x,y,z].
  41729. */
  41730. readonly angularVelocity: Nullable<Float32Array>;
  41731. /**
  41732. * The angularAcceleration of the device, values in array are [x,y,z].
  41733. */
  41734. readonly angularAcceleration: Nullable<Float32Array>;
  41735. }
  41736. /**
  41737. * Interface representing a pose controlled object in Babylon.
  41738. * A pose controlled object has both regular pose values as well as pose values
  41739. * from an external device such as a VR head mounted display
  41740. */
  41741. interface PoseControlled {
  41742. /**
  41743. * The position of the object in babylon space.
  41744. */
  41745. position: Vector3;
  41746. /**
  41747. * The rotation quaternion of the object in babylon space.
  41748. */
  41749. rotationQuaternion: Quaternion;
  41750. /**
  41751. * The position of the device in babylon space.
  41752. */
  41753. devicePosition?: Vector3;
  41754. /**
  41755. * The rotation quaternion of the device in babylon space.
  41756. */
  41757. deviceRotationQuaternion: Quaternion;
  41758. /**
  41759. * The raw pose coming from the device.
  41760. */
  41761. rawPose: Nullable<DevicePose>;
  41762. /**
  41763. * The scale of the device to be used when translating from device space to babylon space.
  41764. */
  41765. deviceScaleFactor: number;
  41766. /**
  41767. * Updates the poseControlled values based on the input device pose.
  41768. * @param poseData the pose data to update the object with
  41769. */
  41770. updateFromDevice(poseData: DevicePose): void;
  41771. }
  41772. /**
  41773. * Set of options to customize the webVRCamera
  41774. */
  41775. interface WebVROptions {
  41776. /**
  41777. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  41778. */
  41779. trackPosition?: boolean;
  41780. /**
  41781. * Sets the scale of the vrDevice in babylon space. (default: 1)
  41782. */
  41783. positionScale?: number;
  41784. /**
  41785. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  41786. */
  41787. displayName?: string;
  41788. /**
  41789. * Should the native controller meshes be initialized. (default: true)
  41790. */
  41791. controllerMeshes?: boolean;
  41792. /**
  41793. * Creating a default HemiLight only on controllers. (default: true)
  41794. */
  41795. defaultLightingOnControllers?: boolean;
  41796. /**
  41797. * If you don't want to use the default VR button of the helper. (default: false)
  41798. */
  41799. useCustomVRButton?: boolean;
  41800. /**
  41801. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  41802. */
  41803. customVRButton?: HTMLButtonElement;
  41804. /**
  41805. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  41806. */
  41807. rayLength?: number;
  41808. /**
  41809. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  41810. */
  41811. defaultHeight?: number;
  41812. }
  41813. /**
  41814. * This represents a WebVR camera.
  41815. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  41816. * @example http://doc.babylonjs.com/how_to/webvr_camera
  41817. */
  41818. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  41819. private webVROptions;
  41820. /**
  41821. * @hidden
  41822. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  41823. */
  41824. _vrDevice: any;
  41825. /**
  41826. * The rawPose of the vrDevice.
  41827. */
  41828. rawPose: Nullable<DevicePose>;
  41829. private _onVREnabled;
  41830. private _specsVersion;
  41831. private _attached;
  41832. private _frameData;
  41833. protected _descendants: Array<Node>;
  41834. private _deviceRoomPosition;
  41835. /** @hidden */
  41836. _deviceRoomRotationQuaternion: Quaternion;
  41837. private _standingMatrix;
  41838. /**
  41839. * Represents device position in babylon space.
  41840. */
  41841. devicePosition: Vector3;
  41842. /**
  41843. * Represents device rotation in babylon space.
  41844. */
  41845. deviceRotationQuaternion: Quaternion;
  41846. /**
  41847. * The scale of the device to be used when translating from device space to babylon space.
  41848. */
  41849. deviceScaleFactor: number;
  41850. private _deviceToWorld;
  41851. private _worldToDevice;
  41852. /**
  41853. * References to the webVR controllers for the vrDevice.
  41854. */
  41855. controllers: Array<WebVRController>;
  41856. /**
  41857. * Emits an event when a controller is attached.
  41858. */
  41859. onControllersAttachedObservable: Observable<WebVRController[]>;
  41860. /**
  41861. * Emits an event when a controller's mesh has been loaded;
  41862. */
  41863. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41864. /**
  41865. * Emits an event when the HMD's pose has been updated.
  41866. */
  41867. onPoseUpdatedFromDeviceObservable: Observable<any>;
  41868. private _poseSet;
  41869. /**
  41870. * If the rig cameras be used as parent instead of this camera.
  41871. */
  41872. rigParenting: boolean;
  41873. private _lightOnControllers;
  41874. private _defaultHeight?;
  41875. /**
  41876. * Instantiates a WebVRFreeCamera.
  41877. * @param name The name of the WebVRFreeCamera
  41878. * @param position The starting anchor position for the camera
  41879. * @param scene The scene the camera belongs to
  41880. * @param webVROptions a set of customizable options for the webVRCamera
  41881. */
  41882. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  41883. /**
  41884. * Gets the device distance from the ground in meters.
  41885. * @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.
  41886. */
  41887. deviceDistanceToRoomGround(): number;
  41888. /**
  41889. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  41890. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  41891. */
  41892. useStandingMatrix(callback?: (bool: boolean) => void): void;
  41893. /**
  41894. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  41895. * @returns A promise with a boolean set to if the standing matrix is supported.
  41896. */
  41897. useStandingMatrixAsync(): Promise<boolean>;
  41898. /**
  41899. * Disposes the camera
  41900. */
  41901. dispose(): void;
  41902. /**
  41903. * Gets a vrController by name.
  41904. * @param name The name of the controller to retreive
  41905. * @returns the controller matching the name specified or null if not found
  41906. */
  41907. getControllerByName(name: string): Nullable<WebVRController>;
  41908. private _leftController;
  41909. /**
  41910. * The controller corrisponding to the users left hand.
  41911. */
  41912. readonly leftController: Nullable<WebVRController>;
  41913. private _rightController;
  41914. /**
  41915. * The controller corrisponding to the users right hand.
  41916. */
  41917. readonly rightController: Nullable<WebVRController>;
  41918. /**
  41919. * Casts a ray forward from the vrCamera's gaze.
  41920. * @param length Length of the ray (default: 100)
  41921. * @returns the ray corrisponding to the gaze
  41922. */
  41923. getForwardRay(length?: number): Ray;
  41924. /**
  41925. * @hidden
  41926. * Updates the camera based on device's frame data
  41927. */
  41928. _checkInputs(): void;
  41929. /**
  41930. * Updates the poseControlled values based on the input device pose.
  41931. * @param poseData Pose coming from the device
  41932. */
  41933. updateFromDevice(poseData: DevicePose): void;
  41934. private _htmlElementAttached;
  41935. private _detachIfAttached;
  41936. /**
  41937. * WebVR's attach control will start broadcasting frames to the device.
  41938. * Note that in certain browsers (chrome for example) this function must be called
  41939. * within a user-interaction callback. Example:
  41940. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  41941. *
  41942. * @param element html element to attach the vrDevice to
  41943. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  41944. */
  41945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41946. /**
  41947. * Detaches the camera from the html element and disables VR
  41948. *
  41949. * @param element html element to detach from
  41950. */
  41951. detachControl(element: HTMLElement): void;
  41952. /**
  41953. * @returns the name of this class
  41954. */
  41955. getClassName(): string;
  41956. /**
  41957. * Calls resetPose on the vrDisplay
  41958. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  41959. */
  41960. resetToCurrentRotation(): void;
  41961. /**
  41962. * @hidden
  41963. * Updates the rig cameras (left and right eye)
  41964. */
  41965. _updateRigCameras(): void;
  41966. private _workingVector;
  41967. private _oneVector;
  41968. private _workingMatrix;
  41969. private updateCacheCalled;
  41970. private _correctPositionIfNotTrackPosition;
  41971. /**
  41972. * @hidden
  41973. * Updates the cached values of the camera
  41974. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  41975. */
  41976. _updateCache(ignoreParentClass?: boolean): void;
  41977. /**
  41978. * @hidden
  41979. * Get current device position in babylon world
  41980. */
  41981. _computeDevicePosition(): void;
  41982. /**
  41983. * Updates the current device position and rotation in the babylon world
  41984. */
  41985. update(): void;
  41986. /**
  41987. * @hidden
  41988. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  41989. * @returns an identity matrix
  41990. */
  41991. _getViewMatrix(): Matrix;
  41992. private _tmpMatrix;
  41993. /**
  41994. * This function is called by the two RIG cameras.
  41995. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  41996. */
  41997. protected _getWebVRViewMatrix(): Matrix;
  41998. protected _getWebVRProjectionMatrix(): Matrix;
  41999. private _onGamepadConnectedObserver;
  42000. private _onGamepadDisconnectedObserver;
  42001. private _updateCacheWhenTrackingDisabledObserver;
  42002. /**
  42003. * Initializes the controllers and their meshes
  42004. */
  42005. initControllers(): void;
  42006. }
  42007. }
  42008. declare module BABYLON {
  42009. /** @hidden */
  42010. class _OcclusionDataStorage {
  42011. /** @hidden */
  42012. occlusionInternalRetryCounter: number;
  42013. /** @hidden */
  42014. isOcclusionQueryInProgress: boolean;
  42015. /** @hidden */
  42016. isOccluded: boolean;
  42017. /** @hidden */
  42018. occlusionRetryCount: number;
  42019. /** @hidden */
  42020. occlusionType: number;
  42021. /** @hidden */
  42022. occlusionQueryAlgorithmType: number;
  42023. }
  42024. interface Engine {
  42025. /**
  42026. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42027. * @return the new query
  42028. */
  42029. createQuery(): WebGLQuery;
  42030. /**
  42031. * Delete and release a webGL query
  42032. * @param query defines the query to delete
  42033. * @return the current engine
  42034. */
  42035. deleteQuery(query: WebGLQuery): Engine;
  42036. /**
  42037. * Check if a given query has resolved and got its value
  42038. * @param query defines the query to check
  42039. * @returns true if the query got its value
  42040. */
  42041. isQueryResultAvailable(query: WebGLQuery): boolean;
  42042. /**
  42043. * Gets the value of a given query
  42044. * @param query defines the query to check
  42045. * @returns the value of the query
  42046. */
  42047. getQueryResult(query: WebGLQuery): number;
  42048. /**
  42049. * Initiates an occlusion query
  42050. * @param algorithmType defines the algorithm to use
  42051. * @param query defines the query to use
  42052. * @returns the current engine
  42053. * @see http://doc.babylonjs.com/features/occlusionquery
  42054. */
  42055. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42056. /**
  42057. * Ends an occlusion query
  42058. * @see http://doc.babylonjs.com/features/occlusionquery
  42059. * @param algorithmType defines the algorithm to use
  42060. * @returns the current engine
  42061. */
  42062. endOcclusionQuery(algorithmType: number): Engine;
  42063. /**
  42064. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42065. * Please note that only one query can be issued at a time
  42066. * @returns a time token used to track the time span
  42067. */
  42068. startTimeQuery(): Nullable<_TimeToken>;
  42069. /**
  42070. * Ends a time query
  42071. * @param token defines the token used to measure the time span
  42072. * @returns the time spent (in ns)
  42073. */
  42074. endTimeQuery(token: _TimeToken): int;
  42075. /** @hidden */
  42076. _currentNonTimestampToken: Nullable<_TimeToken>;
  42077. /** @hidden */
  42078. _createTimeQuery(): WebGLQuery;
  42079. /** @hidden */
  42080. _deleteTimeQuery(query: WebGLQuery): void;
  42081. /** @hidden */
  42082. _getGlAlgorithmType(algorithmType: number): number;
  42083. /** @hidden */
  42084. _getTimeQueryResult(query: WebGLQuery): any;
  42085. /** @hidden */
  42086. _getTimeQueryAvailability(query: WebGLQuery): any;
  42087. }
  42088. interface AbstractMesh {
  42089. /**
  42090. * Backing filed
  42091. * @hidden
  42092. */
  42093. __occlusionDataStorage: _OcclusionDataStorage;
  42094. /**
  42095. * Access property
  42096. * @hidden
  42097. */
  42098. _occlusionDataStorage: _OcclusionDataStorage;
  42099. /**
  42100. * 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.
  42101. * The default value is -1 which means don't break the query and wait till the result
  42102. * @see http://doc.babylonjs.com/features/occlusionquery
  42103. */
  42104. occlusionRetryCount: number;
  42105. /**
  42106. * 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:
  42107. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42108. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42109. * * 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.
  42110. * @see http://doc.babylonjs.com/features/occlusionquery
  42111. */
  42112. occlusionType: number;
  42113. /**
  42114. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42115. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42116. * * 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.
  42117. * @see http://doc.babylonjs.com/features/occlusionquery
  42118. */
  42119. occlusionQueryAlgorithmType: number;
  42120. /**
  42121. * 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
  42122. * @see http://doc.babylonjs.com/features/occlusionquery
  42123. */
  42124. isOccluded: boolean;
  42125. /**
  42126. * Flag to check the progress status of the query
  42127. * @see http://doc.babylonjs.com/features/occlusionquery
  42128. */
  42129. isOcclusionQueryInProgress: boolean;
  42130. }
  42131. }
  42132. declare module BABYLON {
  42133. interface Engine {
  42134. /**
  42135. * Creates a webGL transform feedback object
  42136. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42137. * @returns the webGL transform feedback object
  42138. */
  42139. createTransformFeedback(): WebGLTransformFeedback;
  42140. /**
  42141. * Delete a webGL transform feedback object
  42142. * @param value defines the webGL transform feedback object to delete
  42143. */
  42144. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42145. /**
  42146. * Bind a webGL transform feedback object to the webgl context
  42147. * @param value defines the webGL transform feedback object to bind
  42148. */
  42149. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42150. /**
  42151. * Begins a transform feedback operation
  42152. * @param usePoints defines if points or triangles must be used
  42153. */
  42154. beginTransformFeedback(usePoints: boolean): void;
  42155. /**
  42156. * Ends a transform feedback operation
  42157. */
  42158. endTransformFeedback(): void;
  42159. /**
  42160. * Specify the varyings to use with transform feedback
  42161. * @param program defines the associated webGL program
  42162. * @param value defines the list of strings representing the varying names
  42163. */
  42164. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42165. /**
  42166. * Bind a webGL buffer for a transform feedback operation
  42167. * @param value defines the webGL buffer to bind
  42168. */
  42169. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42170. }
  42171. }
  42172. declare module BABYLON {
  42173. /**
  42174. * Google Daydream controller
  42175. */
  42176. class DaydreamController extends WebVRController {
  42177. /**
  42178. * Base Url for the controller model.
  42179. */
  42180. static MODEL_BASE_URL: string;
  42181. /**
  42182. * File name for the controller model.
  42183. */
  42184. static MODEL_FILENAME: string;
  42185. /**
  42186. * Gamepad Id prefix used to identify Daydream Controller.
  42187. */
  42188. static readonly GAMEPAD_ID_PREFIX: string;
  42189. /**
  42190. * Creates a new DaydreamController from a gamepad
  42191. * @param vrGamepad the gamepad that the controller should be created from
  42192. */
  42193. constructor(vrGamepad: any);
  42194. /**
  42195. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42196. * @param scene scene in which to add meshes
  42197. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42198. */
  42199. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42200. /**
  42201. * Called once for each button that changed state since the last frame
  42202. * @param buttonIdx Which button index changed
  42203. * @param state New state of the button
  42204. * @param changes Which properties on the state changed since last frame
  42205. */
  42206. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42207. }
  42208. }
  42209. declare module BABYLON {
  42210. /**
  42211. * Gear VR Controller
  42212. */
  42213. class GearVRController extends WebVRController {
  42214. /**
  42215. * Base Url for the controller model.
  42216. */
  42217. static MODEL_BASE_URL: string;
  42218. /**
  42219. * File name for the controller model.
  42220. */
  42221. static MODEL_FILENAME: string;
  42222. /**
  42223. * Gamepad Id prefix used to identify this controller.
  42224. */
  42225. static readonly GAMEPAD_ID_PREFIX: string;
  42226. private readonly _buttonIndexToObservableNameMap;
  42227. /**
  42228. * Creates a new GearVRController from a gamepad
  42229. * @param vrGamepad the gamepad that the controller should be created from
  42230. */
  42231. constructor(vrGamepad: any);
  42232. /**
  42233. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42234. * @param scene scene in which to add meshes
  42235. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42236. */
  42237. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42238. /**
  42239. * Called once for each button that changed state since the last frame
  42240. * @param buttonIdx Which button index changed
  42241. * @param state New state of the button
  42242. * @param changes Which properties on the state changed since last frame
  42243. */
  42244. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42245. }
  42246. }
  42247. declare module BABYLON {
  42248. /**
  42249. * Generic Controller
  42250. */
  42251. class GenericController extends WebVRController {
  42252. /**
  42253. * Base Url for the controller model.
  42254. */
  42255. static readonly MODEL_BASE_URL: string;
  42256. /**
  42257. * File name for the controller model.
  42258. */
  42259. static readonly MODEL_FILENAME: string;
  42260. /**
  42261. * Creates a new GenericController from a gamepad
  42262. * @param vrGamepad the gamepad that the controller should be created from
  42263. */
  42264. constructor(vrGamepad: any);
  42265. /**
  42266. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42267. * @param scene scene in which to add meshes
  42268. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42269. */
  42270. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42271. /**
  42272. * Called once for each button that changed state since the last frame
  42273. * @param buttonIdx Which button index changed
  42274. * @param state New state of the button
  42275. * @param changes Which properties on the state changed since last frame
  42276. */
  42277. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42278. }
  42279. }
  42280. declare module BABYLON {
  42281. /**
  42282. * Oculus Touch Controller
  42283. */
  42284. class OculusTouchController extends WebVRController {
  42285. /**
  42286. * Base Url for the controller model.
  42287. */
  42288. static MODEL_BASE_URL: string;
  42289. /**
  42290. * File name for the left controller model.
  42291. */
  42292. static MODEL_LEFT_FILENAME: string;
  42293. /**
  42294. * File name for the right controller model.
  42295. */
  42296. static MODEL_RIGHT_FILENAME: string;
  42297. /**
  42298. * Fired when the secondary trigger on this controller is modified
  42299. */
  42300. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42301. /**
  42302. * Fired when the thumb rest on this controller is modified
  42303. */
  42304. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42305. /**
  42306. * Creates a new OculusTouchController from a gamepad
  42307. * @param vrGamepad the gamepad that the controller should be created from
  42308. */
  42309. constructor(vrGamepad: any);
  42310. /**
  42311. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42312. * @param scene scene in which to add meshes
  42313. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42314. */
  42315. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42316. /**
  42317. * Fired when the A button on this controller is modified
  42318. */
  42319. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42320. /**
  42321. * Fired when the B button on this controller is modified
  42322. */
  42323. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42324. /**
  42325. * Fired when the X button on this controller is modified
  42326. */
  42327. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42328. /**
  42329. * Fired when the Y button on this controller is modified
  42330. */
  42331. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42332. /**
  42333. * Called once for each button that changed state since the last frame
  42334. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42335. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42336. * 2) secondary trigger (same)
  42337. * 3) A (right) X (left), touch, pressed = value
  42338. * 4) B / Y
  42339. * 5) thumb rest
  42340. * @param buttonIdx Which button index changed
  42341. * @param state New state of the button
  42342. * @param changes Which properties on the state changed since last frame
  42343. */
  42344. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42345. }
  42346. }
  42347. declare module BABYLON {
  42348. /**
  42349. * Defines the types of pose enabled controllers that are supported
  42350. */
  42351. enum PoseEnabledControllerType {
  42352. /**
  42353. * HTC Vive
  42354. */
  42355. VIVE = 0,
  42356. /**
  42357. * Oculus Rift
  42358. */
  42359. OCULUS = 1,
  42360. /**
  42361. * Windows mixed reality
  42362. */
  42363. WINDOWS = 2,
  42364. /**
  42365. * Samsung gear VR
  42366. */
  42367. GEAR_VR = 3,
  42368. /**
  42369. * Google Daydream
  42370. */
  42371. DAYDREAM = 4,
  42372. /**
  42373. * Generic
  42374. */
  42375. GENERIC = 5
  42376. }
  42377. /**
  42378. * Defines the MutableGamepadButton interface for the state of a gamepad button
  42379. */
  42380. interface MutableGamepadButton {
  42381. /**
  42382. * Value of the button/trigger
  42383. */
  42384. value: number;
  42385. /**
  42386. * If the button/trigger is currently touched
  42387. */
  42388. touched: boolean;
  42389. /**
  42390. * If the button/trigger is currently pressed
  42391. */
  42392. pressed: boolean;
  42393. }
  42394. /**
  42395. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  42396. * @hidden
  42397. */
  42398. interface ExtendedGamepadButton extends GamepadButton {
  42399. /**
  42400. * If the button/trigger is currently pressed
  42401. */
  42402. readonly pressed: boolean;
  42403. /**
  42404. * If the button/trigger is currently touched
  42405. */
  42406. readonly touched: boolean;
  42407. /**
  42408. * Value of the button/trigger
  42409. */
  42410. readonly value: number;
  42411. }
  42412. /**
  42413. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  42414. */
  42415. class PoseEnabledControllerHelper {
  42416. /**
  42417. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  42418. * @param vrGamepad the gamepad to initialized
  42419. * @returns a vr controller of the type the gamepad identified as
  42420. */
  42421. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  42422. }
  42423. /**
  42424. * Defines the PoseEnabledController object that contains state of a vr capable controller
  42425. */
  42426. class PoseEnabledController extends Gamepad implements PoseControlled {
  42427. private _deviceRoomPosition;
  42428. private _deviceRoomRotationQuaternion;
  42429. /**
  42430. * The device position in babylon space
  42431. */
  42432. devicePosition: Vector3;
  42433. /**
  42434. * The device rotation in babylon space
  42435. */
  42436. deviceRotationQuaternion: Quaternion;
  42437. /**
  42438. * The scale factor of the device in babylon space
  42439. */
  42440. deviceScaleFactor: number;
  42441. /**
  42442. * (Likely devicePosition should be used instead) The device position in its room space
  42443. */
  42444. position: Vector3;
  42445. /**
  42446. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  42447. */
  42448. rotationQuaternion: Quaternion;
  42449. /**
  42450. * The type of controller (Eg. Windows mixed reality)
  42451. */
  42452. controllerType: PoseEnabledControllerType;
  42453. protected _calculatedPosition: Vector3;
  42454. private _calculatedRotation;
  42455. /**
  42456. * The raw pose from the device
  42457. */
  42458. rawPose: DevicePose;
  42459. private _trackPosition;
  42460. private _maxRotationDistFromHeadset;
  42461. private _draggedRoomRotation;
  42462. /**
  42463. * @hidden
  42464. */
  42465. _disableTrackPosition(fixedPosition: Vector3): void;
  42466. /**
  42467. * Internal, the mesh attached to the controller
  42468. * @hidden
  42469. */
  42470. _mesh: Nullable<AbstractMesh>;
  42471. private _poseControlledCamera;
  42472. private _leftHandSystemQuaternion;
  42473. /**
  42474. * Internal, matrix used to convert room space to babylon space
  42475. * @hidden
  42476. */
  42477. _deviceToWorld: Matrix;
  42478. /**
  42479. * Node to be used when casting a ray from the controller
  42480. * @hidden
  42481. */
  42482. _pointingPoseNode: Nullable<AbstractMesh>;
  42483. /**
  42484. * Name of the child mesh that can be used to cast a ray from the controller
  42485. */
  42486. static readonly POINTING_POSE: string;
  42487. /**
  42488. * Creates a new PoseEnabledController from a gamepad
  42489. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  42490. */
  42491. constructor(browserGamepad: any);
  42492. private _workingMatrix;
  42493. /**
  42494. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  42495. */
  42496. update(): void;
  42497. /**
  42498. * Updates only the pose device and mesh without doing any button event checking
  42499. */
  42500. protected _updatePoseAndMesh(): void;
  42501. /**
  42502. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  42503. * @param poseData raw pose fromthe device
  42504. */
  42505. updateFromDevice(poseData: DevicePose): void;
  42506. /**
  42507. * @hidden
  42508. */
  42509. _meshAttachedObservable: Observable<AbstractMesh>;
  42510. /**
  42511. * Attaches a mesh to the controller
  42512. * @param mesh the mesh to be attached
  42513. */
  42514. attachToMesh(mesh: AbstractMesh): void;
  42515. /**
  42516. * Attaches the controllers mesh to a camera
  42517. * @param camera the camera the mesh should be attached to
  42518. */
  42519. attachToPoseControlledCamera(camera: TargetCamera): void;
  42520. /**
  42521. * Disposes of the controller
  42522. */
  42523. dispose(): void;
  42524. /**
  42525. * The mesh that is attached to the controller
  42526. */
  42527. readonly mesh: Nullable<AbstractMesh>;
  42528. /**
  42529. * Gets the ray of the controller in the direction the controller is pointing
  42530. * @param length the length the resulting ray should be
  42531. * @returns a ray in the direction the controller is pointing
  42532. */
  42533. getForwardRay(length?: number): Ray;
  42534. }
  42535. }
  42536. declare module BABYLON {
  42537. /**
  42538. * Vive Controller
  42539. */
  42540. class ViveController extends WebVRController {
  42541. /**
  42542. * Base Url for the controller model.
  42543. */
  42544. static MODEL_BASE_URL: string;
  42545. /**
  42546. * File name for the controller model.
  42547. */
  42548. static MODEL_FILENAME: string;
  42549. /**
  42550. * Creates a new ViveController from a gamepad
  42551. * @param vrGamepad the gamepad that the controller should be created from
  42552. */
  42553. constructor(vrGamepad: any);
  42554. /**
  42555. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42556. * @param scene scene in which to add meshes
  42557. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42558. */
  42559. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42560. /**
  42561. * Fired when the left button on this controller is modified
  42562. */
  42563. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42564. /**
  42565. * Fired when the right button on this controller is modified
  42566. */
  42567. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42568. /**
  42569. * Fired when the menu button on this controller is modified
  42570. */
  42571. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42572. /**
  42573. * Called once for each button that changed state since the last frame
  42574. * Vive mapping:
  42575. * 0: touchpad
  42576. * 1: trigger
  42577. * 2: left AND right buttons
  42578. * 3: menu button
  42579. * @param buttonIdx Which button index changed
  42580. * @param state New state of the button
  42581. * @param changes Which properties on the state changed since last frame
  42582. */
  42583. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42584. }
  42585. }
  42586. declare module BABYLON {
  42587. /**
  42588. * Defines the WebVRController object that represents controllers tracked in 3D space
  42589. */
  42590. abstract class WebVRController extends PoseEnabledController {
  42591. /**
  42592. * Internal, the default controller model for the controller
  42593. */
  42594. protected _defaultModel: AbstractMesh;
  42595. /**
  42596. * Fired when the trigger state has changed
  42597. */
  42598. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42599. /**
  42600. * Fired when the main button state has changed
  42601. */
  42602. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42603. /**
  42604. * Fired when the secondary button state has changed
  42605. */
  42606. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42607. /**
  42608. * Fired when the pad state has changed
  42609. */
  42610. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  42611. /**
  42612. * Fired when controllers stick values have changed
  42613. */
  42614. onPadValuesChangedObservable: Observable<StickValues>;
  42615. /**
  42616. * Array of button availible on the controller
  42617. */
  42618. protected _buttons: Array<MutableGamepadButton>;
  42619. private _onButtonStateChange;
  42620. /**
  42621. * Fired when a controller button's state has changed
  42622. * @param callback the callback containing the button that was modified
  42623. */
  42624. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  42625. /**
  42626. * X and Y axis corrisponding to the controllers joystick
  42627. */
  42628. pad: StickValues;
  42629. /**
  42630. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  42631. */
  42632. hand: string;
  42633. /**
  42634. * The default controller model for the controller
  42635. */
  42636. readonly defaultModel: AbstractMesh;
  42637. /**
  42638. * Creates a new WebVRController from a gamepad
  42639. * @param vrGamepad the gamepad that the WebVRController should be created from
  42640. */
  42641. constructor(vrGamepad: any);
  42642. /**
  42643. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  42644. */
  42645. update(): void;
  42646. /**
  42647. * Function to be called when a button is modified
  42648. */
  42649. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42650. /**
  42651. * Loads a mesh and attaches it to the controller
  42652. * @param scene the scene the mesh should be added to
  42653. * @param meshLoaded callback for when the mesh has been loaded
  42654. */
  42655. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42656. private _setButtonValue;
  42657. private _changes;
  42658. private _checkChanges;
  42659. /**
  42660. * Disposes of th webVRCOntroller
  42661. */
  42662. dispose(): void;
  42663. }
  42664. }
  42665. declare module BABYLON {
  42666. /**
  42667. * Defines the WindowsMotionController object that the state of the windows motion controller
  42668. */
  42669. class WindowsMotionController extends WebVRController {
  42670. /**
  42671. * The base url used to load the left and right controller models
  42672. */
  42673. static MODEL_BASE_URL: string;
  42674. /**
  42675. * The name of the left controller model file
  42676. */
  42677. static MODEL_LEFT_FILENAME: string;
  42678. /**
  42679. * The name of the right controller model file
  42680. */
  42681. static MODEL_RIGHT_FILENAME: string;
  42682. /**
  42683. * The controller name prefix for this controller type
  42684. */
  42685. static readonly GAMEPAD_ID_PREFIX: string;
  42686. /**
  42687. * The controller id pattern for this controller type
  42688. */
  42689. private static readonly GAMEPAD_ID_PATTERN;
  42690. private _loadedMeshInfo;
  42691. private readonly _mapping;
  42692. /**
  42693. * Fired when the trackpad on this controller is clicked
  42694. */
  42695. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42696. /**
  42697. * Fired when the trackpad on this controller is modified
  42698. */
  42699. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42700. /**
  42701. * The current x and y values of this controller's trackpad
  42702. */
  42703. trackpad: StickValues;
  42704. /**
  42705. * Creates a new WindowsMotionController from a gamepad
  42706. * @param vrGamepad the gamepad that the controller should be created from
  42707. */
  42708. constructor(vrGamepad: any);
  42709. /**
  42710. * Fired when the trigger on this controller is modified
  42711. */
  42712. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42713. /**
  42714. * Fired when the menu button on this controller is modified
  42715. */
  42716. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42717. /**
  42718. * Fired when the grip button on this controller is modified
  42719. */
  42720. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42721. /**
  42722. * Fired when the thumbstick button on this controller is modified
  42723. */
  42724. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42725. /**
  42726. * Fired when the touchpad button on this controller is modified
  42727. */
  42728. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42729. /**
  42730. * Fired when the touchpad values on this controller are modified
  42731. */
  42732. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42733. private _updateTrackpad;
  42734. /**
  42735. * Called once per frame by the engine.
  42736. */
  42737. update(): void;
  42738. /**
  42739. * Called once for each button that changed state since the last frame
  42740. * @param buttonIdx Which button index changed
  42741. * @param state New state of the button
  42742. * @param changes Which properties on the state changed since last frame
  42743. */
  42744. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42745. /**
  42746. * Moves the buttons on the controller mesh based on their current state
  42747. * @param buttonName the name of the button to move
  42748. * @param buttonValue the value of the button which determines the buttons new position
  42749. */
  42750. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42751. /**
  42752. * Moves the axis on the controller mesh based on its current state
  42753. * @param axis the index of the axis
  42754. * @param axisValue the value of the axis which determines the meshes new position
  42755. * @hidden
  42756. */
  42757. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42758. /**
  42759. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42760. * @param scene scene in which to add meshes
  42761. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42762. */
  42763. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42764. /**
  42765. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42766. * can be transformed by button presses and axes values, based on this._mapping.
  42767. *
  42768. * @param scene scene in which the meshes exist
  42769. * @param meshes list of meshes that make up the controller model to process
  42770. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42771. */
  42772. private processModel;
  42773. private createMeshInfo;
  42774. /**
  42775. * Gets the ray of the controller in the direction the controller is pointing
  42776. * @param length the length the resulting ray should be
  42777. * @returns a ray in the direction the controller is pointing
  42778. */
  42779. getForwardRay(length?: number): Ray;
  42780. /**
  42781. * Disposes of the controller
  42782. */
  42783. dispose(): void;
  42784. }
  42785. }
  42786. declare module BABYLON {
  42787. /**
  42788. * Interface to implement to create a shadow generator compatible with BJS.
  42789. */
  42790. interface IShadowGenerator {
  42791. /**
  42792. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  42793. * @returns The render target texture if present otherwise, null
  42794. */
  42795. getShadowMap(): Nullable<RenderTargetTexture>;
  42796. /**
  42797. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  42798. * @returns The render target texture if the shadow map is present otherwise, null
  42799. */
  42800. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  42801. /**
  42802. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  42803. * @param subMesh The submesh we want to render in the shadow map
  42804. * @param useInstances Defines wether will draw in the map using instances
  42805. * @returns true if ready otherwise, false
  42806. */
  42807. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  42808. /**
  42809. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  42810. * @param defines Defines of the material we want to update
  42811. * @param lightIndex Index of the light in the enabled light list of the material
  42812. */
  42813. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  42814. /**
  42815. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  42816. * defined in the generator but impacting the effect).
  42817. * It implies the unifroms available on the materials are the standard BJS ones.
  42818. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  42819. * @param effect The effect we are binfing the information for
  42820. */
  42821. bindShadowLight(lightIndex: string, effect: Effect): void;
  42822. /**
  42823. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  42824. * (eq to shadow prjection matrix * light transform matrix)
  42825. * @returns The transform matrix used to create the shadow map
  42826. */
  42827. getTransformMatrix(): Matrix;
  42828. /**
  42829. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  42830. * Cube and 2D textures for instance.
  42831. */
  42832. recreateShadowMap(): void;
  42833. /**
  42834. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  42835. * @param onCompiled Callback triggered at the and of the effects compilation
  42836. * @param options Sets of optional options forcing the compilation with different modes
  42837. */
  42838. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  42839. useInstances: boolean;
  42840. }>): void;
  42841. /**
  42842. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  42843. * @param options Sets of optional options forcing the compilation with different modes
  42844. * @returns A promise that resolves when the compilation completes
  42845. */
  42846. forceCompilationAsync(options?: Partial<{
  42847. useInstances: boolean;
  42848. }>): Promise<void>;
  42849. /**
  42850. * Serializes the shadow generator setup to a json object.
  42851. * @returns The serialized JSON object
  42852. */
  42853. serialize(): any;
  42854. /**
  42855. * Disposes the Shadow map and related Textures and effects.
  42856. */
  42857. dispose(): void;
  42858. }
  42859. /**
  42860. * Default implementation IShadowGenerator.
  42861. * This is the main object responsible of generating shadows in the framework.
  42862. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  42863. */
  42864. class ShadowGenerator implements IShadowGenerator {
  42865. /**
  42866. * Shadow generator mode None: no filtering applied.
  42867. */
  42868. static readonly FILTER_NONE: number;
  42869. /**
  42870. * Shadow generator mode ESM: Exponential Shadow Mapping.
  42871. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  42872. */
  42873. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  42874. /**
  42875. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  42876. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  42877. */
  42878. static readonly FILTER_POISSONSAMPLING: number;
  42879. /**
  42880. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  42881. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  42882. */
  42883. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  42884. /**
  42885. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  42886. * edge artifacts on steep falloff.
  42887. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  42888. */
  42889. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  42890. /**
  42891. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  42892. * edge artifacts on steep falloff.
  42893. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  42894. */
  42895. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  42896. /**
  42897. * Shadow generator mode PCF: Percentage Closer Filtering
  42898. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  42899. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  42900. */
  42901. static readonly FILTER_PCF: number;
  42902. /**
  42903. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  42904. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  42905. * Contact Hardening
  42906. */
  42907. static readonly FILTER_PCSS: number;
  42908. /**
  42909. * Reserved for PCF and PCSS
  42910. * Highest Quality.
  42911. *
  42912. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  42913. *
  42914. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  42915. */
  42916. static readonly QUALITY_HIGH: number;
  42917. /**
  42918. * Reserved for PCF and PCSS
  42919. * Good tradeoff for quality/perf cross devices
  42920. *
  42921. * Execute PCF on a 3*3 kernel.
  42922. *
  42923. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  42924. */
  42925. static readonly QUALITY_MEDIUM: number;
  42926. /**
  42927. * Reserved for PCF and PCSS
  42928. * The lowest quality but the fastest.
  42929. *
  42930. * Execute PCF on a 1*1 kernel.
  42931. *
  42932. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  42933. */
  42934. static readonly QUALITY_LOW: number;
  42935. private _bias;
  42936. /**
  42937. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  42938. */
  42939. /**
  42940. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  42941. */
  42942. bias: number;
  42943. private _normalBias;
  42944. /**
  42945. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  42946. */
  42947. /**
  42948. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  42949. */
  42950. normalBias: number;
  42951. private _blurBoxOffset;
  42952. /**
  42953. * Gets the blur box offset: offset applied during the blur pass.
  42954. * Only usefull if useKernelBlur = false
  42955. */
  42956. /**
  42957. * Sets the blur box offset: offset applied during the blur pass.
  42958. * Only usefull if useKernelBlur = false
  42959. */
  42960. blurBoxOffset: number;
  42961. private _blurScale;
  42962. /**
  42963. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  42964. * 2 means half of the size.
  42965. */
  42966. /**
  42967. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  42968. * 2 means half of the size.
  42969. */
  42970. blurScale: number;
  42971. private _blurKernel;
  42972. /**
  42973. * Gets the blur kernel: kernel size of the blur pass.
  42974. * Only usefull if useKernelBlur = true
  42975. */
  42976. /**
  42977. * Sets the blur kernel: kernel size of the blur pass.
  42978. * Only usefull if useKernelBlur = true
  42979. */
  42980. blurKernel: number;
  42981. private _useKernelBlur;
  42982. /**
  42983. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  42984. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  42985. */
  42986. /**
  42987. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  42988. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  42989. */
  42990. useKernelBlur: boolean;
  42991. private _depthScale;
  42992. /**
  42993. * Gets the depth scale used in ESM mode.
  42994. */
  42995. /**
  42996. * Sets the depth scale used in ESM mode.
  42997. * This can override the scale stored on the light.
  42998. */
  42999. depthScale: number;
  43000. private _filter;
  43001. /**
  43002. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  43003. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43004. */
  43005. /**
  43006. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  43007. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43008. */
  43009. filter: number;
  43010. /**
  43011. * Gets if the current filter is set to Poisson Sampling.
  43012. */
  43013. /**
  43014. * Sets the current filter to Poisson Sampling.
  43015. */
  43016. usePoissonSampling: boolean;
  43017. /**
  43018. * Gets if the current filter is set to VSM.
  43019. * DEPRECATED. Should use useExponentialShadowMap instead.
  43020. */
  43021. /**
  43022. * Sets the current filter is to VSM.
  43023. * DEPRECATED. Should use useExponentialShadowMap instead.
  43024. */
  43025. useVarianceShadowMap: boolean;
  43026. /**
  43027. * Gets if the current filter is set to blurred VSM.
  43028. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43029. */
  43030. /**
  43031. * Sets the current filter is to blurred VSM.
  43032. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43033. */
  43034. useBlurVarianceShadowMap: boolean;
  43035. /**
  43036. * Gets if the current filter is set to ESM.
  43037. */
  43038. /**
  43039. * Sets the current filter is to ESM.
  43040. */
  43041. useExponentialShadowMap: boolean;
  43042. /**
  43043. * Gets if the current filter is set to filtered ESM.
  43044. */
  43045. /**
  43046. * Gets if the current filter is set to filtered ESM.
  43047. */
  43048. useBlurExponentialShadowMap: boolean;
  43049. /**
  43050. * Gets if the current filter is set to "close ESM" (using the inverse of the
  43051. * exponential to prevent steep falloff artifacts).
  43052. */
  43053. /**
  43054. * Sets the current filter to "close ESM" (using the inverse of the
  43055. * exponential to prevent steep falloff artifacts).
  43056. */
  43057. useCloseExponentialShadowMap: boolean;
  43058. /**
  43059. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  43060. * exponential to prevent steep falloff artifacts).
  43061. */
  43062. /**
  43063. * Sets the current filter to filtered "close ESM" (using the inverse of the
  43064. * exponential to prevent steep falloff artifacts).
  43065. */
  43066. useBlurCloseExponentialShadowMap: boolean;
  43067. /**
  43068. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  43069. */
  43070. /**
  43071. * Sets the current filter to "PCF" (percentage closer filtering).
  43072. */
  43073. usePercentageCloserFiltering: boolean;
  43074. private _filteringQuality;
  43075. /**
  43076. * Gets the PCF or PCSS Quality.
  43077. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43078. */
  43079. /**
  43080. * Sets the PCF or PCSS Quality.
  43081. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43082. */
  43083. filteringQuality: number;
  43084. /**
  43085. * Gets if the current filter is set to "PCSS" (contact hardening).
  43086. */
  43087. /**
  43088. * Sets the current filter to "PCSS" (contact hardening).
  43089. */
  43090. useContactHardeningShadow: boolean;
  43091. private _contactHardeningLightSizeUVRatio;
  43092. /**
  43093. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43094. * Using a ratio helps keeping shape stability independently of the map size.
  43095. *
  43096. * It does not account for the light projection as it was having too much
  43097. * instability during the light setup or during light position changes.
  43098. *
  43099. * Only valid if useContactHardeningShadow is true.
  43100. */
  43101. /**
  43102. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43103. * Using a ratio helps keeping shape stability independently of the map size.
  43104. *
  43105. * It does not account for the light projection as it was having too much
  43106. * instability during the light setup or during light position changes.
  43107. *
  43108. * Only valid if useContactHardeningShadow is true.
  43109. */
  43110. contactHardeningLightSizeUVRatio: number;
  43111. private _darkness;
  43112. /**
  43113. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  43114. * 0 means strongest and 1 would means no shadow.
  43115. * @returns the darkness.
  43116. */
  43117. getDarkness(): number;
  43118. /**
  43119. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  43120. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  43121. * @returns the shadow generator allowing fluent coding.
  43122. */
  43123. setDarkness(darkness: number): ShadowGenerator;
  43124. private _transparencyShadow;
  43125. /**
  43126. * Sets the ability to have transparent shadow (boolean).
  43127. * @param transparent True if transparent else False
  43128. * @returns the shadow generator allowing fluent coding
  43129. */
  43130. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  43131. private _shadowMap;
  43132. private _shadowMap2;
  43133. /**
  43134. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43135. * @returns The render target texture if present otherwise, null
  43136. */
  43137. getShadowMap(): Nullable<RenderTargetTexture>;
  43138. /**
  43139. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43140. * @returns The render target texture if the shadow map is present otherwise, null
  43141. */
  43142. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43143. /**
  43144. * Helper function to add a mesh and its descendants to the list of shadow casters.
  43145. * @param mesh Mesh to add
  43146. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  43147. * @returns the Shadow Generator itself
  43148. */
  43149. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  43150. /**
  43151. * Helper function to remove a mesh and its descendants from the list of shadow casters
  43152. * @param mesh Mesh to remove
  43153. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  43154. * @returns the Shadow Generator itself
  43155. */
  43156. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  43157. /**
  43158. * Controls the extent to which the shadows fade out at the edge of the frustum
  43159. * Used only by directionals and spots
  43160. */
  43161. frustumEdgeFalloff: number;
  43162. private _light;
  43163. /**
  43164. * Returns the associated light object.
  43165. * @returns the light generating the shadow
  43166. */
  43167. getLight(): IShadowLight;
  43168. /**
  43169. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  43170. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  43171. * It might on the other hand introduce peter panning.
  43172. */
  43173. forceBackFacesOnly: boolean;
  43174. private _scene;
  43175. private _lightDirection;
  43176. private _effect;
  43177. private _viewMatrix;
  43178. private _projectionMatrix;
  43179. private _transformMatrix;
  43180. private _cachedPosition;
  43181. private _cachedDirection;
  43182. private _cachedDefines;
  43183. private _currentRenderID;
  43184. private _boxBlurPostprocess;
  43185. private _kernelBlurXPostprocess;
  43186. private _kernelBlurYPostprocess;
  43187. private _blurPostProcesses;
  43188. private _mapSize;
  43189. private _currentFaceIndex;
  43190. private _currentFaceIndexCache;
  43191. private _textureType;
  43192. private _defaultTextureMatrix;
  43193. /**
  43194. * Creates a ShadowGenerator object.
  43195. * A ShadowGenerator is the required tool to use the shadows.
  43196. * Each light casting shadows needs to use its own ShadowGenerator.
  43197. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  43198. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  43199. * @param light The light object generating the shadows.
  43200. * @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.
  43201. */
  43202. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  43203. private _initializeGenerator;
  43204. private _initializeShadowMap;
  43205. private _initializeBlurRTTAndPostProcesses;
  43206. private _renderForShadowMap;
  43207. private _renderSubMeshForShadowMap;
  43208. private _applyFilterValues;
  43209. /**
  43210. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43211. * @param onCompiled Callback triggered at the and of the effects compilation
  43212. * @param options Sets of optional options forcing the compilation with different modes
  43213. */
  43214. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  43215. useInstances: boolean;
  43216. }>): void;
  43217. /**
  43218. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43219. * @param options Sets of optional options forcing the compilation with different modes
  43220. * @returns A promise that resolves when the compilation completes
  43221. */
  43222. forceCompilationAsync(options?: Partial<{
  43223. useInstances: boolean;
  43224. }>): Promise<void>;
  43225. /**
  43226. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43227. * @param subMesh The submesh we want to render in the shadow map
  43228. * @param useInstances Defines wether will draw in the map using instances
  43229. * @returns true if ready otherwise, false
  43230. */
  43231. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43232. /**
  43233. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43234. * @param defines Defines of the material we want to update
  43235. * @param lightIndex Index of the light in the enabled light list of the material
  43236. */
  43237. prepareDefines(defines: any, lightIndex: number): void;
  43238. /**
  43239. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43240. * defined in the generator but impacting the effect).
  43241. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43242. * @param effect The effect we are binfing the information for
  43243. */
  43244. bindShadowLight(lightIndex: string, effect: Effect): void;
  43245. /**
  43246. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43247. * (eq to shadow prjection matrix * light transform matrix)
  43248. * @returns The transform matrix used to create the shadow map
  43249. */
  43250. getTransformMatrix(): Matrix;
  43251. /**
  43252. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43253. * Cube and 2D textures for instance.
  43254. */
  43255. recreateShadowMap(): void;
  43256. private _disposeBlurPostProcesses;
  43257. private _disposeRTTandPostProcesses;
  43258. /**
  43259. * Disposes the ShadowGenerator.
  43260. * Returns nothing.
  43261. */
  43262. dispose(): void;
  43263. /**
  43264. * Serializes the shadow generator setup to a json object.
  43265. * @returns The serialized JSON object
  43266. */
  43267. serialize(): any;
  43268. /**
  43269. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  43270. * @param parsedShadowGenerator The JSON object to parse
  43271. * @param scene The scene to create the shadow map for
  43272. * @returns The parsed shadow generator
  43273. */
  43274. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  43275. }
  43276. }
  43277. declare module BABYLON {
  43278. /**
  43279. * Defines the shadow generator component responsible to manage any shadow generators
  43280. * in a given scene.
  43281. */
  43282. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  43283. /**
  43284. * The component name helpfull to identify the component in the list of scene components.
  43285. */
  43286. readonly name: string;
  43287. /**
  43288. * The scene the component belongs to.
  43289. */
  43290. scene: Scene;
  43291. /**
  43292. * Creates a new instance of the component for the given scene
  43293. * @param scene Defines the scene to register the component in
  43294. */
  43295. constructor(scene: Scene);
  43296. /**
  43297. * Registers the component in a given scene
  43298. */
  43299. register(): void;
  43300. /**
  43301. * Rebuilds the elements related to this component in case of
  43302. * context lost for instance.
  43303. */
  43304. rebuild(): void;
  43305. /**
  43306. * Serializes the component data to the specified json object
  43307. * @param serializationObject The object to serialize to
  43308. */
  43309. serialize(serializationObject: any): void;
  43310. /**
  43311. * Adds all the element from the container to the scene
  43312. * @param container the container holding the elements
  43313. */
  43314. addFromContainer(container: AbstractScene): void;
  43315. /**
  43316. * Removes all the elements in the container from the scene
  43317. * @param container contains the elements to remove
  43318. */
  43319. removeFromContainer(container: AbstractScene): void;
  43320. /**
  43321. * Rebuilds the elements related to this component in case of
  43322. * context lost for instance.
  43323. */
  43324. dispose(): void;
  43325. private _gatherRenderTargets;
  43326. }
  43327. }
  43328. declare module BABYLON {
  43329. }
  43330. declare module BABYLON {
  43331. /**
  43332. * Background material used to create an efficient environement around your scene.
  43333. */
  43334. class BackgroundMaterial extends PushMaterial {
  43335. /**
  43336. * Standard reflectance value at parallel view angle.
  43337. */
  43338. static StandardReflectance0: number;
  43339. /**
  43340. * Standard reflectance value at grazing angle.
  43341. */
  43342. static StandardReflectance90: number;
  43343. protected _primaryColor: Color3;
  43344. /**
  43345. * Key light Color (multiply against the environement texture)
  43346. */
  43347. primaryColor: Color3;
  43348. protected __perceptualColor: Nullable<Color3>;
  43349. /**
  43350. * Experimental Internal Use Only.
  43351. *
  43352. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43353. * This acts as a helper to set the primary color to a more "human friendly" value.
  43354. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43355. * output color as close as possible from the chosen value.
  43356. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43357. * part of lighting setup.)
  43358. */
  43359. _perceptualColor: Nullable<Color3>;
  43360. protected _primaryColorShadowLevel: float;
  43361. /**
  43362. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43363. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43364. */
  43365. primaryColorShadowLevel: float;
  43366. protected _primaryColorHighlightLevel: float;
  43367. /**
  43368. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43369. * The primary color is used at the level chosen to define what the white area would look.
  43370. */
  43371. primaryColorHighlightLevel: float;
  43372. protected _reflectionTexture: Nullable<BaseTexture>;
  43373. /**
  43374. * Reflection Texture used in the material.
  43375. * Should be author in a specific way for the best result (refer to the documentation).
  43376. */
  43377. reflectionTexture: Nullable<BaseTexture>;
  43378. protected _reflectionBlur: float;
  43379. /**
  43380. * Reflection Texture level of blur.
  43381. *
  43382. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43383. * texture twice.
  43384. */
  43385. reflectionBlur: float;
  43386. protected _diffuseTexture: Nullable<BaseTexture>;
  43387. /**
  43388. * Diffuse Texture used in the material.
  43389. * Should be author in a specific way for the best result (refer to the documentation).
  43390. */
  43391. diffuseTexture: Nullable<BaseTexture>;
  43392. protected _shadowLights: Nullable<IShadowLight[]>;
  43393. /**
  43394. * Specify the list of lights casting shadow on the material.
  43395. * All scene shadow lights will be included if null.
  43396. */
  43397. shadowLights: Nullable<IShadowLight[]>;
  43398. protected _shadowLevel: float;
  43399. /**
  43400. * Helps adjusting the shadow to a softer level if required.
  43401. * 0 means black shadows and 1 means no shadows.
  43402. */
  43403. shadowLevel: float;
  43404. protected _sceneCenter: Vector3;
  43405. /**
  43406. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43407. * It is usually zero but might be interesting to modify according to your setup.
  43408. */
  43409. sceneCenter: Vector3;
  43410. protected _opacityFresnel: boolean;
  43411. /**
  43412. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43413. * This helps ensuring a nice transition when the camera goes under the ground.
  43414. */
  43415. opacityFresnel: boolean;
  43416. protected _reflectionFresnel: boolean;
  43417. /**
  43418. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43419. * This helps adding a mirror texture on the ground.
  43420. */
  43421. reflectionFresnel: boolean;
  43422. protected _reflectionFalloffDistance: number;
  43423. /**
  43424. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43425. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43426. */
  43427. reflectionFalloffDistance: number;
  43428. protected _reflectionAmount: number;
  43429. /**
  43430. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43431. */
  43432. reflectionAmount: number;
  43433. protected _reflectionReflectance0: number;
  43434. /**
  43435. * This specifies the weight of the reflection at grazing angle.
  43436. */
  43437. reflectionReflectance0: number;
  43438. protected _reflectionReflectance90: number;
  43439. /**
  43440. * This specifies the weight of the reflection at a perpendicular point of view.
  43441. */
  43442. reflectionReflectance90: number;
  43443. /**
  43444. * Sets the reflection reflectance fresnel values according to the default standard
  43445. * empirically know to work well :-)
  43446. */
  43447. reflectionStandardFresnelWeight: number;
  43448. protected _useRGBColor: boolean;
  43449. /**
  43450. * Helps to directly use the maps channels instead of their level.
  43451. */
  43452. useRGBColor: boolean;
  43453. protected _enableNoise: boolean;
  43454. /**
  43455. * This helps reducing the banding effect that could occur on the background.
  43456. */
  43457. enableNoise: boolean;
  43458. /**
  43459. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43460. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43461. * Recommended to be keep at 1.0 except for special cases.
  43462. */
  43463. fovMultiplier: number;
  43464. private _fovMultiplier;
  43465. /**
  43466. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43467. */
  43468. useEquirectangularFOV: boolean;
  43469. private _maxSimultaneousLights;
  43470. /**
  43471. * Number of Simultaneous lights allowed on the material.
  43472. */
  43473. maxSimultaneousLights: int;
  43474. /**
  43475. * Default configuration related to image processing available in the Background Material.
  43476. */
  43477. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43478. /**
  43479. * Keep track of the image processing observer to allow dispose and replace.
  43480. */
  43481. private _imageProcessingObserver;
  43482. /**
  43483. * Attaches a new image processing configuration to the PBR Material.
  43484. * @param configuration (if null the scene configuration will be use)
  43485. */
  43486. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43487. /**
  43488. * Gets the image processing configuration used either in this material.
  43489. */
  43490. /**
  43491. * Sets the Default image processing configuration used either in the this material.
  43492. *
  43493. * If sets to null, the scene one is in use.
  43494. */
  43495. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43496. /**
  43497. * Gets wether the color curves effect is enabled.
  43498. */
  43499. /**
  43500. * Sets wether the color curves effect is enabled.
  43501. */
  43502. cameraColorCurvesEnabled: boolean;
  43503. /**
  43504. * Gets wether the color grading effect is enabled.
  43505. */
  43506. /**
  43507. * Gets wether the color grading effect is enabled.
  43508. */
  43509. cameraColorGradingEnabled: boolean;
  43510. /**
  43511. * Gets wether tonemapping is enabled or not.
  43512. */
  43513. /**
  43514. * Sets wether tonemapping is enabled or not
  43515. */
  43516. cameraToneMappingEnabled: boolean;
  43517. /**
  43518. * The camera exposure used on this material.
  43519. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43520. * This corresponds to a photographic exposure.
  43521. */
  43522. /**
  43523. * The camera exposure used on this material.
  43524. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43525. * This corresponds to a photographic exposure.
  43526. */
  43527. cameraExposure: float;
  43528. /**
  43529. * Gets The camera contrast used on this material.
  43530. */
  43531. /**
  43532. * Sets The camera contrast used on this material.
  43533. */
  43534. cameraContrast: float;
  43535. /**
  43536. * Gets the Color Grading 2D Lookup Texture.
  43537. */
  43538. /**
  43539. * Sets the Color Grading 2D Lookup Texture.
  43540. */
  43541. cameraColorGradingTexture: Nullable<BaseTexture>;
  43542. /**
  43543. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43544. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43545. * 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;
  43546. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43547. */
  43548. /**
  43549. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43550. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43551. * 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;
  43552. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43553. */
  43554. cameraColorCurves: Nullable<ColorCurves>;
  43555. /**
  43556. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43557. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43558. */
  43559. switchToBGR: boolean;
  43560. private _renderTargets;
  43561. private _reflectionControls;
  43562. private _white;
  43563. private _primaryShadowColor;
  43564. private _primaryHighlightColor;
  43565. /**
  43566. * Instantiates a Background Material in the given scene
  43567. * @param name The friendly name of the material
  43568. * @param scene The scene to add the material to
  43569. */
  43570. constructor(name: string, scene: Scene);
  43571. /**
  43572. * Gets a boolean indicating that current material needs to register RTT
  43573. */
  43574. readonly hasRenderTargetTextures: boolean;
  43575. /**
  43576. * The entire material has been created in order to prevent overdraw.
  43577. * @returns false
  43578. */
  43579. needAlphaTesting(): boolean;
  43580. /**
  43581. * The entire material has been created in order to prevent overdraw.
  43582. * @returns true if blending is enable
  43583. */
  43584. needAlphaBlending(): boolean;
  43585. /**
  43586. * Checks wether the material is ready to be rendered for a given mesh.
  43587. * @param mesh The mesh to render
  43588. * @param subMesh The submesh to check against
  43589. * @param useInstances Specify wether or not the material is used with instances
  43590. * @returns true if all the dependencies are ready (Textures, Effects...)
  43591. */
  43592. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43593. /**
  43594. * Compute the primary color according to the chosen perceptual color.
  43595. */
  43596. private _computePrimaryColorFromPerceptualColor;
  43597. /**
  43598. * Compute the highlights and shadow colors according to their chosen levels.
  43599. */
  43600. private _computePrimaryColors;
  43601. /**
  43602. * Build the uniform buffer used in the material.
  43603. */
  43604. buildUniformLayout(): void;
  43605. /**
  43606. * Unbind the material.
  43607. */
  43608. unbind(): void;
  43609. /**
  43610. * Bind only the world matrix to the material.
  43611. * @param world The world matrix to bind.
  43612. */
  43613. bindOnlyWorldMatrix(world: Matrix): void;
  43614. /**
  43615. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43616. * @param world The world matrix to bind.
  43617. * @param subMesh The submesh to bind for.
  43618. */
  43619. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43620. /**
  43621. * Dispose the material.
  43622. * @param forceDisposeEffect Force disposal of the associated effect.
  43623. * @param forceDisposeTextures Force disposal of the associated textures.
  43624. */
  43625. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43626. /**
  43627. * Clones the material.
  43628. * @param name The cloned name.
  43629. * @returns The cloned material.
  43630. */
  43631. clone(name: string): BackgroundMaterial;
  43632. /**
  43633. * Serializes the current material to its JSON representation.
  43634. * @returns The JSON representation.
  43635. */
  43636. serialize(): any;
  43637. /**
  43638. * Gets the class name of the material
  43639. * @returns "BackgroundMaterial"
  43640. */
  43641. getClassName(): string;
  43642. /**
  43643. * Parse a JSON input to create back a background material.
  43644. * @param source The JSON data to parse
  43645. * @param scene The scene to create the parsed material in
  43646. * @param rootUrl The root url of the assets the material depends upon
  43647. * @returns the instantiated BackgroundMaterial.
  43648. */
  43649. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43650. }
  43651. }
  43652. declare module BABYLON {
  43653. /**
  43654. * The Physically based material base class of BJS.
  43655. *
  43656. * This offers the main features of a standard PBR material.
  43657. * For more information, please refer to the documentation :
  43658. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43659. */
  43660. abstract class PBRBaseMaterial extends PushMaterial {
  43661. /**
  43662. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  43663. */
  43664. static readonly LIGHTFALLOFF_PHYSICAL: number;
  43665. /**
  43666. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  43667. * to enhance interoperability with other engines.
  43668. */
  43669. static readonly LIGHTFALLOFF_GLTF: number;
  43670. /**
  43671. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  43672. * to enhance interoperability with other materials.
  43673. */
  43674. static readonly LIGHTFALLOFF_STANDARD: number;
  43675. /**
  43676. * Intensity of the direct lights e.g. the four lights available in your scene.
  43677. * This impacts both the direct diffuse and specular highlights.
  43678. */
  43679. protected _directIntensity: number;
  43680. /**
  43681. * Intensity of the emissive part of the material.
  43682. * This helps controlling the emissive effect without modifying the emissive color.
  43683. */
  43684. protected _emissiveIntensity: number;
  43685. /**
  43686. * Intensity of the environment e.g. how much the environment will light the object
  43687. * either through harmonics for rough material or through the refelction for shiny ones.
  43688. */
  43689. protected _environmentIntensity: number;
  43690. /**
  43691. * This is a special control allowing the reduction of the specular highlights coming from the
  43692. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43693. */
  43694. protected _specularIntensity: number;
  43695. /**
  43696. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  43697. */
  43698. private _lightingInfos;
  43699. /**
  43700. * Debug Control allowing disabling the bump map on this material.
  43701. */
  43702. protected _disableBumpMap: boolean;
  43703. /**
  43704. * AKA Diffuse Texture in standard nomenclature.
  43705. */
  43706. protected _albedoTexture: BaseTexture;
  43707. /**
  43708. * AKA Occlusion Texture in other nomenclature.
  43709. */
  43710. protected _ambientTexture: BaseTexture;
  43711. /**
  43712. * AKA Occlusion Texture Intensity in other nomenclature.
  43713. */
  43714. protected _ambientTextureStrength: number;
  43715. /**
  43716. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43717. * 1 means it completely occludes it
  43718. * 0 mean it has no impact
  43719. */
  43720. protected _ambientTextureImpactOnAnalyticalLights: number;
  43721. /**
  43722. * Stores the alpha values in a texture.
  43723. */
  43724. protected _opacityTexture: BaseTexture;
  43725. /**
  43726. * Stores the reflection values in a texture.
  43727. */
  43728. protected _reflectionTexture: BaseTexture;
  43729. /**
  43730. * Stores the refraction values in a texture.
  43731. */
  43732. protected _refractionTexture: BaseTexture;
  43733. /**
  43734. * Stores the emissive values in a texture.
  43735. */
  43736. protected _emissiveTexture: BaseTexture;
  43737. /**
  43738. * AKA Specular texture in other nomenclature.
  43739. */
  43740. protected _reflectivityTexture: BaseTexture;
  43741. /**
  43742. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43743. */
  43744. protected _metallicTexture: BaseTexture;
  43745. /**
  43746. * Specifies the metallic scalar of the metallic/roughness workflow.
  43747. * Can also be used to scale the metalness values of the metallic texture.
  43748. */
  43749. protected _metallic: Nullable<number>;
  43750. /**
  43751. * Specifies the roughness scalar of the metallic/roughness workflow.
  43752. * Can also be used to scale the roughness values of the metallic texture.
  43753. */
  43754. protected _roughness: Nullable<number>;
  43755. /**
  43756. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43757. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43758. */
  43759. protected _microSurfaceTexture: BaseTexture;
  43760. /**
  43761. * Stores surface normal data used to displace a mesh in a texture.
  43762. */
  43763. protected _bumpTexture: BaseTexture;
  43764. /**
  43765. * Stores the pre-calculated light information of a mesh in a texture.
  43766. */
  43767. protected _lightmapTexture: BaseTexture;
  43768. /**
  43769. * The color of a material in ambient lighting.
  43770. */
  43771. protected _ambientColor: Color3;
  43772. /**
  43773. * AKA Diffuse Color in other nomenclature.
  43774. */
  43775. protected _albedoColor: Color3;
  43776. /**
  43777. * AKA Specular Color in other nomenclature.
  43778. */
  43779. protected _reflectivityColor: Color3;
  43780. /**
  43781. * The color applied when light is reflected from a material.
  43782. */
  43783. protected _reflectionColor: Color3;
  43784. /**
  43785. * The color applied when light is emitted from a material.
  43786. */
  43787. protected _emissiveColor: Color3;
  43788. /**
  43789. * AKA Glossiness in other nomenclature.
  43790. */
  43791. protected _microSurface: number;
  43792. /**
  43793. * source material index of refraction (IOR)' / 'destination material IOR.
  43794. */
  43795. protected _indexOfRefraction: number;
  43796. /**
  43797. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  43798. */
  43799. protected _invertRefractionY: boolean;
  43800. /**
  43801. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43802. * Materials half opaque for instance using refraction could benefit from this control.
  43803. */
  43804. protected _linkRefractionWithTransparency: boolean;
  43805. /**
  43806. * Specifies that the material will use the light map as a show map.
  43807. */
  43808. protected _useLightmapAsShadowmap: boolean;
  43809. /**
  43810. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43811. * makes the reflect vector face the model (under horizon).
  43812. */
  43813. protected _useHorizonOcclusion: boolean;
  43814. /**
  43815. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43816. * too much the area relying on ambient texture to define their ambient occlusion.
  43817. */
  43818. protected _useRadianceOcclusion: boolean;
  43819. /**
  43820. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43821. */
  43822. protected _useAlphaFromAlbedoTexture: boolean;
  43823. /**
  43824. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  43825. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43826. */
  43827. protected _useSpecularOverAlpha: boolean;
  43828. /**
  43829. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43830. */
  43831. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43832. /**
  43833. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43834. */
  43835. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  43836. /**
  43837. * Specifies if the metallic texture contains the roughness information in its green channel.
  43838. */
  43839. protected _useRoughnessFromMetallicTextureGreen: boolean;
  43840. /**
  43841. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43842. */
  43843. protected _useMetallnessFromMetallicTextureBlue: boolean;
  43844. /**
  43845. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43846. */
  43847. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  43848. /**
  43849. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43850. */
  43851. protected _useAmbientInGrayScale: boolean;
  43852. /**
  43853. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43854. * The material will try to infer what glossiness each pixel should be.
  43855. */
  43856. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  43857. /**
  43858. * Defines the falloff type used in this material.
  43859. * It by default is Physical.
  43860. */
  43861. protected _lightFalloff: number;
  43862. /**
  43863. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43864. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43865. */
  43866. protected _useRadianceOverAlpha: boolean;
  43867. /**
  43868. * Allows using an object space normal map (instead of tangent space).
  43869. */
  43870. protected _useObjectSpaceNormalMap: boolean;
  43871. /**
  43872. * Allows using the bump map in parallax mode.
  43873. */
  43874. protected _useParallax: boolean;
  43875. /**
  43876. * Allows using the bump map in parallax occlusion mode.
  43877. */
  43878. protected _useParallaxOcclusion: boolean;
  43879. /**
  43880. * Controls the scale bias of the parallax mode.
  43881. */
  43882. protected _parallaxScaleBias: number;
  43883. /**
  43884. * If sets to true, disables all the lights affecting the material.
  43885. */
  43886. protected _disableLighting: boolean;
  43887. /**
  43888. * Number of Simultaneous lights allowed on the material.
  43889. */
  43890. protected _maxSimultaneousLights: number;
  43891. /**
  43892. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43893. */
  43894. protected _invertNormalMapX: boolean;
  43895. /**
  43896. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43897. */
  43898. protected _invertNormalMapY: boolean;
  43899. /**
  43900. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43901. */
  43902. protected _twoSidedLighting: boolean;
  43903. /**
  43904. * Defines the alpha limits in alpha test mode.
  43905. */
  43906. protected _alphaCutOff: number;
  43907. /**
  43908. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43909. */
  43910. protected _forceAlphaTest: boolean;
  43911. /**
  43912. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43913. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43914. */
  43915. protected _useAlphaFresnel: boolean;
  43916. /**
  43917. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43918. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43919. */
  43920. protected _useLinearAlphaFresnel: boolean;
  43921. /**
  43922. * The transparency mode of the material.
  43923. */
  43924. protected _transparencyMode: Nullable<number>;
  43925. /**
  43926. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  43927. * from cos thetav and roughness:
  43928. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  43929. */
  43930. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  43931. /**
  43932. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43933. */
  43934. protected _forceIrradianceInFragment: boolean;
  43935. /**
  43936. * Force normal to face away from face.
  43937. */
  43938. protected _forceNormalForward: boolean;
  43939. /**
  43940. * Enables specular anti aliasing in the PBR shader.
  43941. * It will both interacts on the Geometry for analytical and IBL lighting.
  43942. * It also prefilter the roughness map based on the bump values.
  43943. */
  43944. protected _enableSpecularAntiAliasing: boolean;
  43945. /**
  43946. * Default configuration related to image processing available in the PBR Material.
  43947. */
  43948. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43949. /**
  43950. * Keep track of the image processing observer to allow dispose and replace.
  43951. */
  43952. private _imageProcessingObserver;
  43953. /**
  43954. * Attaches a new image processing configuration to the PBR Material.
  43955. * @param configuration
  43956. */
  43957. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43958. /**
  43959. * Stores the available render targets.
  43960. */
  43961. private _renderTargets;
  43962. /**
  43963. * Sets the global ambient color for the material used in lighting calculations.
  43964. */
  43965. private _globalAmbientColor;
  43966. /**
  43967. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  43968. */
  43969. private _useLogarithmicDepth;
  43970. /**
  43971. * If set to true, no lighting calculations will be applied.
  43972. */
  43973. private _unlit;
  43974. /**
  43975. * Instantiates a new PBRMaterial instance.
  43976. *
  43977. * @param name The material name
  43978. * @param scene The scene the material will be use in.
  43979. */
  43980. constructor(name: string, scene: Scene);
  43981. /**
  43982. * Gets a boolean indicating that current material needs to register RTT
  43983. */
  43984. readonly hasRenderTargetTextures: boolean;
  43985. /**
  43986. * Gets the name of the material class.
  43987. */
  43988. getClassName(): string;
  43989. /**
  43990. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  43991. */
  43992. /**
  43993. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  43994. */
  43995. useLogarithmicDepth: boolean;
  43996. /**
  43997. * Gets the current transparency mode.
  43998. */
  43999. /**
  44000. * Sets the transparency mode of the material.
  44001. *
  44002. * | Value | Type | Description |
  44003. * | ----- | ----------------------------------- | ----------- |
  44004. * | 0 | OPAQUE | |
  44005. * | 1 | ALPHATEST | |
  44006. * | 2 | ALPHABLEND | |
  44007. * | 3 | ALPHATESTANDBLEND | |
  44008. *
  44009. */
  44010. transparencyMode: Nullable<number>;
  44011. /**
  44012. * Returns true if alpha blending should be disabled.
  44013. */
  44014. private readonly _disableAlphaBlending;
  44015. /**
  44016. * Specifies whether or not this material should be rendered in alpha blend mode.
  44017. */
  44018. needAlphaBlending(): boolean;
  44019. /**
  44020. * Specifies if the mesh will require alpha blending.
  44021. * @param mesh - BJS mesh.
  44022. */
  44023. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44024. /**
  44025. * Specifies whether or not this material should be rendered in alpha test mode.
  44026. */
  44027. needAlphaTesting(): boolean;
  44028. /**
  44029. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44030. */
  44031. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44032. /**
  44033. * Gets the texture used for the alpha test.
  44034. */
  44035. getAlphaTestTexture(): BaseTexture;
  44036. /**
  44037. * Stores the reflectivity values based on metallic roughness workflow.
  44038. */
  44039. private static _scaledReflectivity;
  44040. /**
  44041. * Specifies that the submesh is ready to be used.
  44042. * @param mesh - BJS mesh.
  44043. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44044. * @param useInstances - Specifies that instances should be used.
  44045. * @returns - boolean indicating that the submesh is ready or not.
  44046. */
  44047. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44048. /**
  44049. * Specifies if the material uses metallic roughness workflow.
  44050. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44051. */
  44052. isMetallicWorkflow(): boolean;
  44053. private _prepareEffect;
  44054. private _prepareDefines;
  44055. /**
  44056. * Force shader compilation
  44057. */
  44058. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44059. clipPlane: boolean;
  44060. }>): void;
  44061. /**
  44062. * Initializes the uniform buffer layout for the shader.
  44063. */
  44064. buildUniformLayout(): void;
  44065. /**
  44066. * Unbinds the textures.
  44067. */
  44068. unbind(): void;
  44069. /**
  44070. * Binds the submesh data.
  44071. * @param world - The world matrix.
  44072. * @param mesh - The BJS mesh.
  44073. * @param subMesh - A submesh of the BJS mesh.
  44074. */
  44075. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44076. /**
  44077. * Returns the animatable textures.
  44078. * @returns - Array of animatable textures.
  44079. */
  44080. getAnimatables(): IAnimatable[];
  44081. /**
  44082. * Returns the texture used for reflections.
  44083. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44084. */
  44085. private _getReflectionTexture;
  44086. /**
  44087. * Returns the texture used for refraction or null if none is used.
  44088. * @returns - Refection texture if present. If no refraction texture and refraction
  44089. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44090. */
  44091. private _getRefractionTexture;
  44092. /**
  44093. * Disposes the resources of the material.
  44094. * @param forceDisposeEffect - Forces the disposal of effects.
  44095. * @param forceDisposeTextures - Forces the disposal of all textures.
  44096. */
  44097. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44098. }
  44099. }
  44100. declare module BABYLON {
  44101. /**
  44102. * The Physically based simple base material of BJS.
  44103. *
  44104. * This enables better naming and convention enforcements on top of the pbrMaterial.
  44105. * It is used as the base class for both the specGloss and metalRough conventions.
  44106. */
  44107. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  44108. /**
  44109. * Number of Simultaneous lights allowed on the material.
  44110. */
  44111. maxSimultaneousLights: number;
  44112. /**
  44113. * If sets to true, disables all the lights affecting the material.
  44114. */
  44115. disableLighting: boolean;
  44116. /**
  44117. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  44118. */
  44119. environmentTexture: BaseTexture;
  44120. /**
  44121. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44122. */
  44123. invertNormalMapX: boolean;
  44124. /**
  44125. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44126. */
  44127. invertNormalMapY: boolean;
  44128. /**
  44129. * Normal map used in the model.
  44130. */
  44131. normalTexture: BaseTexture;
  44132. /**
  44133. * Emissivie color used to self-illuminate the model.
  44134. */
  44135. emissiveColor: Color3;
  44136. /**
  44137. * Emissivie texture used to self-illuminate the model.
  44138. */
  44139. emissiveTexture: BaseTexture;
  44140. /**
  44141. * Occlusion Channel Strenght.
  44142. */
  44143. occlusionStrength: number;
  44144. /**
  44145. * Occlusion Texture of the material (adding extra occlusion effects).
  44146. */
  44147. occlusionTexture: BaseTexture;
  44148. /**
  44149. * Defines the alpha limits in alpha test mode.
  44150. */
  44151. alphaCutOff: number;
  44152. /**
  44153. * Gets the current double sided mode.
  44154. */
  44155. /**
  44156. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44157. */
  44158. doubleSided: boolean;
  44159. /**
  44160. * Stores the pre-calculated light information of a mesh in a texture.
  44161. */
  44162. lightmapTexture: BaseTexture;
  44163. /**
  44164. * If true, the light map contains occlusion information instead of lighting info.
  44165. */
  44166. useLightmapAsShadowmap: boolean;
  44167. /**
  44168. * Return the active textures of the material.
  44169. */
  44170. getActiveTextures(): BaseTexture[];
  44171. hasTexture(texture: BaseTexture): boolean;
  44172. /**
  44173. * Instantiates a new PBRMaterial instance.
  44174. *
  44175. * @param name The material name
  44176. * @param scene The scene the material will be use in.
  44177. */
  44178. constructor(name: string, scene: Scene);
  44179. getClassName(): string;
  44180. }
  44181. }
  44182. declare module BABYLON {
  44183. /**
  44184. * The Physically based material of BJS.
  44185. *
  44186. * This offers the main features of a standard PBR material.
  44187. * For more information, please refer to the documentation :
  44188. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44189. */
  44190. class PBRMaterial extends PBRBaseMaterial {
  44191. /**
  44192. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44193. */
  44194. static readonly PBRMATERIAL_OPAQUE: number;
  44195. /**
  44196. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44197. */
  44198. static readonly PBRMATERIAL_ALPHATEST: number;
  44199. /**
  44200. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44201. */
  44202. static readonly PBRMATERIAL_ALPHABLEND: number;
  44203. /**
  44204. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44205. * They are also discarded below the alpha cutoff threshold to improve performances.
  44206. */
  44207. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44208. /**
  44209. * Defines the default value of how much AO map is occluding the analytical lights
  44210. * (point spot...).
  44211. */
  44212. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44213. /**
  44214. * Intensity of the direct lights e.g. the four lights available in your scene.
  44215. * This impacts both the direct diffuse and specular highlights.
  44216. */
  44217. directIntensity: number;
  44218. /**
  44219. * Intensity of the emissive part of the material.
  44220. * This helps controlling the emissive effect without modifying the emissive color.
  44221. */
  44222. emissiveIntensity: number;
  44223. /**
  44224. * Intensity of the environment e.g. how much the environment will light the object
  44225. * either through harmonics for rough material or through the refelction for shiny ones.
  44226. */
  44227. environmentIntensity: number;
  44228. /**
  44229. * This is a special control allowing the reduction of the specular highlights coming from the
  44230. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44231. */
  44232. specularIntensity: number;
  44233. /**
  44234. * Debug Control allowing disabling the bump map on this material.
  44235. */
  44236. disableBumpMap: boolean;
  44237. /**
  44238. * AKA Diffuse Texture in standard nomenclature.
  44239. */
  44240. albedoTexture: BaseTexture;
  44241. /**
  44242. * AKA Occlusion Texture in other nomenclature.
  44243. */
  44244. ambientTexture: BaseTexture;
  44245. /**
  44246. * AKA Occlusion Texture Intensity in other nomenclature.
  44247. */
  44248. ambientTextureStrength: number;
  44249. /**
  44250. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44251. * 1 means it completely occludes it
  44252. * 0 mean it has no impact
  44253. */
  44254. ambientTextureImpactOnAnalyticalLights: number;
  44255. /**
  44256. * Stores the alpha values in a texture.
  44257. */
  44258. opacityTexture: BaseTexture;
  44259. /**
  44260. * Stores the reflection values in a texture.
  44261. */
  44262. reflectionTexture: Nullable<BaseTexture>;
  44263. /**
  44264. * Stores the emissive values in a texture.
  44265. */
  44266. emissiveTexture: BaseTexture;
  44267. /**
  44268. * AKA Specular texture in other nomenclature.
  44269. */
  44270. reflectivityTexture: BaseTexture;
  44271. /**
  44272. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44273. */
  44274. metallicTexture: BaseTexture;
  44275. /**
  44276. * Specifies the metallic scalar of the metallic/roughness workflow.
  44277. * Can also be used to scale the metalness values of the metallic texture.
  44278. */
  44279. metallic: Nullable<number>;
  44280. /**
  44281. * Specifies the roughness scalar of the metallic/roughness workflow.
  44282. * Can also be used to scale the roughness values of the metallic texture.
  44283. */
  44284. roughness: Nullable<number>;
  44285. /**
  44286. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44287. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44288. */
  44289. microSurfaceTexture: BaseTexture;
  44290. /**
  44291. * Stores surface normal data used to displace a mesh in a texture.
  44292. */
  44293. bumpTexture: BaseTexture;
  44294. /**
  44295. * Stores the pre-calculated light information of a mesh in a texture.
  44296. */
  44297. lightmapTexture: BaseTexture;
  44298. /**
  44299. * Stores the refracted light information in a texture.
  44300. */
  44301. refractionTexture: BaseTexture;
  44302. /**
  44303. * The color of a material in ambient lighting.
  44304. */
  44305. ambientColor: Color3;
  44306. /**
  44307. * AKA Diffuse Color in other nomenclature.
  44308. */
  44309. albedoColor: Color3;
  44310. /**
  44311. * AKA Specular Color in other nomenclature.
  44312. */
  44313. reflectivityColor: Color3;
  44314. /**
  44315. * The color reflected from the material.
  44316. */
  44317. reflectionColor: Color3;
  44318. /**
  44319. * The color emitted from the material.
  44320. */
  44321. emissiveColor: Color3;
  44322. /**
  44323. * AKA Glossiness in other nomenclature.
  44324. */
  44325. microSurface: number;
  44326. /**
  44327. * source material index of refraction (IOR)' / 'destination material IOR.
  44328. */
  44329. indexOfRefraction: number;
  44330. /**
  44331. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  44332. */
  44333. invertRefractionY: boolean;
  44334. /**
  44335. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44336. * Materials half opaque for instance using refraction could benefit from this control.
  44337. */
  44338. linkRefractionWithTransparency: boolean;
  44339. /**
  44340. * If true, the light map contains occlusion information instead of lighting info.
  44341. */
  44342. useLightmapAsShadowmap: boolean;
  44343. /**
  44344. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44345. */
  44346. useAlphaFromAlbedoTexture: boolean;
  44347. /**
  44348. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44349. */
  44350. forceAlphaTest: boolean;
  44351. /**
  44352. * Defines the alpha limits in alpha test mode.
  44353. */
  44354. alphaCutOff: number;
  44355. /**
  44356. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44357. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44358. */
  44359. useSpecularOverAlpha: boolean;
  44360. /**
  44361. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44362. */
  44363. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44364. /**
  44365. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44366. */
  44367. useRoughnessFromMetallicTextureAlpha: boolean;
  44368. /**
  44369. * Specifies if the metallic texture contains the roughness information in its green channel.
  44370. */
  44371. useRoughnessFromMetallicTextureGreen: boolean;
  44372. /**
  44373. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44374. */
  44375. useMetallnessFromMetallicTextureBlue: boolean;
  44376. /**
  44377. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44378. */
  44379. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44380. /**
  44381. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44382. */
  44383. useAmbientInGrayScale: boolean;
  44384. /**
  44385. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44386. * The material will try to infer what glossiness each pixel should be.
  44387. */
  44388. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44389. /**
  44390. * BJS is using an harcoded light falloff based on a manually sets up range.
  44391. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44392. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44393. */
  44394. /**
  44395. * BJS is using an harcoded light falloff based on a manually sets up range.
  44396. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44397. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44398. */
  44399. usePhysicalLightFalloff: boolean;
  44400. /**
  44401. * In order to support the falloff compatibility with gltf, a special mode has been added
  44402. * to reproduce the gltf light falloff.
  44403. */
  44404. /**
  44405. * In order to support the falloff compatibility with gltf, a special mode has been added
  44406. * to reproduce the gltf light falloff.
  44407. */
  44408. useGLTFLightFalloff: boolean;
  44409. /**
  44410. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44411. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44412. */
  44413. useRadianceOverAlpha: boolean;
  44414. /**
  44415. * Allows using an object space normal map (instead of tangent space).
  44416. */
  44417. useObjectSpaceNormalMap: boolean;
  44418. /**
  44419. * Allows using the bump map in parallax mode.
  44420. */
  44421. useParallax: boolean;
  44422. /**
  44423. * Allows using the bump map in parallax occlusion mode.
  44424. */
  44425. useParallaxOcclusion: boolean;
  44426. /**
  44427. * Controls the scale bias of the parallax mode.
  44428. */
  44429. parallaxScaleBias: number;
  44430. /**
  44431. * If sets to true, disables all the lights affecting the material.
  44432. */
  44433. disableLighting: boolean;
  44434. /**
  44435. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44436. */
  44437. forceIrradianceInFragment: boolean;
  44438. /**
  44439. * Number of Simultaneous lights allowed on the material.
  44440. */
  44441. maxSimultaneousLights: number;
  44442. /**
  44443. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44444. */
  44445. invertNormalMapX: boolean;
  44446. /**
  44447. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44448. */
  44449. invertNormalMapY: boolean;
  44450. /**
  44451. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44452. */
  44453. twoSidedLighting: boolean;
  44454. /**
  44455. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44456. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44457. */
  44458. useAlphaFresnel: boolean;
  44459. /**
  44460. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44461. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44462. */
  44463. useLinearAlphaFresnel: boolean;
  44464. /**
  44465. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44466. * And/Or occlude the blended part.
  44467. */
  44468. environmentBRDFTexture: Nullable<BaseTexture>;
  44469. /**
  44470. * Force normal to face away from face.
  44471. */
  44472. forceNormalForward: boolean;
  44473. /**
  44474. * Enables specular anti aliasing in the PBR shader.
  44475. * It will both interacts on the Geometry for analytical and IBL lighting.
  44476. * It also prefilter the roughness map based on the bump values.
  44477. */
  44478. enableSpecularAntiAliasing: boolean;
  44479. /**
  44480. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44481. * makes the reflect vector face the model (under horizon).
  44482. */
  44483. useHorizonOcclusion: boolean;
  44484. /**
  44485. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44486. * too much the area relying on ambient texture to define their ambient occlusion.
  44487. */
  44488. useRadianceOcclusion: boolean;
  44489. /**
  44490. * If set to true, no lighting calculations will be applied.
  44491. */
  44492. unlit: boolean;
  44493. /**
  44494. * Gets the image processing configuration used either in this material.
  44495. */
  44496. /**
  44497. * Sets the Default image processing configuration used either in the this material.
  44498. *
  44499. * If sets to null, the scene one is in use.
  44500. */
  44501. imageProcessingConfiguration: ImageProcessingConfiguration;
  44502. /**
  44503. * Gets wether the color curves effect is enabled.
  44504. */
  44505. /**
  44506. * Sets wether the color curves effect is enabled.
  44507. */
  44508. cameraColorCurvesEnabled: boolean;
  44509. /**
  44510. * Gets wether the color grading effect is enabled.
  44511. */
  44512. /**
  44513. * Gets wether the color grading effect is enabled.
  44514. */
  44515. cameraColorGradingEnabled: boolean;
  44516. /**
  44517. * Gets wether tonemapping is enabled or not.
  44518. */
  44519. /**
  44520. * Sets wether tonemapping is enabled or not
  44521. */
  44522. cameraToneMappingEnabled: boolean;
  44523. /**
  44524. * The camera exposure used on this material.
  44525. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44526. * This corresponds to a photographic exposure.
  44527. */
  44528. /**
  44529. * The camera exposure used on this material.
  44530. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44531. * This corresponds to a photographic exposure.
  44532. */
  44533. cameraExposure: number;
  44534. /**
  44535. * Gets The camera contrast used on this material.
  44536. */
  44537. /**
  44538. * Sets The camera contrast used on this material.
  44539. */
  44540. cameraContrast: number;
  44541. /**
  44542. * Gets the Color Grading 2D Lookup Texture.
  44543. */
  44544. /**
  44545. * Sets the Color Grading 2D Lookup Texture.
  44546. */
  44547. cameraColorGradingTexture: Nullable<BaseTexture>;
  44548. /**
  44549. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44550. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44551. * 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;
  44552. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44553. */
  44554. /**
  44555. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44556. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44557. * 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;
  44558. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44559. */
  44560. cameraColorCurves: Nullable<ColorCurves>;
  44561. /**
  44562. * Instantiates a new PBRMaterial instance.
  44563. *
  44564. * @param name The material name
  44565. * @param scene The scene the material will be use in.
  44566. */
  44567. constructor(name: string, scene: Scene);
  44568. /**
  44569. * Returns the name of this material class.
  44570. */
  44571. getClassName(): string;
  44572. /**
  44573. * Returns an array of the actively used textures.
  44574. * @returns - Array of BaseTextures
  44575. */
  44576. getActiveTextures(): BaseTexture[];
  44577. /**
  44578. * Checks to see if a texture is used in the material.
  44579. * @param texture - Base texture to use.
  44580. * @returns - Boolean specifying if a texture is used in the material.
  44581. */
  44582. hasTexture(texture: BaseTexture): boolean;
  44583. /**
  44584. * Makes a duplicate of the current material.
  44585. * @param name - name to use for the new material.
  44586. */
  44587. clone(name: string): PBRMaterial;
  44588. /**
  44589. * Serializes this PBR Material.
  44590. * @returns - An object with the serialized material.
  44591. */
  44592. serialize(): any;
  44593. /**
  44594. * Parses a PBR Material from a serialized object.
  44595. * @param source - Serialized object.
  44596. * @param scene - BJS scene instance.
  44597. * @param rootUrl - url for the scene object
  44598. * @returns - PBRMaterial
  44599. */
  44600. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44601. }
  44602. }
  44603. declare module BABYLON {
  44604. /**
  44605. * The PBR material of BJS following the metal roughness convention.
  44606. *
  44607. * This fits to the PBR convention in the GLTF definition:
  44608. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  44609. */
  44610. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  44611. /**
  44612. * The base color has two different interpretations depending on the value of metalness.
  44613. * When the material is a metal, the base color is the specific measured reflectance value
  44614. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  44615. * of the material.
  44616. */
  44617. baseColor: Color3;
  44618. /**
  44619. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  44620. * well as opacity information in the alpha channel.
  44621. */
  44622. baseTexture: BaseTexture;
  44623. /**
  44624. * Specifies the metallic scalar value of the material.
  44625. * Can also be used to scale the metalness values of the metallic texture.
  44626. */
  44627. metallic: number;
  44628. /**
  44629. * Specifies the roughness scalar value of the material.
  44630. * Can also be used to scale the roughness values of the metallic texture.
  44631. */
  44632. roughness: number;
  44633. /**
  44634. * Texture containing both the metallic value in the B channel and the
  44635. * roughness value in the G channel to keep better precision.
  44636. */
  44637. metallicRoughnessTexture: BaseTexture;
  44638. /**
  44639. * Instantiates a new PBRMetalRoughnessMaterial instance.
  44640. *
  44641. * @param name The material name
  44642. * @param scene The scene the material will be use in.
  44643. */
  44644. constructor(name: string, scene: Scene);
  44645. /**
  44646. * Return the currrent class name of the material.
  44647. */
  44648. getClassName(): string;
  44649. /**
  44650. * Return the active textures of the material.
  44651. */
  44652. getActiveTextures(): BaseTexture[];
  44653. /**
  44654. * Checks to see if a texture is used in the material.
  44655. * @param texture - Base texture to use.
  44656. * @returns - Boolean specifying if a texture is used in the material.
  44657. */
  44658. hasTexture(texture: BaseTexture): boolean;
  44659. /**
  44660. * Makes a duplicate of the current material.
  44661. * @param name - name to use for the new material.
  44662. */
  44663. clone(name: string): PBRMetallicRoughnessMaterial;
  44664. /**
  44665. * Serialize the material to a parsable JSON object.
  44666. */
  44667. serialize(): any;
  44668. /**
  44669. * Parses a JSON object correponding to the serialize function.
  44670. */
  44671. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  44672. }
  44673. }
  44674. declare module BABYLON {
  44675. /**
  44676. * The PBR material of BJS following the specular glossiness convention.
  44677. *
  44678. * This fits to the PBR convention in the GLTF definition:
  44679. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  44680. */
  44681. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  44682. /**
  44683. * Specifies the diffuse color of the material.
  44684. */
  44685. diffuseColor: Color3;
  44686. /**
  44687. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  44688. * channel.
  44689. */
  44690. diffuseTexture: BaseTexture;
  44691. /**
  44692. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  44693. */
  44694. specularColor: Color3;
  44695. /**
  44696. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  44697. */
  44698. glossiness: number;
  44699. /**
  44700. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  44701. */
  44702. specularGlossinessTexture: BaseTexture;
  44703. /**
  44704. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  44705. *
  44706. * @param name The material name
  44707. * @param scene The scene the material will be use in.
  44708. */
  44709. constructor(name: string, scene: Scene);
  44710. /**
  44711. * Return the currrent class name of the material.
  44712. */
  44713. getClassName(): string;
  44714. /**
  44715. * Return the active textures of the material.
  44716. */
  44717. getActiveTextures(): BaseTexture[];
  44718. /**
  44719. * Checks to see if a texture is used in the material.
  44720. * @param texture - Base texture to use.
  44721. * @returns - Boolean specifying if a texture is used in the material.
  44722. */
  44723. hasTexture(texture: BaseTexture): boolean;
  44724. /**
  44725. * Makes a duplicate of the current material.
  44726. * @param name - name to use for the new material.
  44727. */
  44728. clone(name: string): PBRSpecularGlossinessMaterial;
  44729. /**
  44730. * Serialize the material to a parsable JSON object.
  44731. */
  44732. serialize(): any;
  44733. /**
  44734. * Parses a JSON object correponding to the serialize function.
  44735. */
  44736. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  44737. }
  44738. }
  44739. declare module BABYLON {
  44740. /**
  44741. * Base class of all the textures in babylon.
  44742. * It groups all the common properties the materials, post process, lights... might need
  44743. * in order to make a correct use of the texture.
  44744. */
  44745. class BaseTexture {
  44746. /**
  44747. * Default anisotropic filtering level for the application.
  44748. * It is set to 4 as a good tradeoff between perf and quality.
  44749. */
  44750. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  44751. /**
  44752. * Define the name of the texture.
  44753. */
  44754. name: string;
  44755. private _hasAlpha;
  44756. /**
  44757. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  44758. */
  44759. hasAlpha: boolean;
  44760. /**
  44761. * Defines if the alpha value should be determined via the rgb values.
  44762. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  44763. */
  44764. getAlphaFromRGB: boolean;
  44765. /**
  44766. * Intensity or strength of the texture.
  44767. * It is commonly used by materials to fine tune the intensity of the texture
  44768. */
  44769. level: number;
  44770. /**
  44771. * Define the UV chanel to use starting from 0 and defaulting to 0.
  44772. * This is part of the texture as textures usually maps to one uv set.
  44773. */
  44774. coordinatesIndex: number;
  44775. private _coordinatesMode;
  44776. /**
  44777. * How a texture is mapped.
  44778. *
  44779. * | Value | Type | Description |
  44780. * | ----- | ----------------------------------- | ----------- |
  44781. * | 0 | EXPLICIT_MODE | |
  44782. * | 1 | SPHERICAL_MODE | |
  44783. * | 2 | PLANAR_MODE | |
  44784. * | 3 | CUBIC_MODE | |
  44785. * | 4 | PROJECTION_MODE | |
  44786. * | 5 | SKYBOX_MODE | |
  44787. * | 6 | INVCUBIC_MODE | |
  44788. * | 7 | EQUIRECTANGULAR_MODE | |
  44789. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  44790. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  44791. */
  44792. coordinatesMode: number;
  44793. /**
  44794. * | Value | Type | Description |
  44795. * | ----- | ------------------ | ----------- |
  44796. * | 0 | CLAMP_ADDRESSMODE | |
  44797. * | 1 | WRAP_ADDRESSMODE | |
  44798. * | 2 | MIRROR_ADDRESSMODE | |
  44799. */
  44800. wrapU: number;
  44801. /**
  44802. * | Value | Type | Description |
  44803. * | ----- | ------------------ | ----------- |
  44804. * | 0 | CLAMP_ADDRESSMODE | |
  44805. * | 1 | WRAP_ADDRESSMODE | |
  44806. * | 2 | MIRROR_ADDRESSMODE | |
  44807. */
  44808. wrapV: number;
  44809. /**
  44810. * | Value | Type | Description |
  44811. * | ----- | ------------------ | ----------- |
  44812. * | 0 | CLAMP_ADDRESSMODE | |
  44813. * | 1 | WRAP_ADDRESSMODE | |
  44814. * | 2 | MIRROR_ADDRESSMODE | |
  44815. */
  44816. wrapR: number;
  44817. /**
  44818. * With compliant hardware and browser (supporting anisotropic filtering)
  44819. * this defines the level of anisotropic filtering in the texture.
  44820. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  44821. */
  44822. anisotropicFilteringLevel: number;
  44823. /**
  44824. * Define if the texture is a cube texture or if false a 2d texture.
  44825. */
  44826. isCube: boolean;
  44827. /**
  44828. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  44829. */
  44830. is3D: boolean;
  44831. /**
  44832. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  44833. * HDR texture are usually stored in linear space.
  44834. * This only impacts the PBR and Background materials
  44835. */
  44836. gammaSpace: boolean;
  44837. /**
  44838. * Gets whether or not the texture contains RGBD data.
  44839. */
  44840. readonly isRGBD: boolean;
  44841. /**
  44842. * Is Z inverted in the texture (useful in a cube texture).
  44843. */
  44844. invertZ: boolean;
  44845. /**
  44846. * @hidden
  44847. */
  44848. lodLevelInAlpha: boolean;
  44849. /**
  44850. * With prefiltered texture, defined the offset used during the prefiltering steps.
  44851. */
  44852. lodGenerationOffset: number;
  44853. /**
  44854. * With prefiltered texture, defined the scale used during the prefiltering steps.
  44855. */
  44856. lodGenerationScale: number;
  44857. /**
  44858. * Define if the texture is a render target.
  44859. */
  44860. isRenderTarget: boolean;
  44861. /**
  44862. * Define the unique id of the texture in the scene.
  44863. */
  44864. readonly uid: string;
  44865. /**
  44866. * Return a string representation of the texture.
  44867. * @returns the texture as a string
  44868. */
  44869. toString(): string;
  44870. /**
  44871. * Get the class name of the texture.
  44872. * @returns "BaseTexture"
  44873. */
  44874. getClassName(): string;
  44875. /**
  44876. * Define the list of animation attached to the texture.
  44877. */
  44878. animations: Animation[];
  44879. /**
  44880. * An event triggered when the texture is disposed.
  44881. */
  44882. onDisposeObservable: Observable<BaseTexture>;
  44883. private _onDisposeObserver;
  44884. /**
  44885. * Callback triggered when the texture has been disposed.
  44886. * Kept for back compatibility, you can use the onDisposeObservable instead.
  44887. */
  44888. onDispose: () => void;
  44889. /**
  44890. * Define the current state of the loading sequence when in delayed load mode.
  44891. */
  44892. delayLoadState: number;
  44893. private _scene;
  44894. /** @hidden */
  44895. _texture: Nullable<InternalTexture>;
  44896. private _uid;
  44897. /**
  44898. * Define if the texture is preventinga material to render or not.
  44899. * If not and the texture is not ready, the engine will use a default black texture instead.
  44900. */
  44901. readonly isBlocking: boolean;
  44902. /**
  44903. * Instantiates a new BaseTexture.
  44904. * Base class of all the textures in babylon.
  44905. * It groups all the common properties the materials, post process, lights... might need
  44906. * in order to make a correct use of the texture.
  44907. * @param scene Define the scene the texture blongs to
  44908. */
  44909. constructor(scene: Nullable<Scene>);
  44910. /**
  44911. * Get the scene the texture belongs to.
  44912. * @returns the scene or null if undefined
  44913. */
  44914. getScene(): Nullable<Scene>;
  44915. /**
  44916. * Get the texture transform matrix used to offset tile the texture for istance.
  44917. * @returns the transformation matrix
  44918. */
  44919. getTextureMatrix(): Matrix;
  44920. /**
  44921. * Get the texture reflection matrix used to rotate/transform the reflection.
  44922. * @returns the reflection matrix
  44923. */
  44924. getReflectionTextureMatrix(): Matrix;
  44925. /**
  44926. * Get the underlying lower level texture from Babylon.
  44927. * @returns the insternal texture
  44928. */
  44929. getInternalTexture(): Nullable<InternalTexture>;
  44930. /**
  44931. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  44932. * @returns true if ready or not blocking
  44933. */
  44934. isReadyOrNotBlocking(): boolean;
  44935. /**
  44936. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  44937. * @returns true if fully ready
  44938. */
  44939. isReady(): boolean;
  44940. private _cachedSize;
  44941. /**
  44942. * Get the size of the texture.
  44943. * @returns the texture size.
  44944. */
  44945. getSize(): ISize;
  44946. /**
  44947. * Get the base size of the texture.
  44948. * It can be different from the size if the texture has been resized for POT for instance
  44949. * @returns the base size
  44950. */
  44951. getBaseSize(): ISize;
  44952. /**
  44953. * Scales the texture if is `canRescale()`
  44954. * @param ratio the resize factor we want to use to rescale
  44955. */
  44956. scale(ratio: number): void;
  44957. /**
  44958. * Get if the texture can rescale.
  44959. */
  44960. readonly canRescale: boolean;
  44961. /** @hidden */
  44962. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  44963. /** @hidden */
  44964. _rebuild(): void;
  44965. /**
  44966. * Triggers the load sequence in delayed load mode.
  44967. */
  44968. delayLoad(): void;
  44969. /**
  44970. * Clones the texture.
  44971. * @returns the cloned texture
  44972. */
  44973. clone(): Nullable<BaseTexture>;
  44974. /**
  44975. * Get the texture underlying type (INT, FLOAT...)
  44976. */
  44977. readonly textureType: number;
  44978. /**
  44979. * Get the texture underlying format (RGB, RGBA...)
  44980. */
  44981. readonly textureFormat: number;
  44982. /**
  44983. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  44984. * This will returns an RGBA array buffer containing either in values (0-255) or
  44985. * float values (0-1) depending of the underlying buffer type.
  44986. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  44987. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  44988. * @param buffer defines a user defined buffer to fill with data (can be null)
  44989. * @returns The Array buffer containing the pixels data.
  44990. */
  44991. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  44992. /**
  44993. * Release and destroy the underlying lower level texture aka internalTexture.
  44994. */
  44995. releaseInternalTexture(): void;
  44996. /**
  44997. * Get the polynomial representation of the texture data.
  44998. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44999. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45000. */
  45001. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45002. /** @hidden */
  45003. readonly _lodTextureHigh: Nullable<BaseTexture>;
  45004. /** @hidden */
  45005. readonly _lodTextureMid: Nullable<BaseTexture>;
  45006. /** @hidden */
  45007. readonly _lodTextureLow: Nullable<BaseTexture>;
  45008. /**
  45009. * Dispose the texture and release its associated resources.
  45010. */
  45011. dispose(): void;
  45012. /**
  45013. * Serialize the texture into a JSON representation that can be parsed later on.
  45014. * @returns the JSON representation of the texture
  45015. */
  45016. serialize(): any;
  45017. /**
  45018. * Helper function to be called back once a list of texture contains only ready textures.
  45019. * @param textures Define the list of textures to wait for
  45020. * @param callback Define the callback triggered once the entire list will be ready
  45021. */
  45022. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  45023. }
  45024. }
  45025. declare module BABYLON {
  45026. /**
  45027. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45028. * It can help converting any input color in a desired output one. This can then be used to create effects
  45029. * from sepia, black and white to sixties or futuristic rendering...
  45030. *
  45031. * The only supported format is currently 3dl.
  45032. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45033. */
  45034. class ColorGradingTexture extends BaseTexture {
  45035. /**
  45036. * The current texture matrix. (will always be identity in color grading texture)
  45037. */
  45038. private _textureMatrix;
  45039. /**
  45040. * The texture URL.
  45041. */
  45042. url: string;
  45043. /**
  45044. * Empty line regex stored for GC.
  45045. */
  45046. private static _noneEmptyLineRegex;
  45047. private _engine;
  45048. /**
  45049. * Instantiates a ColorGradingTexture from the following parameters.
  45050. *
  45051. * @param url The location of the color gradind data (currently only supporting 3dl)
  45052. * @param scene The scene the texture will be used in
  45053. */
  45054. constructor(url: string, scene: Scene);
  45055. /**
  45056. * Returns the texture matrix used in most of the material.
  45057. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45058. */
  45059. getTextureMatrix(): Matrix;
  45060. /**
  45061. * Occurs when the file being loaded is a .3dl LUT file.
  45062. */
  45063. private load3dlTexture;
  45064. /**
  45065. * Starts the loading process of the texture.
  45066. */
  45067. private loadTexture;
  45068. /**
  45069. * Clones the color gradind texture.
  45070. */
  45071. clone(): ColorGradingTexture;
  45072. /**
  45073. * Called during delayed load for textures.
  45074. */
  45075. delayLoad(): void;
  45076. /**
  45077. * Parses a color grading texture serialized by Babylon.
  45078. * @param parsedTexture The texture information being parsedTexture
  45079. * @param scene The scene to load the texture in
  45080. * @param rootUrl The root url of the data assets to load
  45081. * @return A color gradind texture
  45082. */
  45083. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  45084. /**
  45085. * Serializes the LUT texture to json format.
  45086. */
  45087. serialize(): any;
  45088. }
  45089. }
  45090. declare module BABYLON {
  45091. /**
  45092. * Class for creating a cube texture
  45093. */
  45094. class CubeTexture extends BaseTexture {
  45095. /**
  45096. * The url of the texture
  45097. */
  45098. url: string;
  45099. /**
  45100. * Gets or sets the center of the bounding box associated with the cube texture.
  45101. * It must define where the camera used to render the texture was set
  45102. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  45103. */
  45104. boundingBoxPosition: Vector3;
  45105. private _boundingBoxSize;
  45106. /**
  45107. * Gets or sets the size of the bounding box associated with the cube texture
  45108. * When defined, the cubemap will switch to local mode
  45109. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45110. * @example https://www.babylonjs-playground.com/#RNASML
  45111. */
  45112. /**
  45113. * Returns the bounding box size
  45114. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  45115. */
  45116. boundingBoxSize: Vector3;
  45117. protected _rotationY: number;
  45118. /**
  45119. * Sets texture matrix rotation angle around Y axis in radians.
  45120. */
  45121. /**
  45122. * Gets texture matrix rotation angle around Y axis radians.
  45123. */
  45124. rotationY: number;
  45125. private _noMipmap;
  45126. private _files;
  45127. private _extensions;
  45128. private _textureMatrix;
  45129. private _format;
  45130. private _createPolynomials;
  45131. /** @hidden */
  45132. readonly _prefiltered: boolean;
  45133. /**
  45134. * Creates a cube texture from an array of image urls
  45135. * @param files defines an array of image urls
  45136. * @param scene defines the hosting scene
  45137. * @param noMipmap specifies if mip maps are not used
  45138. * @returns a cube texture
  45139. */
  45140. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  45141. /**
  45142. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  45143. * @param url defines the url of the prefiltered texture
  45144. * @param scene defines the scene the texture is attached to
  45145. * @param forcedExtension defines the extension of the file if different from the url
  45146. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  45147. * @return the prefiltered texture
  45148. */
  45149. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  45150. /**
  45151. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  45152. * as prefiltered data.
  45153. * @param rootUrl defines the url of the texture or the root name of the six images
  45154. * @param scene defines the scene the texture is attached to
  45155. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  45156. * @param noMipmap defines if mipmaps should be created or not
  45157. * @param files defines the six files to load for the different faces
  45158. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  45159. * @param onError defines a callback triggered in case of error during load
  45160. * @param format defines the internal format to use for the texture once loaded
  45161. * @param prefiltered defines whether or not the texture is created from prefiltered data
  45162. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  45163. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  45164. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45165. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45166. * @return the cube texture
  45167. */
  45168. 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);
  45169. /**
  45170. * Delays loading of the cube texture
  45171. */
  45172. delayLoad(): void;
  45173. /**
  45174. * Returns the reflection texture matrix
  45175. * @returns the reflection texture matrix
  45176. */
  45177. getReflectionTextureMatrix(): Matrix;
  45178. /**
  45179. * Sets the reflection texture matrix
  45180. * @param value Reflection texture matrix
  45181. */
  45182. setReflectionTextureMatrix(value: Matrix): void;
  45183. /**
  45184. * Parses text to create a cube texture
  45185. * @param parsedTexture define the serialized text to read from
  45186. * @param scene defines the hosting scene
  45187. * @param rootUrl defines the root url of the cube texture
  45188. * @returns a cube texture
  45189. */
  45190. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  45191. /**
  45192. * Makes a clone, or deep copy, of the cube texture
  45193. * @returns a new cube texture
  45194. */
  45195. clone(): CubeTexture;
  45196. }
  45197. }
  45198. declare module BABYLON {
  45199. /**
  45200. * A class extending Texture allowing drawing on a texture
  45201. * @see http://doc.babylonjs.com/how_to/dynamictexture
  45202. */
  45203. class DynamicTexture extends Texture {
  45204. private _generateMipMaps;
  45205. private _canvas;
  45206. private _context;
  45207. private _engine;
  45208. /**
  45209. * Creates a DynamicTexture
  45210. * @param name defines the name of the texture
  45211. * @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
  45212. * @param scene defines the scene where you want the texture
  45213. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45214. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45215. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  45216. */
  45217. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45218. /**
  45219. * Gets the current state of canRescale
  45220. */
  45221. readonly canRescale: boolean;
  45222. private _recreate;
  45223. /**
  45224. * Scales the texture
  45225. * @param ratio the scale factor to apply to both width and height
  45226. */
  45227. scale(ratio: number): void;
  45228. /**
  45229. * Resizes the texture
  45230. * @param width the new width
  45231. * @param height the new height
  45232. */
  45233. scaleTo(width: number, height: number): void;
  45234. /**
  45235. * Gets the context of the canvas used by the texture
  45236. * @returns the canvas context of the dynamic texture
  45237. */
  45238. getContext(): CanvasRenderingContext2D;
  45239. /**
  45240. * Clears the texture
  45241. */
  45242. clear(): void;
  45243. /**
  45244. * Updates the texture
  45245. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45246. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45247. */
  45248. update(invertY?: boolean, premulAlpha?: boolean): void;
  45249. /**
  45250. * Draws text onto the texture
  45251. * @param text defines the text to be drawn
  45252. * @param x defines the placement of the text from the left
  45253. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45254. * @param font defines the font to be used with font-style, font-size, font-name
  45255. * @param color defines the color used for the text
  45256. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45257. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45258. * @param update defines whether texture is immediately update (default is true)
  45259. */
  45260. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  45261. /**
  45262. * Clones the texture
  45263. * @returns the clone of the texture.
  45264. */
  45265. clone(): DynamicTexture;
  45266. /**
  45267. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45268. * @returns a serialized dynamic texture object
  45269. */
  45270. serialize(): any;
  45271. /** @hidden */
  45272. _rebuild(): void;
  45273. }
  45274. }
  45275. declare module BABYLON {
  45276. /**
  45277. * This represents a texture coming from an HDR input.
  45278. *
  45279. * The only supported format is currently panorama picture stored in RGBE format.
  45280. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45281. */
  45282. class HDRCubeTexture extends BaseTexture {
  45283. private static _facesMapping;
  45284. private _generateHarmonics;
  45285. private _noMipmap;
  45286. private _textureMatrix;
  45287. private _size;
  45288. private _onLoad;
  45289. private _onError;
  45290. /**
  45291. * The texture URL.
  45292. */
  45293. url: string;
  45294. /**
  45295. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45296. */
  45297. coordinatesMode: number;
  45298. protected _isBlocking: boolean;
  45299. /**
  45300. * Sets wether or not the texture is blocking during loading.
  45301. */
  45302. /**
  45303. * Gets wether or not the texture is blocking during loading.
  45304. */
  45305. isBlocking: boolean;
  45306. protected _rotationY: number;
  45307. /**
  45308. * Sets texture matrix rotation angle around Y axis in radians.
  45309. */
  45310. /**
  45311. * Gets texture matrix rotation angle around Y axis radians.
  45312. */
  45313. rotationY: number;
  45314. /**
  45315. * Gets or sets the center of the bounding box associated with the cube texture
  45316. * It must define where the camera used to render the texture was set
  45317. */
  45318. boundingBoxPosition: Vector3;
  45319. private _boundingBoxSize;
  45320. /**
  45321. * Gets or sets the size of the bounding box associated with the cube texture
  45322. * When defined, the cubemap will switch to local mode
  45323. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45324. * @example https://www.babylonjs-playground.com/#RNASML
  45325. */
  45326. boundingBoxSize: Vector3;
  45327. /**
  45328. * Instantiates an HDRTexture from the following parameters.
  45329. *
  45330. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  45331. * @param scene The scene the texture will be used in
  45332. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  45333. * @param noMipmap Forces to not generate the mipmap if true
  45334. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  45335. * @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)
  45336. * @param reserved Reserved flag for internal use.
  45337. */
  45338. 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>);
  45339. /**
  45340. * Occurs when the file is raw .hdr file.
  45341. */
  45342. private loadTexture;
  45343. clone(): HDRCubeTexture;
  45344. delayLoad(): void;
  45345. /**
  45346. * Get the texture reflection matrix used to rotate/transform the reflection.
  45347. * @returns the reflection matrix
  45348. */
  45349. getReflectionTextureMatrix(): Matrix;
  45350. /**
  45351. * Set the texture reflection matrix used to rotate/transform the reflection.
  45352. * @param value Define the reflection matrix to set
  45353. */
  45354. setReflectionTextureMatrix(value: Matrix): void;
  45355. /**
  45356. * Parses a JSON representation of an HDR Texture in order to create the texture
  45357. * @param parsedTexture Define the JSON representation
  45358. * @param scene Define the scene the texture should be created in
  45359. * @param rootUrl Define the root url in case we need to load relative dependencies
  45360. * @returns the newly created texture after parsing
  45361. */
  45362. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  45363. serialize(): any;
  45364. }
  45365. }
  45366. declare module BABYLON {
  45367. /**
  45368. * Class used to store data associated with WebGL texture data for the engine
  45369. * This class should not be used directly
  45370. */
  45371. class InternalTexture implements IInternalTextureTracker {
  45372. /**
  45373. * The source of the texture data is unknown
  45374. */
  45375. static DATASOURCE_UNKNOWN: number;
  45376. /**
  45377. * Texture data comes from an URL
  45378. */
  45379. static DATASOURCE_URL: number;
  45380. /**
  45381. * Texture data is only used for temporary storage
  45382. */
  45383. static DATASOURCE_TEMP: number;
  45384. /**
  45385. * Texture data comes from raw data (ArrayBuffer)
  45386. */
  45387. static DATASOURCE_RAW: number;
  45388. /**
  45389. * Texture content is dynamic (video or dynamic texture)
  45390. */
  45391. static DATASOURCE_DYNAMIC: number;
  45392. /**
  45393. * Texture content is generated by rendering to it
  45394. */
  45395. static DATASOURCE_RENDERTARGET: number;
  45396. /**
  45397. * Texture content is part of a multi render target process
  45398. */
  45399. static DATASOURCE_MULTIRENDERTARGET: number;
  45400. /**
  45401. * Texture data comes from a cube data file
  45402. */
  45403. static DATASOURCE_CUBE: number;
  45404. /**
  45405. * Texture data comes from a raw cube data
  45406. */
  45407. static DATASOURCE_CUBERAW: number;
  45408. /**
  45409. * Texture data come from a prefiltered cube data file
  45410. */
  45411. static DATASOURCE_CUBEPREFILTERED: number;
  45412. /**
  45413. * Texture content is raw 3D data
  45414. */
  45415. static DATASOURCE_RAW3D: number;
  45416. /**
  45417. * Texture content is a depth texture
  45418. */
  45419. static DATASOURCE_DEPTHTEXTURE: number;
  45420. /**
  45421. * Texture data comes from a raw cube data encoded with RGBD
  45422. */
  45423. static DATASOURCE_CUBERAW_RGBD: number;
  45424. /**
  45425. * Defines if the texture is ready
  45426. */
  45427. isReady: boolean;
  45428. /**
  45429. * Defines if the texture is a cube texture
  45430. */
  45431. isCube: boolean;
  45432. /**
  45433. * Defines if the texture contains 3D data
  45434. */
  45435. is3D: boolean;
  45436. /**
  45437. * Gets the URL used to load this texture
  45438. */
  45439. url: string;
  45440. /**
  45441. * Gets the sampling mode of the texture
  45442. */
  45443. samplingMode: number;
  45444. /**
  45445. * Gets a boolean indicating if the texture needs mipmaps generation
  45446. */
  45447. generateMipMaps: boolean;
  45448. /**
  45449. * Gets the number of samples used by the texture (WebGL2+ only)
  45450. */
  45451. samples: number;
  45452. /**
  45453. * Gets the type of the texture (int, float...)
  45454. */
  45455. type: number;
  45456. /**
  45457. * Gets the format of the texture (RGB, RGBA...)
  45458. */
  45459. format: number;
  45460. /**
  45461. * Observable called when the texture is loaded
  45462. */
  45463. onLoadedObservable: Observable<InternalTexture>;
  45464. /**
  45465. * Gets the width of the texture
  45466. */
  45467. width: number;
  45468. /**
  45469. * Gets the height of the texture
  45470. */
  45471. height: number;
  45472. /**
  45473. * Gets the depth of the texture
  45474. */
  45475. depth: number;
  45476. /**
  45477. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  45478. */
  45479. baseWidth: number;
  45480. /**
  45481. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  45482. */
  45483. baseHeight: number;
  45484. /**
  45485. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  45486. */
  45487. baseDepth: number;
  45488. /**
  45489. * Gets a boolean indicating if the texture is inverted on Y axis
  45490. */
  45491. invertY: boolean;
  45492. /**
  45493. * Gets or set the previous tracker in the list
  45494. */
  45495. previous: Nullable<IInternalTextureTracker>;
  45496. /**
  45497. * Gets or set the next tracker in the list
  45498. */
  45499. next: Nullable<IInternalTextureTracker>;
  45500. /** @hidden */
  45501. _initialSlot: number;
  45502. /** @hidden */
  45503. _designatedSlot: number;
  45504. /** @hidden */
  45505. _dataSource: number;
  45506. /** @hidden */
  45507. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  45508. /** @hidden */
  45509. _bufferView: Nullable<ArrayBufferView>;
  45510. /** @hidden */
  45511. _bufferViewArray: Nullable<ArrayBufferView[]>;
  45512. /** @hidden */
  45513. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  45514. /** @hidden */
  45515. _size: number;
  45516. /** @hidden */
  45517. _extension: string;
  45518. /** @hidden */
  45519. _files: Nullable<string[]>;
  45520. /** @hidden */
  45521. _workingCanvas: HTMLCanvasElement;
  45522. /** @hidden */
  45523. _workingContext: CanvasRenderingContext2D;
  45524. /** @hidden */
  45525. _framebuffer: Nullable<WebGLFramebuffer>;
  45526. /** @hidden */
  45527. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  45528. /** @hidden */
  45529. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  45530. /** @hidden */
  45531. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  45532. /** @hidden */
  45533. _attachments: Nullable<number[]>;
  45534. /** @hidden */
  45535. _cachedCoordinatesMode: Nullable<number>;
  45536. /** @hidden */
  45537. _cachedWrapU: Nullable<number>;
  45538. /** @hidden */
  45539. _cachedWrapV: Nullable<number>;
  45540. /** @hidden */
  45541. _cachedWrapR: Nullable<number>;
  45542. /** @hidden */
  45543. _cachedAnisotropicFilteringLevel: Nullable<number>;
  45544. /** @hidden */
  45545. _isDisabled: boolean;
  45546. /** @hidden */
  45547. _compression: Nullable<string>;
  45548. /** @hidden */
  45549. _generateStencilBuffer: boolean;
  45550. /** @hidden */
  45551. _generateDepthBuffer: boolean;
  45552. /** @hidden */
  45553. _comparisonFunction: number;
  45554. /** @hidden */
  45555. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  45556. /** @hidden */
  45557. _lodGenerationScale: number;
  45558. /** @hidden */
  45559. _lodGenerationOffset: number;
  45560. /** @hidden */
  45561. _lodTextureHigh: BaseTexture;
  45562. /** @hidden */
  45563. _lodTextureMid: BaseTexture;
  45564. /** @hidden */
  45565. _lodTextureLow: BaseTexture;
  45566. /** @hidden */
  45567. _isRGBD: boolean;
  45568. /** @hidden */
  45569. _webGLTexture: Nullable<WebGLTexture>;
  45570. /** @hidden */
  45571. _references: number;
  45572. private _engine;
  45573. /**
  45574. * Gets the Engine the texture belongs to.
  45575. * @returns The babylon engine
  45576. */
  45577. getEngine(): Engine;
  45578. /**
  45579. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  45580. */
  45581. readonly dataSource: number;
  45582. /**
  45583. * Creates a new InternalTexture
  45584. * @param engine defines the engine to use
  45585. * @param dataSource defines the type of data that will be used
  45586. */
  45587. constructor(engine: Engine, dataSource: number);
  45588. /**
  45589. * Increments the number of references (ie. the number of Texture that point to it)
  45590. */
  45591. incrementReferences(): void;
  45592. /**
  45593. * Change the size of the texture (not the size of the content)
  45594. * @param width defines the new width
  45595. * @param height defines the new height
  45596. * @param depth defines the new depth (1 by default)
  45597. */
  45598. updateSize(width: int, height: int, depth?: int): void;
  45599. /** @hidden */
  45600. _rebuild(): void;
  45601. /** @hidden */
  45602. _swapAndDie(target: InternalTexture): void;
  45603. /**
  45604. * Dispose the current allocated resources
  45605. */
  45606. dispose(): void;
  45607. }
  45608. }
  45609. declare module BABYLON {
  45610. /**
  45611. * This represents the required contract to create a new type of texture loader.
  45612. */
  45613. interface IInternalTextureLoader {
  45614. /**
  45615. * Defines wether the loader supports cascade loading the different faces.
  45616. */
  45617. supportCascades: boolean;
  45618. /**
  45619. * This returns if the loader support the current file information.
  45620. * @param extension defines the file extension of the file being loaded
  45621. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45622. * @param fallback defines the fallback internal texture if any
  45623. * @param isBase64 defines whether the texture is encoded as a base64
  45624. * @param isBuffer defines whether the texture data are stored as a buffer
  45625. * @returns true if the loader can load the specified file
  45626. */
  45627. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45628. /**
  45629. * Transform the url before loading if required.
  45630. * @param rootUrl the url of the texture
  45631. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45632. * @returns the transformed texture
  45633. */
  45634. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45635. /**
  45636. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45637. * @param rootUrl the url of the texture
  45638. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45639. * @returns the fallback texture
  45640. */
  45641. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45642. /**
  45643. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45644. * @param data contains the texture data
  45645. * @param texture defines the BabylonJS internal texture
  45646. * @param createPolynomials will be true if polynomials have been requested
  45647. * @param onLoad defines the callback to trigger once the texture is ready
  45648. * @param onError defines the callback to trigger in case of error
  45649. */
  45650. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45651. /**
  45652. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45653. * @param data contains the texture data
  45654. * @param texture defines the BabylonJS internal texture
  45655. * @param callback defines the method to call once ready to upload
  45656. */
  45657. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45658. }
  45659. }
  45660. declare module BABYLON {
  45661. /**
  45662. * Internal interface used to track InternalTexture already bound to the GL context
  45663. */
  45664. interface IInternalTextureTracker {
  45665. /**
  45666. * Gets or set the previous tracker in the list
  45667. */
  45668. previous: Nullable<IInternalTextureTracker>;
  45669. /**
  45670. * Gets or set the next tracker in the list
  45671. */
  45672. next: Nullable<IInternalTextureTracker>;
  45673. }
  45674. /**
  45675. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  45676. */
  45677. class DummyInternalTextureTracker {
  45678. /**
  45679. * Gets or set the previous tracker in the list
  45680. */
  45681. previous: Nullable<IInternalTextureTracker>;
  45682. /**
  45683. * Gets or set the next tracker in the list
  45684. */
  45685. next: Nullable<IInternalTextureTracker>;
  45686. }
  45687. }
  45688. declare module BABYLON {
  45689. /**
  45690. * Mirror texture can be used to simulate the view from a mirror in a scene.
  45691. * It will dynamically be rendered every frame to adapt to the camera point of view.
  45692. * You can then easily use it as a reflectionTexture on a flat surface.
  45693. * In case the surface is not a plane, please consider relying on reflection probes.
  45694. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  45695. */
  45696. class MirrorTexture extends RenderTargetTexture {
  45697. private scene;
  45698. /**
  45699. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  45700. * 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.
  45701. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  45702. */
  45703. mirrorPlane: Plane;
  45704. /**
  45705. * Define the blur ratio used to blur the reflection if needed.
  45706. */
  45707. blurRatio: number;
  45708. /**
  45709. * Define the adaptive blur kernel used to blur the reflection if needed.
  45710. * This will autocompute the closest best match for the `blurKernel`
  45711. */
  45712. adaptiveBlurKernel: number;
  45713. /**
  45714. * Define the blur kernel used to blur the reflection if needed.
  45715. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  45716. */
  45717. blurKernel: number;
  45718. /**
  45719. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  45720. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  45721. */
  45722. blurKernelX: number;
  45723. /**
  45724. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  45725. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  45726. */
  45727. blurKernelY: number;
  45728. private _autoComputeBlurKernel;
  45729. protected _onRatioRescale(): void;
  45730. private _updateGammaSpace;
  45731. private _imageProcessingConfigChangeObserver;
  45732. private _transformMatrix;
  45733. private _mirrorMatrix;
  45734. private _savedViewMatrix;
  45735. private _blurX;
  45736. private _blurY;
  45737. private _adaptiveBlurKernel;
  45738. private _blurKernelX;
  45739. private _blurKernelY;
  45740. private _blurRatio;
  45741. /**
  45742. * Instantiates a Mirror Texture.
  45743. * Mirror texture can be used to simulate the view from a mirror in a scene.
  45744. * It will dynamically be rendered every frame to adapt to the camera point of view.
  45745. * You can then easily use it as a reflectionTexture on a flat surface.
  45746. * In case the surface is not a plane, please consider relying on reflection probes.
  45747. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  45748. * @param name
  45749. * @param size
  45750. * @param scene
  45751. * @param generateMipMaps
  45752. * @param type
  45753. * @param samplingMode
  45754. * @param generateDepthBuffer
  45755. */
  45756. constructor(name: string, size: number | {
  45757. width: number;
  45758. height: number;
  45759. } | {
  45760. ratio: number;
  45761. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  45762. private _preparePostProcesses;
  45763. /**
  45764. * Clone the mirror texture.
  45765. * @returns the cloned texture
  45766. */
  45767. clone(): MirrorTexture;
  45768. /**
  45769. * Serialize the texture to a JSON representation you could use in Parse later on
  45770. * @returns the serialized JSON representation
  45771. */
  45772. serialize(): any;
  45773. /**
  45774. * Dispose the texture and release its associated resources.
  45775. */
  45776. dispose(): void;
  45777. }
  45778. }
  45779. declare module BABYLON {
  45780. /**
  45781. * Creation options of the multi render target texture.
  45782. */
  45783. interface IMultiRenderTargetOptions {
  45784. /**
  45785. * Define if the texture needs to create mip maps after render.
  45786. */
  45787. generateMipMaps?: boolean;
  45788. /**
  45789. * Define the types of all the draw buffers we want to create
  45790. */
  45791. types?: number[];
  45792. /**
  45793. * Define the sampling modes of all the draw buffers we want to create
  45794. */
  45795. samplingModes?: number[];
  45796. /**
  45797. * Define if a depth buffer is required
  45798. */
  45799. generateDepthBuffer?: boolean;
  45800. /**
  45801. * Define if a stencil buffer is required
  45802. */
  45803. generateStencilBuffer?: boolean;
  45804. /**
  45805. * Define if a depth texture is required instead of a depth buffer
  45806. */
  45807. generateDepthTexture?: boolean;
  45808. /**
  45809. * Define the number of desired draw buffers
  45810. */
  45811. textureCount?: number;
  45812. /**
  45813. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45814. */
  45815. doNotChangeAspectRatio?: boolean;
  45816. /**
  45817. * Define the default type of the buffers we are creating
  45818. */
  45819. defaultType?: number;
  45820. }
  45821. /**
  45822. * A multi render target, like a render target provides the ability to render to a texture.
  45823. * Unlike the render target, it can render to several draw buffers in one draw.
  45824. * This is specially interesting in deferred rendering or for any effects requiring more than
  45825. * just one color from a single pass.
  45826. */
  45827. class MultiRenderTarget extends RenderTargetTexture {
  45828. private _internalTextures;
  45829. private _textures;
  45830. private _multiRenderTargetOptions;
  45831. /**
  45832. * Get if draw buffers are currently supported by the used hardware and browser.
  45833. */
  45834. readonly isSupported: boolean;
  45835. /**
  45836. * Get the list of textures generated by the multi render target.
  45837. */
  45838. readonly textures: Texture[];
  45839. /**
  45840. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45841. */
  45842. readonly depthTexture: Texture;
  45843. /**
  45844. * Set the wrapping mode on U of all the textures we are rendering to.
  45845. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45846. */
  45847. wrapU: number;
  45848. /**
  45849. * Set the wrapping mode on V of all the textures we are rendering to.
  45850. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45851. */
  45852. wrapV: number;
  45853. /**
  45854. * Instantiate a new multi render target texture.
  45855. * A multi render target, like a render target provides the ability to render to a texture.
  45856. * Unlike the render target, it can render to several draw buffers in one draw.
  45857. * This is specially interesting in deferred rendering or for any effects requiring more than
  45858. * just one color from a single pass.
  45859. * @param name Define the name of the texture
  45860. * @param size Define the size of the buffers to render to
  45861. * @param count Define the number of target we are rendering into
  45862. * @param scene Define the scene the texture belongs to
  45863. * @param options Define the options used to create the multi render target
  45864. */
  45865. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45866. /** @hidden */
  45867. _rebuild(): void;
  45868. private _createInternalTextures;
  45869. private _createTextures;
  45870. /**
  45871. * Define the number of samples used if MSAA is enabled.
  45872. */
  45873. samples: number;
  45874. /**
  45875. * Resize all the textures in the multi render target.
  45876. * Be carrefull as it will recreate all the data in the new texture.
  45877. * @param size Define the new size
  45878. */
  45879. resize(size: any): void;
  45880. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45881. /**
  45882. * Dispose the render targets and their associated resources
  45883. */
  45884. dispose(): void;
  45885. /**
  45886. * Release all the underlying texture used as draw buffers.
  45887. */
  45888. releaseInternalTextures(): void;
  45889. }
  45890. }
  45891. declare module BABYLON {
  45892. /**
  45893. * Raw cube texture where the raw buffers are passed in
  45894. */
  45895. class RawCubeTexture extends CubeTexture {
  45896. /**
  45897. * Creates a cube texture where the raw buffers are passed in.
  45898. * @param scene defines the scene the texture is attached to
  45899. * @param data defines the array of data to use to create each face
  45900. * @param size defines the size of the textures
  45901. * @param format defines the format of the data
  45902. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  45903. * @param generateMipMaps defines if the engine should generate the mip levels
  45904. * @param invertY defines if data must be stored with Y axis inverted
  45905. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  45906. * @param compression defines the compression used (null by default)
  45907. */
  45908. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  45909. /**
  45910. * Updates the raw cube texture.
  45911. * @param data defines the data to store
  45912. * @param format defines the data format
  45913. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45914. * @param invertY defines if data must be stored with Y axis inverted
  45915. * @param compression defines the compression used (null by default)
  45916. * @param level defines which level of the texture to update
  45917. */
  45918. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45919. /**
  45920. * Updates a raw cube texture with RGBD encoded data.
  45921. * @param data defines the array of data [mipmap][face] to use to create each face
  45922. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  45923. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45924. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45925. * @returns a promsie that resolves when the operation is complete
  45926. */
  45927. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  45928. /**
  45929. * Clones the raw cube texture.
  45930. * @return a new cube texture
  45931. */
  45932. clone(): CubeTexture;
  45933. /** @hidden */
  45934. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45935. }
  45936. }
  45937. declare module BABYLON {
  45938. /**
  45939. * Raw texture can help creating a texture directly from an array of data.
  45940. * This can be super useful if you either get the data from an uncompressed source or
  45941. * if you wish to create your texture pixel by pixel.
  45942. */
  45943. class RawTexture extends Texture {
  45944. /**
  45945. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  45946. */
  45947. format: number;
  45948. private _engine;
  45949. /**
  45950. * Instantiates a new RawTexture.
  45951. * Raw texture can help creating a texture directly from an array of data.
  45952. * This can be super useful if you either get the data from an uncompressed source or
  45953. * if you wish to create your texture pixel by pixel.
  45954. * @param data define the array of data to use to create the texture
  45955. * @param width define the width of the texture
  45956. * @param height define the height of the texture
  45957. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  45958. * @param scene define the scene the texture belongs to
  45959. * @param generateMipMaps define whether mip maps should be generated or not
  45960. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  45961. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  45962. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  45963. */
  45964. constructor(data: ArrayBufferView, width: number, height: number,
  45965. /**
  45966. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  45967. */
  45968. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  45969. /**
  45970. * Updates the texture underlying data.
  45971. * @param data Define the new data of the texture
  45972. */
  45973. update(data: ArrayBufferView): void;
  45974. /**
  45975. * Creates a luminance texture from some data.
  45976. * @param data Define the texture data
  45977. * @param width Define the width of the texture
  45978. * @param height Define the height of the texture
  45979. * @param scene Define the scene the texture belongs to
  45980. * @param generateMipMaps Define whether or not to create mip maps for the texture
  45981. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  45982. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  45983. * @returns the luminance texture
  45984. */
  45985. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  45986. /**
  45987. * Creates a luminance alpha texture from some data.
  45988. * @param data Define the texture data
  45989. * @param width Define the width of the texture
  45990. * @param height Define the height of the texture
  45991. * @param scene Define the scene the texture belongs to
  45992. * @param generateMipMaps Define whether or not to create mip maps for the texture
  45993. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  45994. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  45995. * @returns the luminance alpha texture
  45996. */
  45997. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  45998. /**
  45999. * Creates an alpha texture from some data.
  46000. * @param data Define the texture data
  46001. * @param width Define the width of the texture
  46002. * @param height Define the height of the texture
  46003. * @param scene Define the scene the texture belongs to
  46004. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46005. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46006. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46007. * @returns the alpha texture
  46008. */
  46009. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46010. /**
  46011. * Creates a RGB texture from some data.
  46012. * @param data Define the texture data
  46013. * @param width Define the width of the texture
  46014. * @param height Define the height of the texture
  46015. * @param scene Define the scene the texture belongs to
  46016. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46017. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46018. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46019. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46020. * @returns the RGB alpha texture
  46021. */
  46022. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46023. /**
  46024. * Creates a RGBA texture from some data.
  46025. * @param data Define the texture data
  46026. * @param width Define the width of the texture
  46027. * @param height Define the height of the texture
  46028. * @param scene Define the scene the texture belongs to
  46029. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46030. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46031. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46032. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46033. * @returns the RGBA texture
  46034. */
  46035. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46036. /**
  46037. * Creates a R texture from some data.
  46038. * @param data Define the texture data
  46039. * @param width Define the width of the texture
  46040. * @param height Define the height of the texture
  46041. * @param scene Define the scene the texture belongs to
  46042. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46043. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46044. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46045. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46046. * @returns the R texture
  46047. */
  46048. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46049. }
  46050. }
  46051. declare module BABYLON {
  46052. /**
  46053. * Class used to store 3D textures containing user data
  46054. */
  46055. class RawTexture3D extends Texture {
  46056. /** Gets or sets the texture format to use */
  46057. format: number;
  46058. private _engine;
  46059. /**
  46060. * Create a new RawTexture3D
  46061. * @param data defines the data of the texture
  46062. * @param width defines the width of the texture
  46063. * @param height defines the height of the texture
  46064. * @param depth defines the depth of the texture
  46065. * @param format defines the texture format to use
  46066. * @param scene defines the hosting scene
  46067. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  46068. * @param invertY defines if texture must be stored with Y axis inverted
  46069. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  46070. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46071. */
  46072. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  46073. /** Gets or sets the texture format to use */
  46074. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  46075. /**
  46076. * Update the texture with new data
  46077. * @param data defines the data to store in the texture
  46078. */
  46079. update(data: ArrayBufferView): void;
  46080. }
  46081. }
  46082. declare module BABYLON {
  46083. /**
  46084. * Creates a refraction texture used by refraction channel of the standard material.
  46085. * It is like a mirror but to see through a material.
  46086. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46087. */
  46088. class RefractionTexture extends RenderTargetTexture {
  46089. /**
  46090. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  46091. * 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.
  46092. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46093. */
  46094. refractionPlane: Plane;
  46095. /**
  46096. * Define how deep under the surface we should see.
  46097. */
  46098. depth: number;
  46099. /**
  46100. * Creates a refraction texture used by refraction channel of the standard material.
  46101. * It is like a mirror but to see through a material.
  46102. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46103. * @param name Define the texture name
  46104. * @param size Define the size of the underlying texture
  46105. * @param scene Define the scene the refraction belongs to
  46106. * @param generateMipMaps Define if we need to generate mips level for the refraction
  46107. */
  46108. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  46109. /**
  46110. * Clone the refraction texture.
  46111. * @returns the cloned texture
  46112. */
  46113. clone(): RefractionTexture;
  46114. /**
  46115. * Serialize the texture to a JSON representation you could use in Parse later on
  46116. * @returns the serialized JSON representation
  46117. */
  46118. serialize(): any;
  46119. }
  46120. }
  46121. declare module BABYLON {
  46122. /**
  46123. * This Helps creating a texture that will be created from a camera in your scene.
  46124. * It is basically a dynamic texture that could be used to create special effects for instance.
  46125. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  46126. */
  46127. class RenderTargetTexture extends Texture {
  46128. isCube: boolean;
  46129. /**
  46130. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  46131. */
  46132. static readonly REFRESHRATE_RENDER_ONCE: number;
  46133. /**
  46134. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  46135. */
  46136. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  46137. /**
  46138. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  46139. * the central point of your effect and can save a lot of performances.
  46140. */
  46141. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  46142. /**
  46143. * Use this predicate to dynamically define the list of mesh you want to render.
  46144. * If set, the renderList property will be overwritten.
  46145. */
  46146. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  46147. private _renderList;
  46148. /**
  46149. * Use this list to define the list of mesh you want to render.
  46150. */
  46151. renderList: Nullable<Array<AbstractMesh>>;
  46152. private _hookArray;
  46153. /**
  46154. * Define if particles should be rendered in your texture.
  46155. */
  46156. renderParticles: boolean;
  46157. /**
  46158. * Define if sprites should be rendered in your texture.
  46159. */
  46160. renderSprites: boolean;
  46161. /**
  46162. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  46163. */
  46164. coordinatesMode: number;
  46165. /**
  46166. * Define the camera used to render the texture.
  46167. */
  46168. activeCamera: Nullable<Camera>;
  46169. /**
  46170. * Override the render function of the texture with your own one.
  46171. */
  46172. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  46173. /**
  46174. * Define if camera post processes should be use while rendering the texture.
  46175. */
  46176. useCameraPostProcesses: boolean;
  46177. /**
  46178. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  46179. */
  46180. ignoreCameraViewport: boolean;
  46181. private _postProcessManager;
  46182. private _postProcesses;
  46183. private _resizeObserver;
  46184. /**
  46185. * An event triggered when the texture is unbind.
  46186. */
  46187. onBeforeBindObservable: Observable<RenderTargetTexture>;
  46188. /**
  46189. * An event triggered when the texture is unbind.
  46190. */
  46191. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  46192. private _onAfterUnbindObserver;
  46193. /**
  46194. * Set a after unbind callback in the texture.
  46195. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  46196. */
  46197. onAfterUnbind: () => void;
  46198. /**
  46199. * An event triggered before rendering the texture
  46200. */
  46201. onBeforeRenderObservable: Observable<number>;
  46202. private _onBeforeRenderObserver;
  46203. /**
  46204. * Set a before render callback in the texture.
  46205. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  46206. */
  46207. onBeforeRender: (faceIndex: number) => void;
  46208. /**
  46209. * An event triggered after rendering the texture
  46210. */
  46211. onAfterRenderObservable: Observable<number>;
  46212. private _onAfterRenderObserver;
  46213. /**
  46214. * Set a after render callback in the texture.
  46215. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  46216. */
  46217. onAfterRender: (faceIndex: number) => void;
  46218. /**
  46219. * An event triggered after the texture clear
  46220. */
  46221. onClearObservable: Observable<Engine>;
  46222. private _onClearObserver;
  46223. /**
  46224. * Set a clear callback in the texture.
  46225. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  46226. */
  46227. onClear: (Engine: Engine) => void;
  46228. /**
  46229. * Define the clear color of the Render Target if it should be different from the scene.
  46230. */
  46231. clearColor: Color4;
  46232. protected _size: number | {
  46233. width: number;
  46234. height: number;
  46235. };
  46236. protected _initialSizeParameter: number | {
  46237. width: number;
  46238. height: number;
  46239. } | {
  46240. ratio: number;
  46241. };
  46242. protected _sizeRatio: Nullable<number>;
  46243. /** @hidden */
  46244. _generateMipMaps: boolean;
  46245. protected _renderingManager: RenderingManager;
  46246. /** @hidden */
  46247. _waitingRenderList: string[];
  46248. protected _doNotChangeAspectRatio: boolean;
  46249. protected _currentRefreshId: number;
  46250. protected _refreshRate: number;
  46251. protected _textureMatrix: Matrix;
  46252. protected _samples: number;
  46253. protected _renderTargetOptions: RenderTargetCreationOptions;
  46254. /**
  46255. * Gets render target creation options that were used.
  46256. */
  46257. readonly renderTargetOptions: RenderTargetCreationOptions;
  46258. protected _engine: Engine;
  46259. protected _onRatioRescale(): void;
  46260. /**
  46261. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  46262. * It must define where the camera used to render the texture is set
  46263. */
  46264. boundingBoxPosition: Vector3;
  46265. private _boundingBoxSize;
  46266. /**
  46267. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  46268. * When defined, the cubemap will switch to local mode
  46269. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46270. * @example https://www.babylonjs-playground.com/#RNASML
  46271. */
  46272. boundingBoxSize: Vector3;
  46273. /**
  46274. * In case the RTT has been created with a depth texture, get the associated
  46275. * depth texture.
  46276. * Otherwise, return null.
  46277. */
  46278. depthStencilTexture: Nullable<InternalTexture>;
  46279. /**
  46280. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  46281. * or used a shadow, depth texture...
  46282. * @param name The friendly name of the texture
  46283. * @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)
  46284. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  46285. * @param generateMipMaps True if mip maps need to be generated after render.
  46286. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  46287. * @param type The type of the buffer in the RTT (int, half float, float...)
  46288. * @param isCube True if a cube texture needs to be created
  46289. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  46290. * @param generateDepthBuffer True to generate a depth buffer
  46291. * @param generateStencilBuffer True to generate a stencil buffer
  46292. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  46293. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  46294. */
  46295. constructor(name: string, size: number | {
  46296. width: number;
  46297. height: number;
  46298. } | {
  46299. ratio: number;
  46300. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  46301. /**
  46302. * Creates a depth stencil texture.
  46303. * This is only available in WebGL 2 or with the depth texture extension available.
  46304. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  46305. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  46306. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  46307. */
  46308. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  46309. private _processSizeParameter;
  46310. /**
  46311. * Define the number of samples to use in case of MSAA.
  46312. * It defaults to one meaning no MSAA has been enabled.
  46313. */
  46314. samples: number;
  46315. /**
  46316. * Resets the refresh counter of the texture and start bak from scratch.
  46317. * Could be usefull to regenerate the texture if it is setup to render only once.
  46318. */
  46319. resetRefreshCounter(): void;
  46320. /**
  46321. * Define the refresh rate of the texture or the rendering frequency.
  46322. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  46323. */
  46324. refreshRate: number;
  46325. /**
  46326. * Adds a post process to the render target rendering passes.
  46327. * @param postProcess define the post process to add
  46328. */
  46329. addPostProcess(postProcess: PostProcess): void;
  46330. /**
  46331. * Clear all the post processes attached to the render target
  46332. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  46333. */
  46334. clearPostProcesses(dispose?: boolean): void;
  46335. /**
  46336. * Remove one of the post process from the list of attached post processes to the texture
  46337. * @param postProcess define the post process to remove from the list
  46338. */
  46339. removePostProcess(postProcess: PostProcess): void;
  46340. /** @hidden */
  46341. _shouldRender(): boolean;
  46342. /**
  46343. * Gets the actual render size of the texture.
  46344. * @returns the width of the render size
  46345. */
  46346. getRenderSize(): number;
  46347. /**
  46348. * Gets the actual render width of the texture.
  46349. * @returns the width of the render size
  46350. */
  46351. getRenderWidth(): number;
  46352. /**
  46353. * Gets the actual render height of the texture.
  46354. * @returns the height of the render size
  46355. */
  46356. getRenderHeight(): number;
  46357. /**
  46358. * Get if the texture can be rescaled or not.
  46359. */
  46360. readonly canRescale: boolean;
  46361. /**
  46362. * Resize the texture using a ratio.
  46363. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  46364. */
  46365. scale(ratio: number): void;
  46366. /**
  46367. * Get the texture reflection matrix used to rotate/transform the reflection.
  46368. * @returns the reflection matrix
  46369. */
  46370. getReflectionTextureMatrix(): Matrix;
  46371. /**
  46372. * Resize the texture to a new desired size.
  46373. * Be carrefull as it will recreate all the data in the new texture.
  46374. * @param size Define the new size. It can be:
  46375. * - a number for squared texture,
  46376. * - an object containing { width: number, height: number }
  46377. * - or an object containing a ratio { ratio: number }
  46378. */
  46379. resize(size: number | {
  46380. width: number;
  46381. height: number;
  46382. } | {
  46383. ratio: number;
  46384. }): void;
  46385. /**
  46386. * Renders all the objects from the render list into the texture.
  46387. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  46388. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  46389. */
  46390. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  46391. private _bestReflectionRenderTargetDimension;
  46392. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46393. private renderToTarget;
  46394. /**
  46395. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46396. * This allowed control for front to back rendering or reversly depending of the special needs.
  46397. *
  46398. * @param renderingGroupId The rendering group id corresponding to its index
  46399. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46400. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46401. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46402. */
  46403. 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;
  46404. /**
  46405. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46406. *
  46407. * @param renderingGroupId The rendering group id corresponding to its index
  46408. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46409. */
  46410. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  46411. /**
  46412. * Clones the texture.
  46413. * @returns the cloned texture
  46414. */
  46415. clone(): RenderTargetTexture;
  46416. /**
  46417. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  46418. * @returns The JSON representation of the texture
  46419. */
  46420. serialize(): any;
  46421. /**
  46422. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  46423. */
  46424. disposeFramebufferObjects(): void;
  46425. /**
  46426. * Dispose the texture and release its associated resources.
  46427. */
  46428. dispose(): void;
  46429. /** @hidden */
  46430. _rebuild(): void;
  46431. /**
  46432. * Clear the info related to rendering groups preventing retention point in material dispose.
  46433. */
  46434. freeRenderingGroups(): void;
  46435. }
  46436. }
  46437. declare module BABYLON {
  46438. /**
  46439. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  46440. * @see http://doc.babylonjs.com/babylon101/materials#texture
  46441. */
  46442. class Texture extends BaseTexture {
  46443. /** nearest is mag = nearest and min = nearest and mip = linear */
  46444. static readonly NEAREST_SAMPLINGMODE: number;
  46445. /** nearest is mag = nearest and min = nearest and mip = linear */
  46446. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  46447. /** Bilinear is mag = linear and min = linear and mip = nearest */
  46448. static readonly BILINEAR_SAMPLINGMODE: number;
  46449. /** Bilinear is mag = linear and min = linear and mip = nearest */
  46450. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  46451. /** Trilinear is mag = linear and min = linear and mip = linear */
  46452. static readonly TRILINEAR_SAMPLINGMODE: number;
  46453. /** Trilinear is mag = linear and min = linear and mip = linear */
  46454. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  46455. /** mag = nearest and min = nearest and mip = nearest */
  46456. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  46457. /** mag = nearest and min = linear and mip = nearest */
  46458. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  46459. /** mag = nearest and min = linear and mip = linear */
  46460. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  46461. /** mag = nearest and min = linear and mip = none */
  46462. static readonly NEAREST_LINEAR: number;
  46463. /** mag = nearest and min = nearest and mip = none */
  46464. static readonly NEAREST_NEAREST: number;
  46465. /** mag = linear and min = nearest and mip = nearest */
  46466. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  46467. /** mag = linear and min = nearest and mip = linear */
  46468. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  46469. /** mag = linear and min = linear and mip = none */
  46470. static readonly LINEAR_LINEAR: number;
  46471. /** mag = linear and min = nearest and mip = none */
  46472. static readonly LINEAR_NEAREST: number;
  46473. /** Explicit coordinates mode */
  46474. static readonly EXPLICIT_MODE: number;
  46475. /** Spherical coordinates mode */
  46476. static readonly SPHERICAL_MODE: number;
  46477. /** Planar coordinates mode */
  46478. static readonly PLANAR_MODE: number;
  46479. /** Cubic coordinates mode */
  46480. static readonly CUBIC_MODE: number;
  46481. /** Projection coordinates mode */
  46482. static readonly PROJECTION_MODE: number;
  46483. /** Inverse Cubic coordinates mode */
  46484. static readonly SKYBOX_MODE: number;
  46485. /** Inverse Cubic coordinates mode */
  46486. static readonly INVCUBIC_MODE: number;
  46487. /** Equirectangular coordinates mode */
  46488. static readonly EQUIRECTANGULAR_MODE: number;
  46489. /** Equirectangular Fixed coordinates mode */
  46490. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  46491. /** Equirectangular Fixed Mirrored coordinates mode */
  46492. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  46493. /** Texture is not repeating outside of 0..1 UVs */
  46494. static readonly CLAMP_ADDRESSMODE: number;
  46495. /** Texture is repeating outside of 0..1 UVs */
  46496. static readonly WRAP_ADDRESSMODE: number;
  46497. /** Texture is repeating and mirrored */
  46498. static readonly MIRROR_ADDRESSMODE: number;
  46499. /**
  46500. * 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
  46501. */
  46502. static UseSerializedUrlIfAny: boolean;
  46503. /**
  46504. * Define the url of the texture.
  46505. */
  46506. url: Nullable<string>;
  46507. /**
  46508. * Define an offset on the texture to offset the u coordinates of the UVs
  46509. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  46510. */
  46511. uOffset: number;
  46512. /**
  46513. * Define an offset on the texture to offset the v coordinates of the UVs
  46514. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  46515. */
  46516. vOffset: number;
  46517. /**
  46518. * Define an offset on the texture to scale the u coordinates of the UVs
  46519. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  46520. */
  46521. uScale: number;
  46522. /**
  46523. * Define an offset on the texture to scale the v coordinates of the UVs
  46524. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  46525. */
  46526. vScale: number;
  46527. /**
  46528. * Define an offset on the texture to rotate around the u coordinates of the UVs
  46529. * @see http://doc.babylonjs.com/how_to/more_materials
  46530. */
  46531. uAng: number;
  46532. /**
  46533. * Define an offset on the texture to rotate around the v coordinates of the UVs
  46534. * @see http://doc.babylonjs.com/how_to/more_materials
  46535. */
  46536. vAng: number;
  46537. /**
  46538. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  46539. * @see http://doc.babylonjs.com/how_to/more_materials
  46540. */
  46541. wAng: number;
  46542. /**
  46543. * Defines the center of rotation (U)
  46544. */
  46545. uRotationCenter: number;
  46546. /**
  46547. * Defines the center of rotation (V)
  46548. */
  46549. vRotationCenter: number;
  46550. /**
  46551. * Defines the center of rotation (W)
  46552. */
  46553. wRotationCenter: number;
  46554. /**
  46555. * Are mip maps generated for this texture or not.
  46556. */
  46557. readonly noMipmap: boolean;
  46558. private _noMipmap;
  46559. /** @hidden */
  46560. _invertY: boolean;
  46561. private _rowGenerationMatrix;
  46562. private _cachedTextureMatrix;
  46563. private _projectionModeMatrix;
  46564. private _t0;
  46565. private _t1;
  46566. private _t2;
  46567. private _cachedUOffset;
  46568. private _cachedVOffset;
  46569. private _cachedUScale;
  46570. private _cachedVScale;
  46571. private _cachedUAng;
  46572. private _cachedVAng;
  46573. private _cachedWAng;
  46574. private _cachedProjectionMatrixId;
  46575. private _cachedCoordinatesMode;
  46576. /** @hidden */
  46577. _samplingMode: number;
  46578. /** @hidden */
  46579. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  46580. private _deleteBuffer;
  46581. protected _format: Nullable<number>;
  46582. private _delayedOnLoad;
  46583. private _delayedOnError;
  46584. /**
  46585. * Observable triggered once the texture has been loaded.
  46586. */
  46587. onLoadObservable: Observable<Texture>;
  46588. protected _isBlocking: boolean;
  46589. /**
  46590. * Is the texture preventing material to render while loading.
  46591. * If false, a default texture will be used instead of the loading one during the preparation step.
  46592. */
  46593. isBlocking: boolean;
  46594. /**
  46595. * Get the current sampling mode associated with the texture.
  46596. */
  46597. readonly samplingMode: number;
  46598. /**
  46599. * Instantiates a new texture.
  46600. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  46601. * @see http://doc.babylonjs.com/babylon101/materials#texture
  46602. * @param url define the url of the picture to load as a texture
  46603. * @param scene define the scene the texture will belong to
  46604. * @param noMipmap define if the texture will require mip maps or not
  46605. * @param invertY define if the texture needs to be inverted on the y axis during loading
  46606. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  46607. * @param onLoad define a callback triggered when the texture has been loaded
  46608. * @param onError define a callback triggered when an error occurred during the loading session
  46609. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  46610. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  46611. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  46612. */
  46613. 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);
  46614. /**
  46615. * Update the url (and optional buffer) of this texture if url was null during construction.
  46616. * @param url the url of the texture
  46617. * @param buffer the buffer of the texture (defaults to null)
  46618. */
  46619. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  46620. /**
  46621. * Finish the loading sequence of a texture flagged as delayed load.
  46622. * @hidden
  46623. */
  46624. delayLoad(): void;
  46625. /**
  46626. * Update the sampling mode of the texture.
  46627. * Default is Trilinear mode.
  46628. *
  46629. * | Value | Type | Description |
  46630. * | ----- | ------------------ | ----------- |
  46631. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46632. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46633. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46634. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46635. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46636. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46637. * | 7 | NEAREST_LINEAR | |
  46638. * | 8 | NEAREST_NEAREST | |
  46639. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46640. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46641. * | 11 | LINEAR_LINEAR | |
  46642. * | 12 | LINEAR_NEAREST | |
  46643. *
  46644. * > _mag_: magnification filter (close to the viewer)
  46645. * > _min_: minification filter (far from the viewer)
  46646. * > _mip_: filter used between mip map levels
  46647. *@param samplingMode Define the new sampling mode of the texture
  46648. */
  46649. updateSamplingMode(samplingMode: number): void;
  46650. private _prepareRowForTextureGeneration;
  46651. /**
  46652. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  46653. * @returns the transform matrix of the texture.
  46654. */
  46655. getTextureMatrix(): Matrix;
  46656. /**
  46657. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  46658. * @returns The reflection texture transform
  46659. */
  46660. getReflectionTextureMatrix(): Matrix;
  46661. /**
  46662. * Clones the texture.
  46663. * @returns the cloned texture
  46664. */
  46665. clone(): Texture;
  46666. /**
  46667. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  46668. * @returns The JSON representation of the texture
  46669. */
  46670. serialize(): any;
  46671. /**
  46672. * Get the current class name of the texture usefull for serialization or dynamic coding.
  46673. * @returns "Texture"
  46674. */
  46675. getClassName(): string;
  46676. /**
  46677. * Dispose the texture and release its associated resources.
  46678. */
  46679. dispose(): void;
  46680. /**
  46681. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  46682. * @param parsedTexture Define the JSON representation of the texture
  46683. * @param scene Define the scene the parsed texture should be instantiated in
  46684. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  46685. * @returns The parsed texture if successful
  46686. */
  46687. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  46688. /**
  46689. * Creates a texture from its base 64 representation.
  46690. * @param data Define the base64 payload without the data: prefix
  46691. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  46692. * @param scene Define the scene the texture should belong to
  46693. * @param noMipmap Forces the texture to not create mip map information if true
  46694. * @param invertY define if the texture needs to be inverted on the y axis during loading
  46695. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  46696. * @param onLoad define a callback triggered when the texture has been loaded
  46697. * @param onError define a callback triggered when an error occurred during the loading session
  46698. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  46699. * @returns the created texture
  46700. */
  46701. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  46702. /**
  46703. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  46704. * @param data Define the base64 payload without the data: prefix
  46705. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  46706. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  46707. * @param scene Define the scene the texture should belong to
  46708. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  46709. * @param noMipmap Forces the texture to not create mip map information if true
  46710. * @param invertY define if the texture needs to be inverted on the y axis during loading
  46711. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  46712. * @param onLoad define a callback triggered when the texture has been loaded
  46713. * @param onError define a callback triggered when an error occurred during the loading session
  46714. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  46715. * @returns the created texture
  46716. */
  46717. 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;
  46718. }
  46719. }
  46720. declare module BABYLON {
  46721. /**
  46722. * Settings for finer control over video usage
  46723. */
  46724. interface VideoTextureSettings {
  46725. /**
  46726. * Applies `autoplay` to video, if specified
  46727. */
  46728. autoPlay?: boolean;
  46729. /**
  46730. * Applies `loop` to video, if specified
  46731. */
  46732. loop?: boolean;
  46733. /**
  46734. * Automatically updates internal texture from video at every frame in the render loop
  46735. */
  46736. autoUpdateTexture: boolean;
  46737. /**
  46738. * Image src displayed during the video loading or until the user interacts with the video.
  46739. */
  46740. poster?: string;
  46741. }
  46742. /**
  46743. * If you want to display a video in your scene, this is the special texture for that.
  46744. * This special texture works similar to other textures, with the exception of a few parameters.
  46745. * @see https://doc.babylonjs.com/how_to/video_texture
  46746. */
  46747. class VideoTexture extends Texture {
  46748. /**
  46749. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  46750. */
  46751. readonly autoUpdateTexture: boolean;
  46752. /**
  46753. * The video instance used by the texture internally
  46754. */
  46755. readonly video: HTMLVideoElement;
  46756. private _onUserActionRequestedObservable;
  46757. /**
  46758. * Event triggerd when a dom action is required by the user to play the video.
  46759. * This happens due to recent changes in browser policies preventing video to auto start.
  46760. */
  46761. readonly onUserActionRequestedObservable: Observable<Texture>;
  46762. private _generateMipMaps;
  46763. private _engine;
  46764. private _stillImageCaptured;
  46765. private _poster;
  46766. /**
  46767. * Creates a video texture.
  46768. * If you want to display a video in your scene, this is the special texture for that.
  46769. * This special texture works similar to other textures, with the exception of a few parameters.
  46770. * @see https://doc.babylonjs.com/how_to/video_texture
  46771. * @param name optional name, will detect from video source, if not defined
  46772. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  46773. * @param scene is obviously the current scene.
  46774. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  46775. * @param invertY is false by default but can be used to invert video on Y axis
  46776. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  46777. * @param settings allows finer control over video usage
  46778. */
  46779. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  46780. private _getName;
  46781. private _getVideo;
  46782. private _createInternalTexture;
  46783. private reset;
  46784. /**
  46785. * @hidden Internal method to initiate `update`.
  46786. */
  46787. _rebuild(): void;
  46788. /**
  46789. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  46790. */
  46791. update(): void;
  46792. /**
  46793. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  46794. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  46795. */
  46796. updateTexture(isVisible: boolean): void;
  46797. protected _updateInternalTexture: (e?: Event | undefined) => void;
  46798. /**
  46799. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  46800. * @param url New url.
  46801. */
  46802. updateURL(url: string): void;
  46803. /**
  46804. * Dispose the texture and release its associated resources.
  46805. */
  46806. dispose(): void;
  46807. /**
  46808. * Creates a video texture straight from your WebCam video feed.
  46809. * @param scene Define the scene the texture should be created in
  46810. * @param onReady Define a callback to triggered once the texture will be ready
  46811. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  46812. */
  46813. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  46814. minWidth: number;
  46815. maxWidth: number;
  46816. minHeight: number;
  46817. maxHeight: number;
  46818. deviceId: string;
  46819. }): void;
  46820. }
  46821. }
  46822. declare var DracoDecoderModule: any;
  46823. declare var WebAssembly: any;
  46824. declare module BABYLON {
  46825. /**
  46826. * Configuration for Draco compression
  46827. */
  46828. interface IDracoCompressionConfiguration {
  46829. /**
  46830. * Configuration for the decoder.
  46831. */
  46832. decoder?: {
  46833. /**
  46834. * The url to the WebAssembly module.
  46835. */
  46836. wasmUrl?: string;
  46837. /**
  46838. * The url to the WebAssembly binary.
  46839. */
  46840. wasmBinaryUrl?: string;
  46841. /**
  46842. * The url to the fallback JavaScript module.
  46843. */
  46844. fallbackUrl?: string;
  46845. };
  46846. }
  46847. /**
  46848. * Draco compression (https://google.github.io/draco/)
  46849. *
  46850. * This class wraps the Draco module.
  46851. *
  46852. * **Encoder**
  46853. *
  46854. * The encoder is not currently implemented.
  46855. *
  46856. * **Decoder**
  46857. *
  46858. * 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.
  46859. *
  46860. * To update the configuration, use the following code:
  46861. * ```javascript
  46862. * BABYLON.DracoCompression.Configuration = {
  46863. * decoder: {
  46864. * wasmUrl: "<url to the WebAssembly library>",
  46865. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  46866. * fallbackUrl: "<url to the fallback JavaScript library>",
  46867. * }
  46868. * };
  46869. * ```
  46870. *
  46871. * 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.
  46872. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  46873. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  46874. *
  46875. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  46876. * ```javascript
  46877. * var dracoCompression = new BABYLON.DracoCompression();
  46878. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  46879. * [BABYLON.VertexBuffer.PositionKind]: 0
  46880. * });
  46881. * ```
  46882. *
  46883. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  46884. */
  46885. class DracoCompression implements IDisposable {
  46886. private static _DecoderModulePromise;
  46887. /**
  46888. * The configuration. Defaults to the following urls:
  46889. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  46890. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  46891. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  46892. */
  46893. static Configuration: IDracoCompressionConfiguration;
  46894. /**
  46895. * Returns true if the decoder is available.
  46896. */
  46897. static readonly DecoderAvailable: boolean;
  46898. /**
  46899. * Constructor
  46900. */
  46901. constructor();
  46902. /**
  46903. * Stop all async operations and release resources.
  46904. */
  46905. dispose(): void;
  46906. /**
  46907. * Decode Draco compressed mesh data to vertex data.
  46908. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  46909. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  46910. * @returns A promise that resolves with the decoded vertex data
  46911. */
  46912. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  46913. [kind: string]: number;
  46914. }): Promise<VertexData>;
  46915. private static _GetDecoderModule;
  46916. private static _LoadScriptAsync;
  46917. private static _LoadFileAsync;
  46918. }
  46919. }
  46920. declare module BABYLON {
  46921. /**
  46922. * Particle emitter emitting particles from the inside of a box.
  46923. * It emits the particles randomly between 2 given directions.
  46924. */
  46925. class BoxParticleEmitter implements IParticleEmitterType {
  46926. /**
  46927. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  46928. */
  46929. direction1: Vector3;
  46930. /**
  46931. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  46932. */
  46933. direction2: Vector3;
  46934. /**
  46935. * 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.
  46936. */
  46937. minEmitBox: Vector3;
  46938. /**
  46939. * 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.
  46940. */
  46941. maxEmitBox: Vector3;
  46942. /**
  46943. * Creates a new instance BoxParticleEmitter
  46944. */
  46945. constructor();
  46946. /**
  46947. * Called by the particle System when the direction is computed for the created particle.
  46948. * @param worldMatrix is the world matrix of the particle system
  46949. * @param directionToUpdate is the direction vector to update with the result
  46950. * @param particle is the particle we are computed the direction for
  46951. */
  46952. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  46953. /**
  46954. * Called by the particle System when the position is computed for the created particle.
  46955. * @param worldMatrix is the world matrix of the particle system
  46956. * @param positionToUpdate is the position vector to update with the result
  46957. * @param particle is the particle we are computed the position for
  46958. */
  46959. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  46960. /**
  46961. * Clones the current emitter and returns a copy of it
  46962. * @returns the new emitter
  46963. */
  46964. clone(): BoxParticleEmitter;
  46965. /**
  46966. * Called by the GPUParticleSystem to setup the update shader
  46967. * @param effect defines the update shader
  46968. */
  46969. applyToShader(effect: Effect): void;
  46970. /**
  46971. * Returns a string to use to update the GPU particles update shader
  46972. * @returns a string containng the defines string
  46973. */
  46974. getEffectDefines(): string;
  46975. /**
  46976. * Returns the string "BoxParticleEmitter"
  46977. * @returns a string containing the class name
  46978. */
  46979. getClassName(): string;
  46980. /**
  46981. * Serializes the particle system to a JSON object.
  46982. * @returns the JSON object
  46983. */
  46984. serialize(): any;
  46985. /**
  46986. * Parse properties from a JSON object
  46987. * @param serializationObject defines the JSON object
  46988. */
  46989. parse(serializationObject: any): void;
  46990. }
  46991. }
  46992. declare module BABYLON {
  46993. /**
  46994. * Particle emitter emitting particles from the inside of a cone.
  46995. * It emits the particles alongside the cone volume from the base to the particle.
  46996. * The emission direction might be randomized.
  46997. */
  46998. class ConeParticleEmitter implements IParticleEmitterType {
  46999. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  47000. directionRandomizer: number;
  47001. private _radius;
  47002. private _angle;
  47003. private _height;
  47004. /**
  47005. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  47006. */
  47007. radiusRange: number;
  47008. /**
  47009. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  47010. */
  47011. heightRange: number;
  47012. /**
  47013. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  47014. */
  47015. emitFromSpawnPointOnly: boolean;
  47016. /**
  47017. * Gets or sets the radius of the emission cone
  47018. */
  47019. radius: number;
  47020. /**
  47021. * Gets or sets the angle of the emission cone
  47022. */
  47023. angle: number;
  47024. private _buildHeight;
  47025. /**
  47026. * Creates a new instance ConeParticleEmitter
  47027. * @param radius the radius of the emission cone (1 by default)
  47028. * @param angles the cone base angle (PI by default)
  47029. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  47030. */
  47031. constructor(radius?: number, angle?: number,
  47032. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  47033. directionRandomizer?: number);
  47034. /**
  47035. * Called by the particle System when the direction is computed for the created particle.
  47036. * @param worldMatrix is the world matrix of the particle system
  47037. * @param directionToUpdate is the direction vector to update with the result
  47038. * @param particle is the particle we are computed the direction for
  47039. */
  47040. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47041. /**
  47042. * Called by the particle System when the position is computed for the created particle.
  47043. * @param worldMatrix is the world matrix of the particle system
  47044. * @param positionToUpdate is the position vector to update with the result
  47045. * @param particle is the particle we are computed the position for
  47046. */
  47047. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47048. /**
  47049. * Clones the current emitter and returns a copy of it
  47050. * @returns the new emitter
  47051. */
  47052. clone(): ConeParticleEmitter;
  47053. /**
  47054. * Called by the GPUParticleSystem to setup the update shader
  47055. * @param effect defines the update shader
  47056. */
  47057. applyToShader(effect: Effect): void;
  47058. /**
  47059. * Returns a string to use to update the GPU particles update shader
  47060. * @returns a string containng the defines string
  47061. */
  47062. getEffectDefines(): string;
  47063. /**
  47064. * Returns the string "ConeParticleEmitter"
  47065. * @returns a string containing the class name
  47066. */
  47067. getClassName(): string;
  47068. /**
  47069. * Serializes the particle system to a JSON object.
  47070. * @returns the JSON object
  47071. */
  47072. serialize(): any;
  47073. /**
  47074. * Parse properties from a JSON object
  47075. * @param serializationObject defines the JSON object
  47076. */
  47077. parse(serializationObject: any): void;
  47078. }
  47079. }
  47080. declare module BABYLON {
  47081. /**
  47082. * Particle emitter emitting particles from the inside of a cylinder.
  47083. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  47084. */
  47085. class CylinderParticleEmitter implements IParticleEmitterType {
  47086. /**
  47087. * The radius of the emission cylinder.
  47088. */
  47089. radius: number;
  47090. /**
  47091. * The height of the emission cylinder.
  47092. */
  47093. height: number;
  47094. /**
  47095. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47096. */
  47097. radiusRange: number;
  47098. /**
  47099. * How much to randomize the particle direction [0-1].
  47100. */
  47101. directionRandomizer: number;
  47102. /**
  47103. * Creates a new instance CylinderParticleEmitter
  47104. * @param radius the radius of the emission cylinder (1 by default)
  47105. * @param height the height of the emission cylinder (1 by default)
  47106. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47107. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47108. */
  47109. constructor(
  47110. /**
  47111. * The radius of the emission cylinder.
  47112. */
  47113. radius?: number,
  47114. /**
  47115. * The height of the emission cylinder.
  47116. */
  47117. height?: number,
  47118. /**
  47119. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47120. */
  47121. radiusRange?: number,
  47122. /**
  47123. * How much to randomize the particle direction [0-1].
  47124. */
  47125. directionRandomizer?: number);
  47126. /**
  47127. * Called by the particle System when the direction is computed for the created particle.
  47128. * @param worldMatrix is the world matrix of the particle system
  47129. * @param directionToUpdate is the direction vector to update with the result
  47130. * @param particle is the particle we are computed the direction for
  47131. */
  47132. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47133. /**
  47134. * Called by the particle System when the position is computed for the created particle.
  47135. * @param worldMatrix is the world matrix of the particle system
  47136. * @param positionToUpdate is the position vector to update with the result
  47137. * @param particle is the particle we are computed the position for
  47138. */
  47139. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47140. /**
  47141. * Clones the current emitter and returns a copy of it
  47142. * @returns the new emitter
  47143. */
  47144. clone(): CylinderParticleEmitter;
  47145. /**
  47146. * Called by the GPUParticleSystem to setup the update shader
  47147. * @param effect defines the update shader
  47148. */
  47149. applyToShader(effect: Effect): void;
  47150. /**
  47151. * Returns a string to use to update the GPU particles update shader
  47152. * @returns a string containng the defines string
  47153. */
  47154. getEffectDefines(): string;
  47155. /**
  47156. * Returns the string "CylinderParticleEmitter"
  47157. * @returns a string containing the class name
  47158. */
  47159. getClassName(): string;
  47160. /**
  47161. * Serializes the particle system to a JSON object.
  47162. * @returns the JSON object
  47163. */
  47164. serialize(): any;
  47165. /**
  47166. * Parse properties from a JSON object
  47167. * @param serializationObject defines the JSON object
  47168. */
  47169. parse(serializationObject: any): void;
  47170. }
  47171. /**
  47172. * Particle emitter emitting particles from the inside of a cylinder.
  47173. * It emits the particles randomly between two vectors.
  47174. */
  47175. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  47176. /**
  47177. * The min limit of the emission direction.
  47178. */
  47179. direction1: Vector3;
  47180. /**
  47181. * The max limit of the emission direction.
  47182. */
  47183. direction2: Vector3;
  47184. /**
  47185. * Creates a new instance CylinderDirectedParticleEmitter
  47186. * @param radius the radius of the emission cylinder (1 by default)
  47187. * @param height the height of the emission cylinder (1 by default)
  47188. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47189. * @param direction1 the min limit of the emission direction (up vector by default)
  47190. * @param direction2 the max limit of the emission direction (up vector by default)
  47191. */
  47192. constructor(radius?: number, height?: number, radiusRange?: number,
  47193. /**
  47194. * The min limit of the emission direction.
  47195. */
  47196. direction1?: Vector3,
  47197. /**
  47198. * The max limit of the emission direction.
  47199. */
  47200. direction2?: Vector3);
  47201. /**
  47202. * Called by the particle System when the direction is computed for the created particle.
  47203. * @param worldMatrix is the world matrix of the particle system
  47204. * @param directionToUpdate is the direction vector to update with the result
  47205. * @param particle is the particle we are computed the direction for
  47206. */
  47207. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47208. /**
  47209. * Clones the current emitter and returns a copy of it
  47210. * @returns the new emitter
  47211. */
  47212. clone(): CylinderDirectedParticleEmitter;
  47213. /**
  47214. * Called by the GPUParticleSystem to setup the update shader
  47215. * @param effect defines the update shader
  47216. */
  47217. applyToShader(effect: Effect): void;
  47218. /**
  47219. * Returns a string to use to update the GPU particles update shader
  47220. * @returns a string containng the defines string
  47221. */
  47222. getEffectDefines(): string;
  47223. /**
  47224. * Returns the string "CylinderDirectedParticleEmitter"
  47225. * @returns a string containing the class name
  47226. */
  47227. getClassName(): string;
  47228. /**
  47229. * Serializes the particle system to a JSON object.
  47230. * @returns the JSON object
  47231. */
  47232. serialize(): any;
  47233. /**
  47234. * Parse properties from a JSON object
  47235. * @param serializationObject defines the JSON object
  47236. */
  47237. parse(serializationObject: any): void;
  47238. }
  47239. }
  47240. declare module BABYLON {
  47241. /**
  47242. * Particle emitter emitting particles from the inside of a hemisphere.
  47243. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  47244. */
  47245. class HemisphericParticleEmitter implements IParticleEmitterType {
  47246. /**
  47247. * The radius of the emission hemisphere.
  47248. */
  47249. radius: number;
  47250. /**
  47251. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47252. */
  47253. radiusRange: number;
  47254. /**
  47255. * How much to randomize the particle direction [0-1].
  47256. */
  47257. directionRandomizer: number;
  47258. /**
  47259. * Creates a new instance HemisphericParticleEmitter
  47260. * @param radius the radius of the emission hemisphere (1 by default)
  47261. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47262. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47263. */
  47264. constructor(
  47265. /**
  47266. * The radius of the emission hemisphere.
  47267. */
  47268. radius?: number,
  47269. /**
  47270. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47271. */
  47272. radiusRange?: number,
  47273. /**
  47274. * How much to randomize the particle direction [0-1].
  47275. */
  47276. directionRandomizer?: number);
  47277. /**
  47278. * Called by the particle System when the direction is computed for the created particle.
  47279. * @param worldMatrix is the world matrix of the particle system
  47280. * @param directionToUpdate is the direction vector to update with the result
  47281. * @param particle is the particle we are computed the direction for
  47282. */
  47283. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47284. /**
  47285. * Called by the particle System when the position is computed for the created particle.
  47286. * @param worldMatrix is the world matrix of the particle system
  47287. * @param positionToUpdate is the position vector to update with the result
  47288. * @param particle is the particle we are computed the position for
  47289. */
  47290. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47291. /**
  47292. * Clones the current emitter and returns a copy of it
  47293. * @returns the new emitter
  47294. */
  47295. clone(): HemisphericParticleEmitter;
  47296. /**
  47297. * Called by the GPUParticleSystem to setup the update shader
  47298. * @param effect defines the update shader
  47299. */
  47300. applyToShader(effect: Effect): void;
  47301. /**
  47302. * Returns a string to use to update the GPU particles update shader
  47303. * @returns a string containng the defines string
  47304. */
  47305. getEffectDefines(): string;
  47306. /**
  47307. * Returns the string "HemisphericParticleEmitter"
  47308. * @returns a string containing the class name
  47309. */
  47310. getClassName(): string;
  47311. /**
  47312. * Serializes the particle system to a JSON object.
  47313. * @returns the JSON object
  47314. */
  47315. serialize(): any;
  47316. /**
  47317. * Parse properties from a JSON object
  47318. * @param serializationObject defines the JSON object
  47319. */
  47320. parse(serializationObject: any): void;
  47321. }
  47322. }
  47323. declare module BABYLON {
  47324. /**
  47325. * Particle emitter represents a volume emitting particles.
  47326. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  47327. */
  47328. interface IParticleEmitterType {
  47329. /**
  47330. * Called by the particle System when the direction is computed for the created particle.
  47331. * @param worldMatrix is the world matrix of the particle system
  47332. * @param directionToUpdate is the direction vector to update with the result
  47333. * @param particle is the particle we are computed the direction for
  47334. */
  47335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47336. /**
  47337. * Called by the particle System when the position is computed for the created particle.
  47338. * @param worldMatrix is the world matrix of the particle system
  47339. * @param positionToUpdate is the position vector to update with the result
  47340. * @param particle is the particle we are computed the position for
  47341. */
  47342. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47343. /**
  47344. * Clones the current emitter and returns a copy of it
  47345. * @returns the new emitter
  47346. */
  47347. clone(): IParticleEmitterType;
  47348. /**
  47349. * Called by the GPUParticleSystem to setup the update shader
  47350. * @param effect defines the update shader
  47351. */
  47352. applyToShader(effect: Effect): void;
  47353. /**
  47354. * Returns a string to use to update the GPU particles update shader
  47355. * @returns the effect defines string
  47356. */
  47357. getEffectDefines(): string;
  47358. /**
  47359. * Returns a string representing the class name
  47360. * @returns a string containing the class name
  47361. */
  47362. getClassName(): string;
  47363. /**
  47364. * Serializes the particle system to a JSON object.
  47365. * @returns the JSON object
  47366. */
  47367. serialize(): any;
  47368. /**
  47369. * Parse properties from a JSON object
  47370. * @param serializationObject defines the JSON object
  47371. */
  47372. parse(serializationObject: any): void;
  47373. }
  47374. }
  47375. declare module BABYLON {
  47376. /**
  47377. * Particle emitter emitting particles from a point.
  47378. * It emits the particles randomly between 2 given directions.
  47379. */
  47380. class PointParticleEmitter implements IParticleEmitterType {
  47381. /**
  47382. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47383. */
  47384. direction1: Vector3;
  47385. /**
  47386. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47387. */
  47388. direction2: Vector3;
  47389. /**
  47390. * Creates a new instance PointParticleEmitter
  47391. */
  47392. constructor();
  47393. /**
  47394. * Called by the particle System when the direction is computed for the created particle.
  47395. * @param worldMatrix is the world matrix of the particle system
  47396. * @param directionToUpdate is the direction vector to update with the result
  47397. * @param particle is the particle we are computed the direction for
  47398. */
  47399. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47400. /**
  47401. * Called by the particle System when the position is computed for the created particle.
  47402. * @param worldMatrix is the world matrix of the particle system
  47403. * @param positionToUpdate is the position vector to update with the result
  47404. * @param particle is the particle we are computed the position for
  47405. */
  47406. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47407. /**
  47408. * Clones the current emitter and returns a copy of it
  47409. * @returns the new emitter
  47410. */
  47411. clone(): PointParticleEmitter;
  47412. /**
  47413. * Called by the GPUParticleSystem to setup the update shader
  47414. * @param effect defines the update shader
  47415. */
  47416. applyToShader(effect: Effect): void;
  47417. /**
  47418. * Returns a string to use to update the GPU particles update shader
  47419. * @returns a string containng the defines string
  47420. */
  47421. getEffectDefines(): string;
  47422. /**
  47423. * Returns the string "PointParticleEmitter"
  47424. * @returns a string containing the class name
  47425. */
  47426. getClassName(): string;
  47427. /**
  47428. * Serializes the particle system to a JSON object.
  47429. * @returns the JSON object
  47430. */
  47431. serialize(): any;
  47432. /**
  47433. * Parse properties from a JSON object
  47434. * @param serializationObject defines the JSON object
  47435. */
  47436. parse(serializationObject: any): void;
  47437. }
  47438. }
  47439. declare module BABYLON {
  47440. /**
  47441. * Particle emitter emitting particles from the inside of a sphere.
  47442. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  47443. */
  47444. class SphereParticleEmitter implements IParticleEmitterType {
  47445. /**
  47446. * The radius of the emission sphere.
  47447. */
  47448. radius: number;
  47449. /**
  47450. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47451. */
  47452. radiusRange: number;
  47453. /**
  47454. * How much to randomize the particle direction [0-1].
  47455. */
  47456. directionRandomizer: number;
  47457. /**
  47458. * Creates a new instance SphereParticleEmitter
  47459. * @param radius the radius of the emission sphere (1 by default)
  47460. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47461. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47462. */
  47463. constructor(
  47464. /**
  47465. * The radius of the emission sphere.
  47466. */
  47467. radius?: number,
  47468. /**
  47469. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47470. */
  47471. radiusRange?: number,
  47472. /**
  47473. * How much to randomize the particle direction [0-1].
  47474. */
  47475. directionRandomizer?: number);
  47476. /**
  47477. * Called by the particle System when the direction is computed for the created particle.
  47478. * @param worldMatrix is the world matrix of the particle system
  47479. * @param directionToUpdate is the direction vector to update with the result
  47480. * @param particle is the particle we are computed the direction for
  47481. */
  47482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47483. /**
  47484. * Called by the particle System when the position is computed for the created particle.
  47485. * @param worldMatrix is the world matrix of the particle system
  47486. * @param positionToUpdate is the position vector to update with the result
  47487. * @param particle is the particle we are computed the position for
  47488. */
  47489. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47490. /**
  47491. * Clones the current emitter and returns a copy of it
  47492. * @returns the new emitter
  47493. */
  47494. clone(): SphereParticleEmitter;
  47495. /**
  47496. * Called by the GPUParticleSystem to setup the update shader
  47497. * @param effect defines the update shader
  47498. */
  47499. applyToShader(effect: Effect): void;
  47500. /**
  47501. * Returns a string to use to update the GPU particles update shader
  47502. * @returns a string containng the defines string
  47503. */
  47504. getEffectDefines(): string;
  47505. /**
  47506. * Returns the string "SphereParticleEmitter"
  47507. * @returns a string containing the class name
  47508. */
  47509. getClassName(): string;
  47510. /**
  47511. * Serializes the particle system to a JSON object.
  47512. * @returns the JSON object
  47513. */
  47514. serialize(): any;
  47515. /**
  47516. * Parse properties from a JSON object
  47517. * @param serializationObject defines the JSON object
  47518. */
  47519. parse(serializationObject: any): void;
  47520. }
  47521. /**
  47522. * Particle emitter emitting particles from the inside of a sphere.
  47523. * It emits the particles randomly between two vectors.
  47524. */
  47525. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  47526. /**
  47527. * The min limit of the emission direction.
  47528. */
  47529. direction1: Vector3;
  47530. /**
  47531. * The max limit of the emission direction.
  47532. */
  47533. direction2: Vector3;
  47534. /**
  47535. * Creates a new instance SphereDirectedParticleEmitter
  47536. * @param radius the radius of the emission sphere (1 by default)
  47537. * @param direction1 the min limit of the emission direction (up vector by default)
  47538. * @param direction2 the max limit of the emission direction (up vector by default)
  47539. */
  47540. constructor(radius?: number,
  47541. /**
  47542. * The min limit of the emission direction.
  47543. */
  47544. direction1?: Vector3,
  47545. /**
  47546. * The max limit of the emission direction.
  47547. */
  47548. direction2?: Vector3);
  47549. /**
  47550. * Called by the particle System when the direction is computed for the created particle.
  47551. * @param worldMatrix is the world matrix of the particle system
  47552. * @param directionToUpdate is the direction vector to update with the result
  47553. * @param particle is the particle we are computed the direction for
  47554. */
  47555. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47556. /**
  47557. * Clones the current emitter and returns a copy of it
  47558. * @returns the new emitter
  47559. */
  47560. clone(): SphereDirectedParticleEmitter;
  47561. /**
  47562. * Called by the GPUParticleSystem to setup the update shader
  47563. * @param effect defines the update shader
  47564. */
  47565. applyToShader(effect: Effect): void;
  47566. /**
  47567. * Returns a string to use to update the GPU particles update shader
  47568. * @returns a string containng the defines string
  47569. */
  47570. getEffectDefines(): string;
  47571. /**
  47572. * Returns the string "SphereDirectedParticleEmitter"
  47573. * @returns a string containing the class name
  47574. */
  47575. getClassName(): string;
  47576. /**
  47577. * Serializes the particle system to a JSON object.
  47578. * @returns the JSON object
  47579. */
  47580. serialize(): any;
  47581. /**
  47582. * Parse properties from a JSON object
  47583. * @param serializationObject defines the JSON object
  47584. */
  47585. parse(serializationObject: any): void;
  47586. }
  47587. }
  47588. declare module BABYLON {
  47589. /** @hidden */
  47590. class CannonJSPlugin implements IPhysicsEnginePlugin {
  47591. private _useDeltaForWorldStep;
  47592. world: any;
  47593. name: string;
  47594. private _physicsMaterials;
  47595. private _fixedTimeStep;
  47596. BJSCANNON: any;
  47597. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  47598. setGravity(gravity: Vector3): void;
  47599. setTimeStep(timeStep: number): void;
  47600. getTimeStep(): number;
  47601. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47602. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47603. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47604. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47605. private _processChildMeshes;
  47606. removePhysicsBody(impostor: PhysicsImpostor): void;
  47607. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47608. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47609. private _addMaterial;
  47610. private _checkWithEpsilon;
  47611. private _createShape;
  47612. private _createHeightmap;
  47613. private _minus90X;
  47614. private _plus90X;
  47615. private _tmpPosition;
  47616. private _tmpDeltaPosition;
  47617. private _tmpUnityRotation;
  47618. private _updatePhysicsBodyTransformation;
  47619. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47620. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47621. isSupported(): boolean;
  47622. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47623. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47624. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47625. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47626. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47627. getBodyMass(impostor: PhysicsImpostor): number;
  47628. getBodyFriction(impostor: PhysicsImpostor): number;
  47629. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47630. getBodyRestitution(impostor: PhysicsImpostor): number;
  47631. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47632. sleepBody(impostor: PhysicsImpostor): void;
  47633. wakeUpBody(impostor: PhysicsImpostor): void;
  47634. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47635. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47636. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47637. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47638. getRadius(impostor: PhysicsImpostor): number;
  47639. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47640. dispose(): void;
  47641. private _extendNamespace;
  47642. }
  47643. }
  47644. declare module BABYLON {
  47645. /** @hidden */
  47646. class OimoJSPlugin implements IPhysicsEnginePlugin {
  47647. world: any;
  47648. name: string;
  47649. BJSOIMO: any;
  47650. constructor(iterations?: number);
  47651. setGravity(gravity: Vector3): void;
  47652. setTimeStep(timeStep: number): void;
  47653. getTimeStep(): number;
  47654. private _tmpImpostorsArray;
  47655. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47656. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47657. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47658. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47659. private _tmpPositionVector;
  47660. removePhysicsBody(impostor: PhysicsImpostor): void;
  47661. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47662. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47663. isSupported(): boolean;
  47664. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47665. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47666. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47667. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47668. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47669. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47670. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47671. getBodyMass(impostor: PhysicsImpostor): number;
  47672. getBodyFriction(impostor: PhysicsImpostor): number;
  47673. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47674. getBodyRestitution(impostor: PhysicsImpostor): number;
  47675. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47676. sleepBody(impostor: PhysicsImpostor): void;
  47677. wakeUpBody(impostor: PhysicsImpostor): void;
  47678. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47679. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47680. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47681. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47682. getRadius(impostor: PhysicsImpostor): number;
  47683. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47684. dispose(): void;
  47685. }
  47686. }
  47687. declare module BABYLON {
  47688. /**
  47689. * This represents a set of one or more post processes in Babylon.
  47690. * A post process can be used to apply a shader to a texture after it is rendered.
  47691. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47692. */
  47693. class PostProcessRenderEffect {
  47694. private _postProcesses;
  47695. private _getPostProcesses;
  47696. private _singleInstance;
  47697. private _cameras;
  47698. private _indicesForCamera;
  47699. /**
  47700. * Name of the effect
  47701. * @hidden
  47702. */
  47703. _name: string;
  47704. /**
  47705. * Instantiates a post process render effect.
  47706. * A post process can be used to apply a shader to a texture after it is rendered.
  47707. * @param engine The engine the effect is tied to
  47708. * @param name The name of the effect
  47709. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  47710. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  47711. */
  47712. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  47713. /**
  47714. * Checks if all the post processes in the effect are supported.
  47715. */
  47716. readonly isSupported: boolean;
  47717. /**
  47718. * Updates the current state of the effect
  47719. * @hidden
  47720. */
  47721. _update(): void;
  47722. /**
  47723. * Attaches the effect on cameras
  47724. * @param cameras The camera to attach to.
  47725. * @hidden
  47726. */
  47727. _attachCameras(cameras: Camera): void;
  47728. /**
  47729. * Attaches the effect on cameras
  47730. * @param cameras The camera to attach to.
  47731. * @hidden
  47732. */
  47733. _attachCameras(cameras: Camera[]): void;
  47734. /**
  47735. * Detatches the effect on cameras
  47736. * @param cameras The camera to detatch from.
  47737. * @hidden
  47738. */
  47739. _detachCameras(cameras: Camera): void;
  47740. /**
  47741. * Detatches the effect on cameras
  47742. * @param cameras The camera to detatch from.
  47743. * @hidden
  47744. */
  47745. _detachCameras(cameras: Camera[]): void;
  47746. /**
  47747. * Enables the effect on given cameras
  47748. * @param cameras The camera to enable.
  47749. * @hidden
  47750. */
  47751. _enable(cameras: Camera): void;
  47752. /**
  47753. * Enables the effect on given cameras
  47754. * @param cameras The camera to enable.
  47755. * @hidden
  47756. */
  47757. _enable(cameras: Nullable<Camera[]>): void;
  47758. /**
  47759. * Disables the effect on the given cameras
  47760. * @param cameras The camera to disable.
  47761. * @hidden
  47762. */
  47763. _disable(cameras: Camera): void;
  47764. /**
  47765. * Disables the effect on the given cameras
  47766. * @param cameras The camera to disable.
  47767. * @hidden
  47768. */
  47769. _disable(cameras: Nullable<Camera[]>): void;
  47770. /**
  47771. * Gets a list of the post processes contained in the effect.
  47772. * @param camera The camera to get the post processes on.
  47773. * @returns The list of the post processes in the effect.
  47774. */
  47775. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  47776. }
  47777. }
  47778. declare module BABYLON {
  47779. /**
  47780. * PostProcessRenderPipeline
  47781. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47782. */
  47783. class PostProcessRenderPipeline {
  47784. private engine;
  47785. private _renderEffects;
  47786. private _renderEffectsForIsolatedPass;
  47787. /**
  47788. * @hidden
  47789. */
  47790. protected _cameras: Camera[];
  47791. /** @hidden */
  47792. _name: string;
  47793. /**
  47794. * Initializes a PostProcessRenderPipeline
  47795. * @param engine engine to add the pipeline to
  47796. * @param name name of the pipeline
  47797. */
  47798. constructor(engine: Engine, name: string);
  47799. /**
  47800. * "PostProcessRenderPipeline"
  47801. * @returns "PostProcessRenderPipeline"
  47802. */
  47803. getClassName(): string;
  47804. /**
  47805. * If all the render effects in the pipeline are support
  47806. */
  47807. readonly isSupported: boolean;
  47808. /**
  47809. * Adds an effect to the pipeline
  47810. * @param renderEffect the effect to add
  47811. */
  47812. addEffect(renderEffect: PostProcessRenderEffect): void;
  47813. /** @hidden */
  47814. _rebuild(): void;
  47815. /** @hidden */
  47816. _enableEffect(renderEffectName: string, cameras: Camera): void;
  47817. /** @hidden */
  47818. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  47819. /** @hidden */
  47820. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  47821. /** @hidden */
  47822. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  47823. /** @hidden */
  47824. _attachCameras(cameras: Camera, unique: boolean): void;
  47825. /** @hidden */
  47826. _attachCameras(cameras: Camera[], unique: boolean): void;
  47827. /** @hidden */
  47828. _detachCameras(cameras: Camera): void;
  47829. /** @hidden */
  47830. _detachCameras(cameras: Nullable<Camera[]>): void;
  47831. /** @hidden */
  47832. _update(): void;
  47833. /** @hidden */
  47834. _reset(): void;
  47835. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  47836. /**
  47837. * Disposes of the pipeline
  47838. */
  47839. dispose(): void;
  47840. }
  47841. }
  47842. declare module BABYLON {
  47843. /**
  47844. * PostProcessRenderPipelineManager class
  47845. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47846. */
  47847. class PostProcessRenderPipelineManager {
  47848. private _renderPipelines;
  47849. /**
  47850. * Initializes a PostProcessRenderPipelineManager
  47851. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47852. */
  47853. constructor();
  47854. /**
  47855. * Adds a pipeline to the manager
  47856. * @param renderPipeline The pipeline to add
  47857. */
  47858. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  47859. /**
  47860. * Attaches a camera to the pipeline
  47861. * @param renderPipelineName The name of the pipeline to attach to
  47862. * @param cameras the camera to attach
  47863. * @param unique if the camera can be attached multiple times to the pipeline
  47864. */
  47865. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  47866. /**
  47867. * Detaches a camera from the pipeline
  47868. * @param renderPipelineName The name of the pipeline to detach from
  47869. * @param cameras the camera to detach
  47870. */
  47871. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  47872. /**
  47873. * Enables an effect by name on a pipeline
  47874. * @param renderPipelineName the name of the pipeline to enable the effect in
  47875. * @param renderEffectName the name of the effect to enable
  47876. * @param cameras the cameras that the effect should be enabled on
  47877. */
  47878. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  47879. /**
  47880. * Disables an effect by name on a pipeline
  47881. * @param renderPipelineName the name of the pipeline to disable the effect in
  47882. * @param renderEffectName the name of the effect to disable
  47883. * @param cameras the cameras that the effect should be disabled on
  47884. */
  47885. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  47886. /**
  47887. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  47888. */
  47889. update(): void;
  47890. /** @hidden */
  47891. _rebuild(): void;
  47892. /**
  47893. * Disposes of the manager and pipelines
  47894. */
  47895. dispose(): void;
  47896. }
  47897. }
  47898. declare module BABYLON {
  47899. interface Scene {
  47900. /** @hidden (Backing field) */
  47901. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  47902. /**
  47903. * Gets the postprocess render pipeline manager
  47904. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47905. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  47906. */
  47907. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  47908. }
  47909. /**
  47910. * Defines the Render Pipeline scene component responsible to rendering pipelines
  47911. */
  47912. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  47913. /**
  47914. * The component name helpfull to identify the component in the list of scene components.
  47915. */
  47916. readonly name: string;
  47917. /**
  47918. * The scene the component belongs to.
  47919. */
  47920. scene: Scene;
  47921. /**
  47922. * Creates a new instance of the component for the given scene
  47923. * @param scene Defines the scene to register the component in
  47924. */
  47925. constructor(scene: Scene);
  47926. /**
  47927. * Registers the component in a given scene
  47928. */
  47929. register(): void;
  47930. /**
  47931. * Rebuilds the elements related to this component in case of
  47932. * context lost for instance.
  47933. */
  47934. rebuild(): void;
  47935. /**
  47936. * Disposes the component and the associated ressources
  47937. */
  47938. dispose(): void;
  47939. private _gatherRenderTargets;
  47940. }
  47941. }
  47942. declare module BABYLON {
  47943. /**
  47944. * Helper class dealing with the extraction of spherical polynomial dataArray
  47945. * from a cube map.
  47946. */
  47947. class CubeMapToSphericalPolynomialTools {
  47948. private static FileFaces;
  47949. /**
  47950. * Converts a texture to the according Spherical Polynomial data.
  47951. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47952. *
  47953. * @param texture The texture to extract the information from.
  47954. * @return The Spherical Polynomial data.
  47955. */
  47956. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47957. /**
  47958. * Converts a cubemap to the according Spherical Polynomial data.
  47959. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47960. *
  47961. * @param cubeInfo The Cube map to extract the information from.
  47962. * @return The Spherical Polynomial data.
  47963. */
  47964. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47965. }
  47966. }
  47967. declare module BABYLON {
  47968. /**
  47969. * Header information of HDR texture files.
  47970. */
  47971. interface HDRInfo {
  47972. /**
  47973. * The height of the texture in pixels.
  47974. */
  47975. height: number;
  47976. /**
  47977. * The width of the texture in pixels.
  47978. */
  47979. width: number;
  47980. /**
  47981. * The index of the beginning of the data in the binary file.
  47982. */
  47983. dataPosition: number;
  47984. }
  47985. /**
  47986. * This groups tools to convert HDR texture to native colors array.
  47987. */
  47988. class HDRTools {
  47989. private static Ldexp;
  47990. private static Rgbe2float;
  47991. private static readStringLine;
  47992. /**
  47993. * Reads header information from an RGBE texture stored in a native array.
  47994. * More information on this format are available here:
  47995. * https://en.wikipedia.org/wiki/RGBE_image_format
  47996. *
  47997. * @param uint8array The binary file stored in native array.
  47998. * @return The header information.
  47999. */
  48000. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48001. /**
  48002. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48003. * This RGBE texture needs to store the information as a panorama.
  48004. *
  48005. * More information on this format are available here:
  48006. * https://en.wikipedia.org/wiki/RGBE_image_format
  48007. *
  48008. * @param buffer The binary file stored in an array buffer.
  48009. * @param size The expected size of the extracted cubemap.
  48010. * @return The Cube Map information.
  48011. */
  48012. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48013. /**
  48014. * Returns the pixels data extracted from an RGBE texture.
  48015. * This pixels will be stored left to right up to down in the R G B order in one array.
  48016. *
  48017. * More information on this format are available here:
  48018. * https://en.wikipedia.org/wiki/RGBE_image_format
  48019. *
  48020. * @param uint8array The binary file stored in an array buffer.
  48021. * @param hdrInfo The header information of the file.
  48022. * @return The pixels data in RGB right to left up to down order.
  48023. */
  48024. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48025. private static RGBE_ReadPixels_RLE;
  48026. }
  48027. }
  48028. declare module BABYLON {
  48029. /**
  48030. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48031. */
  48032. interface CubeMapInfo {
  48033. /**
  48034. * The pixel array for the front face.
  48035. * This is stored in format, left to right, up to down format.
  48036. */
  48037. front: Nullable<ArrayBufferView>;
  48038. /**
  48039. * The pixel array for the back face.
  48040. * This is stored in format, left to right, up to down format.
  48041. */
  48042. back: Nullable<ArrayBufferView>;
  48043. /**
  48044. * The pixel array for the left face.
  48045. * This is stored in format, left to right, up to down format.
  48046. */
  48047. left: Nullable<ArrayBufferView>;
  48048. /**
  48049. * The pixel array for the right face.
  48050. * This is stored in format, left to right, up to down format.
  48051. */
  48052. right: Nullable<ArrayBufferView>;
  48053. /**
  48054. * The pixel array for the up face.
  48055. * This is stored in format, left to right, up to down format.
  48056. */
  48057. up: Nullable<ArrayBufferView>;
  48058. /**
  48059. * The pixel array for the down face.
  48060. * This is stored in format, left to right, up to down format.
  48061. */
  48062. down: Nullable<ArrayBufferView>;
  48063. /**
  48064. * The size of the cubemap stored.
  48065. *
  48066. * Each faces will be size * size pixels.
  48067. */
  48068. size: number;
  48069. /**
  48070. * The format of the texture.
  48071. *
  48072. * RGBA, RGB.
  48073. */
  48074. format: number;
  48075. /**
  48076. * The type of the texture data.
  48077. *
  48078. * UNSIGNED_INT, FLOAT.
  48079. */
  48080. type: number;
  48081. /**
  48082. * Specifies whether the texture is in gamma space.
  48083. */
  48084. gammaSpace: boolean;
  48085. }
  48086. /**
  48087. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  48088. */
  48089. class PanoramaToCubeMapTools {
  48090. private static FACE_FRONT;
  48091. private static FACE_BACK;
  48092. private static FACE_RIGHT;
  48093. private static FACE_LEFT;
  48094. private static FACE_DOWN;
  48095. private static FACE_UP;
  48096. /**
  48097. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48098. *
  48099. * @param float32Array The source data.
  48100. * @param inputWidth The width of the input panorama.
  48101. * @param inputHeight The height of the input panorama.
  48102. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48103. * @return The cubemap data
  48104. */
  48105. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48106. private static CreateCubemapTexture;
  48107. private static CalcProjectionSpherical;
  48108. }
  48109. }
  48110. declare module BABYLON {
  48111. }
  48112. declare module BABYLON {
  48113. }
  48114. declare module BABYLON {
  48115. }
  48116. declare module BABYLON {
  48117. }
  48118. declare module BABYLON {
  48119. /**
  48120. * 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.
  48121. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48122. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48123. */
  48124. class CustomProceduralTexture extends ProceduralTexture {
  48125. private _animate;
  48126. private _time;
  48127. private _config;
  48128. private _texturePath;
  48129. /**
  48130. * Instantiates a new Custom Procedural Texture.
  48131. * 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.
  48132. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48133. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48134. * @param name Define the name of the texture
  48135. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48136. * @param size Define the size of the texture to create
  48137. * @param scene Define the scene the texture belongs to
  48138. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48139. * @param generateMipMaps Define if the texture should creates mip maps or not
  48140. */
  48141. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48142. private _loadJson;
  48143. /**
  48144. * Is the texture ready to be used ? (rendered at least once)
  48145. * @returns true if ready, otherwise, false.
  48146. */
  48147. isReady(): boolean;
  48148. /**
  48149. * Render the texture to its associated render target.
  48150. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48151. */
  48152. render(useCameraPostProcess?: boolean): void;
  48153. /**
  48154. * Update the list of dependant textures samplers in the shader.
  48155. */
  48156. updateTextures(): void;
  48157. /**
  48158. * Update the uniform values of the procedural texture in the shader.
  48159. */
  48160. updateShaderUniforms(): void;
  48161. /**
  48162. * Define if the texture animates or not.
  48163. */
  48164. animate: boolean;
  48165. }
  48166. }
  48167. declare module BABYLON {
  48168. /**
  48169. * Class used to generate noise procedural textures
  48170. */
  48171. class NoiseProceduralTexture extends ProceduralTexture {
  48172. private _time;
  48173. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48174. brightness: number;
  48175. /** Defines the number of octaves to process */
  48176. octaves: number;
  48177. /** Defines the level of persistence (0.8 by default) */
  48178. persistence: number;
  48179. /** Gets or sets animation speed factor (default is 1) */
  48180. animationSpeedFactor: number;
  48181. /**
  48182. * Creates a new NoiseProceduralTexture
  48183. * @param name defines the name fo the texture
  48184. * @param size defines the size of the texture (default is 256)
  48185. * @param scene defines the hosting scene
  48186. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48187. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48188. */
  48189. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48190. private _updateShaderUniforms;
  48191. protected _getDefines(): string;
  48192. /** Generate the current state of the procedural texture */
  48193. render(useCameraPostProcess?: boolean): void;
  48194. /**
  48195. * Serializes this noise procedural texture
  48196. * @returns a serialized noise procedural texture object
  48197. */
  48198. serialize(): any;
  48199. /**
  48200. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48201. * @param parsedTexture defines parsed texture data
  48202. * @param scene defines the current scene
  48203. * @param rootUrl defines the root URL containing noise procedural texture information
  48204. * @returns a parsed NoiseProceduralTexture
  48205. */
  48206. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  48207. }
  48208. }
  48209. declare module BABYLON {
  48210. /**
  48211. * 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.
  48212. * This is the base class of any Procedural texture and contains most of the shareable code.
  48213. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48214. */
  48215. class ProceduralTexture extends Texture {
  48216. isCube: boolean;
  48217. /**
  48218. * Define if the texture is enabled or not (disabled texture will not render)
  48219. */
  48220. isEnabled: boolean;
  48221. /**
  48222. * Callback called when the texture is generated
  48223. */
  48224. onGenerated: () => void;
  48225. /**
  48226. * Event raised when the texture is generated
  48227. */
  48228. onGeneratedObservable: Observable<ProceduralTexture>;
  48229. /** @hidden */
  48230. _generateMipMaps: boolean;
  48231. /** @hidden **/
  48232. _effect: Effect;
  48233. /** @hidden */
  48234. _textures: {
  48235. [key: string]: Texture;
  48236. };
  48237. private _size;
  48238. private _currentRefreshId;
  48239. private _refreshRate;
  48240. private _vertexBuffers;
  48241. private _indexBuffer;
  48242. private _uniforms;
  48243. private _samplers;
  48244. private _fragment;
  48245. private _floats;
  48246. private _ints;
  48247. private _floatsArrays;
  48248. private _colors3;
  48249. private _colors4;
  48250. private _vectors2;
  48251. private _vectors3;
  48252. private _matrices;
  48253. private _fallbackTexture;
  48254. private _fallbackTextureUsed;
  48255. private _engine;
  48256. private _cachedDefines;
  48257. private _contentUpdateId;
  48258. private _contentData;
  48259. /**
  48260. * Instantiates a new procedural texture.
  48261. * 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.
  48262. * This is the base class of any Procedural texture and contains most of the shareable code.
  48263. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48264. * @param name Define the name of the texture
  48265. * @param size Define the size of the texture to create
  48266. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  48267. * @param scene Define the scene the texture belongs to
  48268. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48269. * @param generateMipMaps Define if the texture should creates mip maps or not
  48270. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  48271. */
  48272. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  48273. /**
  48274. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  48275. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  48276. */
  48277. getContent(): Nullable<ArrayBufferView>;
  48278. private _createIndexBuffer;
  48279. /** @hidden */
  48280. _rebuild(): void;
  48281. /**
  48282. * Resets the texture in order to recreate its associated resources.
  48283. * This can be called in case of context loss
  48284. */
  48285. reset(): void;
  48286. protected _getDefines(): string;
  48287. /**
  48288. * Is the texture ready to be used ? (rendered at least once)
  48289. * @returns true if ready, otherwise, false.
  48290. */
  48291. isReady(): boolean;
  48292. /**
  48293. * Resets the refresh counter of the texture and start bak from scratch.
  48294. * Could be usefull to regenerate the texture if it is setup to render only once.
  48295. */
  48296. resetRefreshCounter(): void;
  48297. /**
  48298. * Set the fragment shader to use in order to render the texture.
  48299. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  48300. */
  48301. setFragment(fragment: any): void;
  48302. /**
  48303. * Define the refresh rate of the texture or the rendering frequency.
  48304. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48305. */
  48306. refreshRate: number;
  48307. /** @hidden */
  48308. _shouldRender(): boolean;
  48309. /**
  48310. * Get the size the texture is rendering at.
  48311. * @returns the size (texture is always squared)
  48312. */
  48313. getRenderSize(): number;
  48314. /**
  48315. * Resize the texture to new value.
  48316. * @param size Define the new size the texture should have
  48317. * @param generateMipMaps Define whether the new texture should create mip maps
  48318. */
  48319. resize(size: number, generateMipMaps: boolean): void;
  48320. private _checkUniform;
  48321. /**
  48322. * Set a texture in the shader program used to render.
  48323. * @param name Define the name of the uniform samplers as defined in the shader
  48324. * @param texture Define the texture to bind to this sampler
  48325. * @return the texture itself allowing "fluent" like uniform updates
  48326. */
  48327. setTexture(name: string, texture: Texture): ProceduralTexture;
  48328. /**
  48329. * Set a float in the shader.
  48330. * @param name Define the name of the uniform as defined in the shader
  48331. * @param value Define the value to give to the uniform
  48332. * @return the texture itself allowing "fluent" like uniform updates
  48333. */
  48334. setFloat(name: string, value: number): ProceduralTexture;
  48335. /**
  48336. * Set a int in the shader.
  48337. * @param name Define the name of the uniform as defined in the shader
  48338. * @param value Define the value to give to the uniform
  48339. * @return the texture itself allowing "fluent" like uniform updates
  48340. */
  48341. setInt(name: string, value: number): ProceduralTexture;
  48342. /**
  48343. * Set an array of floats in the shader.
  48344. * @param name Define the name of the uniform as defined in the shader
  48345. * @param value Define the value to give to the uniform
  48346. * @return the texture itself allowing "fluent" like uniform updates
  48347. */
  48348. setFloats(name: string, value: number[]): ProceduralTexture;
  48349. /**
  48350. * Set a vec3 in the shader from a Color3.
  48351. * @param name Define the name of the uniform as defined in the shader
  48352. * @param value Define the value to give to the uniform
  48353. * @return the texture itself allowing "fluent" like uniform updates
  48354. */
  48355. setColor3(name: string, value: Color3): ProceduralTexture;
  48356. /**
  48357. * Set a vec4 in the shader from a Color4.
  48358. * @param name Define the name of the uniform as defined in the shader
  48359. * @param value Define the value to give to the uniform
  48360. * @return the texture itself allowing "fluent" like uniform updates
  48361. */
  48362. setColor4(name: string, value: Color4): ProceduralTexture;
  48363. /**
  48364. * Set a vec2 in the shader from a Vector2.
  48365. * @param name Define the name of the uniform as defined in the shader
  48366. * @param value Define the value to give to the uniform
  48367. * @return the texture itself allowing "fluent" like uniform updates
  48368. */
  48369. setVector2(name: string, value: Vector2): ProceduralTexture;
  48370. /**
  48371. * Set a vec3 in the shader from a Vector3.
  48372. * @param name Define the name of the uniform as defined in the shader
  48373. * @param value Define the value to give to the uniform
  48374. * @return the texture itself allowing "fluent" like uniform updates
  48375. */
  48376. setVector3(name: string, value: Vector3): ProceduralTexture;
  48377. /**
  48378. * Set a mat4 in the shader from a MAtrix.
  48379. * @param name Define the name of the uniform as defined in the shader
  48380. * @param value Define the value to give to the uniform
  48381. * @return the texture itself allowing "fluent" like uniform updates
  48382. */
  48383. setMatrix(name: string, value: Matrix): ProceduralTexture;
  48384. /**
  48385. * Render the texture to its associated render target.
  48386. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48387. */
  48388. render(useCameraPostProcess?: boolean): void;
  48389. /**
  48390. * Clone the texture.
  48391. * @returns the cloned texture
  48392. */
  48393. clone(): ProceduralTexture;
  48394. /**
  48395. * Dispose the texture and release its asoociated resources.
  48396. */
  48397. dispose(): void;
  48398. }
  48399. }
  48400. declare module BABYLON {
  48401. interface AbstractScene {
  48402. /**
  48403. * The list of procedural textures added to the scene
  48404. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48405. */
  48406. proceduralTextures: Array<ProceduralTexture>;
  48407. }
  48408. /**
  48409. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  48410. * in a given scene.
  48411. */
  48412. class ProceduralTextureSceneComponent implements ISceneComponent {
  48413. /**
  48414. * The component name helpfull to identify the component in the list of scene components.
  48415. */
  48416. readonly name: string;
  48417. /**
  48418. * The scene the component belongs to.
  48419. */
  48420. scene: Scene;
  48421. /**
  48422. * Creates a new instance of the component for the given scene
  48423. * @param scene Defines the scene to register the component in
  48424. */
  48425. constructor(scene: Scene);
  48426. /**
  48427. * Registers the component in a given scene
  48428. */
  48429. register(): void;
  48430. /**
  48431. * Rebuilds the elements related to this component in case of
  48432. * context lost for instance.
  48433. */
  48434. rebuild(): void;
  48435. /**
  48436. * Disposes the component and the associated ressources.
  48437. */
  48438. dispose(): void;
  48439. private _beforeClear;
  48440. }
  48441. }
  48442. declare module BABYLON {
  48443. /**
  48444. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  48445. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  48446. */
  48447. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  48448. private _scene;
  48449. private _camerasToBeAttached;
  48450. /**
  48451. * ID of the sharpen post process,
  48452. */
  48453. private readonly SharpenPostProcessId;
  48454. /**
  48455. * @ignore
  48456. * ID of the image processing post process;
  48457. */
  48458. readonly ImageProcessingPostProcessId: string;
  48459. /**
  48460. * @ignore
  48461. * ID of the Fast Approximate Anti-Aliasing post process;
  48462. */
  48463. readonly FxaaPostProcessId: string;
  48464. /**
  48465. * ID of the chromatic aberration post process,
  48466. */
  48467. private readonly ChromaticAberrationPostProcessId;
  48468. /**
  48469. * ID of the grain post process
  48470. */
  48471. private readonly GrainPostProcessId;
  48472. /**
  48473. * Sharpen post process which will apply a sharpen convolution to enhance edges
  48474. */
  48475. sharpen: SharpenPostProcess;
  48476. private _sharpenEffect;
  48477. private bloom;
  48478. /**
  48479. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  48480. */
  48481. depthOfField: DepthOfFieldEffect;
  48482. /**
  48483. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  48484. */
  48485. fxaa: FxaaPostProcess;
  48486. /**
  48487. * Image post processing pass used to perform operations such as tone mapping or color grading.
  48488. */
  48489. imageProcessing: ImageProcessingPostProcess;
  48490. /**
  48491. * Chromatic aberration post process which will shift rgb colors in the image
  48492. */
  48493. chromaticAberration: ChromaticAberrationPostProcess;
  48494. private _chromaticAberrationEffect;
  48495. /**
  48496. * Grain post process which add noise to the image
  48497. */
  48498. grain: GrainPostProcess;
  48499. private _grainEffect;
  48500. /**
  48501. * Glow post process which adds a glow to emmisive areas of the image
  48502. */
  48503. private _glowLayer;
  48504. /**
  48505. * Animations which can be used to tweak settings over a period of time
  48506. */
  48507. animations: Animation[];
  48508. private _imageProcessingConfigurationObserver;
  48509. private _sharpenEnabled;
  48510. private _bloomEnabled;
  48511. private _depthOfFieldEnabled;
  48512. private _depthOfFieldBlurLevel;
  48513. private _fxaaEnabled;
  48514. private _imageProcessingEnabled;
  48515. private _defaultPipelineTextureType;
  48516. private _bloomScale;
  48517. private _chromaticAberrationEnabled;
  48518. private _grainEnabled;
  48519. private _buildAllowed;
  48520. /**
  48521. * Enable or disable the sharpen process from the pipeline
  48522. */
  48523. sharpenEnabled: boolean;
  48524. private _resizeObserver;
  48525. private _hardwareScaleLevel;
  48526. private _bloomKernel;
  48527. /**
  48528. * Specifies the size of the bloom blur kernel, relative to the final output size
  48529. */
  48530. bloomKernel: number;
  48531. /**
  48532. * Specifies the weight of the bloom in the final rendering
  48533. */
  48534. private _bloomWeight;
  48535. /**
  48536. * Specifies the luma threshold for the area that will be blurred by the bloom
  48537. */
  48538. private _bloomThreshold;
  48539. private _hdr;
  48540. /**
  48541. * The strength of the bloom.
  48542. */
  48543. bloomWeight: number;
  48544. /**
  48545. * The strength of the bloom.
  48546. */
  48547. bloomThreshold: number;
  48548. /**
  48549. * The scale of the bloom, lower value will provide better performance.
  48550. */
  48551. bloomScale: number;
  48552. /**
  48553. * Enable or disable the bloom from the pipeline
  48554. */
  48555. bloomEnabled: boolean;
  48556. private _rebuildBloom;
  48557. /**
  48558. * If the depth of field is enabled.
  48559. */
  48560. depthOfFieldEnabled: boolean;
  48561. /**
  48562. * Blur level of the depth of field effect. (Higher blur will effect performance)
  48563. */
  48564. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  48565. /**
  48566. * If the anti aliasing is enabled.
  48567. */
  48568. fxaaEnabled: boolean;
  48569. private _samples;
  48570. /**
  48571. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  48572. */
  48573. samples: number;
  48574. /**
  48575. * If image processing is enabled.
  48576. */
  48577. imageProcessingEnabled: boolean;
  48578. /**
  48579. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  48580. */
  48581. glowLayerEnabled: boolean;
  48582. /**
  48583. * Enable or disable the chromaticAberration process from the pipeline
  48584. */
  48585. chromaticAberrationEnabled: boolean;
  48586. /**
  48587. * Enable or disable the grain process from the pipeline
  48588. */
  48589. grainEnabled: boolean;
  48590. /**
  48591. * @constructor
  48592. * @param name - The rendering pipeline name (default: "")
  48593. * @param hdr - If high dynamic range textures should be used (default: true)
  48594. * @param scene - The scene linked to this pipeline (default: the last created scene)
  48595. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  48596. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  48597. */
  48598. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  48599. /**
  48600. * Force the compilation of the entire pipeline.
  48601. */
  48602. prepare(): void;
  48603. private _hasCleared;
  48604. private _prevPostProcess;
  48605. private _prevPrevPostProcess;
  48606. private _setAutoClearAndTextureSharing;
  48607. private _depthOfFieldSceneObserver;
  48608. private _buildPipeline;
  48609. private _disposePostProcesses;
  48610. /**
  48611. * Adds a camera to the pipeline
  48612. * @param camera the camera to be added
  48613. */
  48614. addCamera(camera: Camera): void;
  48615. /**
  48616. * Removes a camera from the pipeline
  48617. * @param camera the camera to remove
  48618. */
  48619. removeCamera(camera: Camera): void;
  48620. /**
  48621. * Dispose of the pipeline and stop all post processes
  48622. */
  48623. dispose(): void;
  48624. /**
  48625. * Serialize the rendering pipeline (Used when exporting)
  48626. * @returns the serialized object
  48627. */
  48628. serialize(): any;
  48629. /**
  48630. * Parse the serialized pipeline
  48631. * @param source Source pipeline.
  48632. * @param scene The scene to load the pipeline to.
  48633. * @param rootUrl The URL of the serialized pipeline.
  48634. * @returns An instantiated pipeline from the serialized object.
  48635. */
  48636. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  48637. }
  48638. }
  48639. declare module BABYLON {
  48640. /**
  48641. * BABYLON.JS Chromatic Aberration GLSL Shader
  48642. * Author: Olivier Guyot
  48643. * Separates very slightly R, G and B colors on the edges of the screen
  48644. * Inspired by Francois Tarlier & Martins Upitis
  48645. */
  48646. class LensRenderingPipeline extends PostProcessRenderPipeline {
  48647. /**
  48648. * @ignore
  48649. * The chromatic aberration PostProcess id in the pipeline
  48650. */
  48651. LensChromaticAberrationEffect: string;
  48652. /**
  48653. * @ignore
  48654. * The highlights enhancing PostProcess id in the pipeline
  48655. */
  48656. HighlightsEnhancingEffect: string;
  48657. /**
  48658. * @ignore
  48659. * The depth-of-field PostProcess id in the pipeline
  48660. */
  48661. LensDepthOfFieldEffect: string;
  48662. private _scene;
  48663. private _depthTexture;
  48664. private _grainTexture;
  48665. private _chromaticAberrationPostProcess;
  48666. private _highlightsPostProcess;
  48667. private _depthOfFieldPostProcess;
  48668. private _edgeBlur;
  48669. private _grainAmount;
  48670. private _chromaticAberration;
  48671. private _distortion;
  48672. private _highlightsGain;
  48673. private _highlightsThreshold;
  48674. private _dofDistance;
  48675. private _dofAperture;
  48676. private _dofDarken;
  48677. private _dofPentagon;
  48678. private _blurNoise;
  48679. /**
  48680. * @constructor
  48681. *
  48682. * Effect parameters are as follow:
  48683. * {
  48684. * chromatic_aberration: number; // from 0 to x (1 for realism)
  48685. * edge_blur: number; // from 0 to x (1 for realism)
  48686. * distortion: number; // from 0 to x (1 for realism)
  48687. * grain_amount: number; // from 0 to 1
  48688. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  48689. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  48690. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  48691. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  48692. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  48693. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  48694. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  48695. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  48696. * }
  48697. * Note: if an effect parameter is unset, effect is disabled
  48698. *
  48699. * @param name The rendering pipeline name
  48700. * @param parameters - An object containing all parameters (see above)
  48701. * @param scene The scene linked to this pipeline
  48702. * @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)
  48703. * @param cameras The array of cameras that the rendering pipeline will be attached to
  48704. */
  48705. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  48706. /**
  48707. * Sets the amount of blur at the edges
  48708. * @param amount blur amount
  48709. */
  48710. setEdgeBlur(amount: number): void;
  48711. /**
  48712. * Sets edge blur to 0
  48713. */
  48714. disableEdgeBlur(): void;
  48715. /**
  48716. * Sets the amout of grain
  48717. * @param amount Amount of grain
  48718. */
  48719. setGrainAmount(amount: number): void;
  48720. /**
  48721. * Set grain amount to 0
  48722. */
  48723. disableGrain(): void;
  48724. /**
  48725. * Sets the chromatic aberration amount
  48726. * @param amount amount of chromatic aberration
  48727. */
  48728. setChromaticAberration(amount: number): void;
  48729. /**
  48730. * Sets chromatic aberration amount to 0
  48731. */
  48732. disableChromaticAberration(): void;
  48733. /**
  48734. * Sets the EdgeDistortion amount
  48735. * @param amount amount of EdgeDistortion
  48736. */
  48737. setEdgeDistortion(amount: number): void;
  48738. /**
  48739. * Sets edge distortion to 0
  48740. */
  48741. disableEdgeDistortion(): void;
  48742. /**
  48743. * Sets the FocusDistance amount
  48744. * @param amount amount of FocusDistance
  48745. */
  48746. setFocusDistance(amount: number): void;
  48747. /**
  48748. * Disables depth of field
  48749. */
  48750. disableDepthOfField(): void;
  48751. /**
  48752. * Sets the Aperture amount
  48753. * @param amount amount of Aperture
  48754. */
  48755. setAperture(amount: number): void;
  48756. /**
  48757. * Sets the DarkenOutOfFocus amount
  48758. * @param amount amount of DarkenOutOfFocus
  48759. */
  48760. setDarkenOutOfFocus(amount: number): void;
  48761. /**
  48762. * Creates a pentagon bokeh effect
  48763. */
  48764. enablePentagonBokeh(): void;
  48765. /**
  48766. * Disables the pentagon bokeh effect
  48767. */
  48768. disablePentagonBokeh(): void;
  48769. /**
  48770. * Enables noise blur
  48771. */
  48772. enableNoiseBlur(): void;
  48773. /**
  48774. * Disables noise blur
  48775. */
  48776. disableNoiseBlur(): void;
  48777. /**
  48778. * Sets the HighlightsGain amount
  48779. * @param amount amount of HighlightsGain
  48780. */
  48781. setHighlightsGain(amount: number): void;
  48782. /**
  48783. * Sets the HighlightsThreshold amount
  48784. * @param amount amount of HighlightsThreshold
  48785. */
  48786. setHighlightsThreshold(amount: number): void;
  48787. /**
  48788. * Disables highlights
  48789. */
  48790. disableHighlights(): void;
  48791. /**
  48792. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  48793. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  48794. */
  48795. dispose(disableDepthRender?: boolean): void;
  48796. private _createChromaticAberrationPostProcess;
  48797. private _createHighlightsPostProcess;
  48798. private _createDepthOfFieldPostProcess;
  48799. private _createGrainTexture;
  48800. }
  48801. }
  48802. declare module BABYLON {
  48803. /**
  48804. * Render pipeline to produce ssao effect
  48805. */
  48806. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  48807. /**
  48808. * @ignore
  48809. * The PassPostProcess id in the pipeline that contains the original scene color
  48810. */
  48811. SSAOOriginalSceneColorEffect: string;
  48812. /**
  48813. * @ignore
  48814. * The SSAO PostProcess id in the pipeline
  48815. */
  48816. SSAORenderEffect: string;
  48817. /**
  48818. * @ignore
  48819. * The horizontal blur PostProcess id in the pipeline
  48820. */
  48821. SSAOBlurHRenderEffect: string;
  48822. /**
  48823. * @ignore
  48824. * The vertical blur PostProcess id in the pipeline
  48825. */
  48826. SSAOBlurVRenderEffect: string;
  48827. /**
  48828. * @ignore
  48829. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  48830. */
  48831. SSAOCombineRenderEffect: string;
  48832. /**
  48833. * The output strength of the SSAO post-process. Default value is 1.0.
  48834. */
  48835. totalStrength: number;
  48836. /**
  48837. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  48838. */
  48839. maxZ: number;
  48840. /**
  48841. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  48842. */
  48843. minZAspect: number;
  48844. private _samples;
  48845. /**
  48846. * Number of samples used for the SSAO calculations. Default value is 8
  48847. */
  48848. samples: number;
  48849. private _textureSamples;
  48850. /**
  48851. * Number of samples to use for antialiasing
  48852. */
  48853. textureSamples: number;
  48854. /**
  48855. * Ratio object used for SSAO ratio and blur ratio
  48856. */
  48857. private _ratio;
  48858. /**
  48859. * Dynamically generated sphere sampler.
  48860. */
  48861. private _sampleSphere;
  48862. /**
  48863. * Blur filter offsets
  48864. */
  48865. private _samplerOffsets;
  48866. private _expensiveBlur;
  48867. /**
  48868. * If bilateral blur should be used
  48869. */
  48870. expensiveBlur: boolean;
  48871. /**
  48872. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  48873. */
  48874. radius: number;
  48875. /**
  48876. * The base color of the SSAO post-process
  48877. * The final result is "base + ssao" between [0, 1]
  48878. */
  48879. base: number;
  48880. /**
  48881. * Support test.
  48882. */
  48883. static readonly IsSupported: boolean;
  48884. private _scene;
  48885. private _depthTexture;
  48886. private _normalTexture;
  48887. private _randomTexture;
  48888. private _originalColorPostProcess;
  48889. private _ssaoPostProcess;
  48890. private _blurHPostProcess;
  48891. private _blurVPostProcess;
  48892. private _ssaoCombinePostProcess;
  48893. private _firstUpdate;
  48894. /**
  48895. * @constructor
  48896. * @param name The rendering pipeline name
  48897. * @param scene The scene linked to this pipeline
  48898. * @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 }
  48899. * @param cameras The array of cameras that the rendering pipeline will be attached to
  48900. */
  48901. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  48902. /**
  48903. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  48904. */
  48905. dispose(disableGeometryBufferRenderer?: boolean): void;
  48906. private _createBlurPostProcess;
  48907. /** @hidden */
  48908. _rebuild(): void;
  48909. private _bits;
  48910. private _radicalInverse_VdC;
  48911. private _hammersley;
  48912. private _hemisphereSample_uniform;
  48913. private _generateHemisphere;
  48914. private _createSSAOPostProcess;
  48915. private _createSSAOCombinePostProcess;
  48916. private _createRandomTexture;
  48917. /**
  48918. * Serialize the rendering pipeline (Used when exporting)
  48919. * @returns the serialized object
  48920. */
  48921. serialize(): any;
  48922. /**
  48923. * Parse the serialized pipeline
  48924. * @param source Source pipeline.
  48925. * @param scene The scene to load the pipeline to.
  48926. * @param rootUrl The URL of the serialized pipeline.
  48927. * @returns An instantiated pipeline from the serialized object.
  48928. */
  48929. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  48930. }
  48931. }
  48932. declare module BABYLON {
  48933. /**
  48934. * Render pipeline to produce ssao effect
  48935. */
  48936. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  48937. /**
  48938. * @ignore
  48939. * The PassPostProcess id in the pipeline that contains the original scene color
  48940. */
  48941. SSAOOriginalSceneColorEffect: string;
  48942. /**
  48943. * @ignore
  48944. * The SSAO PostProcess id in the pipeline
  48945. */
  48946. SSAORenderEffect: string;
  48947. /**
  48948. * @ignore
  48949. * The horizontal blur PostProcess id in the pipeline
  48950. */
  48951. SSAOBlurHRenderEffect: string;
  48952. /**
  48953. * @ignore
  48954. * The vertical blur PostProcess id in the pipeline
  48955. */
  48956. SSAOBlurVRenderEffect: string;
  48957. /**
  48958. * @ignore
  48959. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  48960. */
  48961. SSAOCombineRenderEffect: string;
  48962. /**
  48963. * The output strength of the SSAO post-process. Default value is 1.0.
  48964. */
  48965. totalStrength: number;
  48966. /**
  48967. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  48968. */
  48969. radius: number;
  48970. /**
  48971. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  48972. * Must not be equal to fallOff and superior to fallOff.
  48973. * Default value is 0.975
  48974. */
  48975. area: number;
  48976. /**
  48977. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  48978. * Must not be equal to area and inferior to area.
  48979. * Default value is 0.0
  48980. */
  48981. fallOff: number;
  48982. /**
  48983. * The base color of the SSAO post-process
  48984. * The final result is "base + ssao" between [0, 1]
  48985. */
  48986. base: number;
  48987. private _scene;
  48988. private _depthTexture;
  48989. private _randomTexture;
  48990. private _originalColorPostProcess;
  48991. private _ssaoPostProcess;
  48992. private _blurHPostProcess;
  48993. private _blurVPostProcess;
  48994. private _ssaoCombinePostProcess;
  48995. private _firstUpdate;
  48996. /**
  48997. * @constructor
  48998. * @param name - The rendering pipeline name
  48999. * @param scene - The scene linked to this pipeline
  49000. * @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 }
  49001. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  49002. */
  49003. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49004. /**
  49005. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49006. */
  49007. dispose(disableDepthRender?: boolean): void;
  49008. private _createBlurPostProcess;
  49009. /** @hidden */
  49010. _rebuild(): void;
  49011. private _createSSAOPostProcess;
  49012. private _createSSAOCombinePostProcess;
  49013. private _createRandomTexture;
  49014. }
  49015. }
  49016. declare module BABYLON {
  49017. /**
  49018. * Standard rendering pipeline
  49019. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49020. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  49021. */
  49022. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49023. /**
  49024. * Public members
  49025. */
  49026. /**
  49027. * Post-process which contains the original scene color before the pipeline applies all the effects
  49028. */
  49029. originalPostProcess: Nullable<PostProcess>;
  49030. /**
  49031. * Post-process used to down scale an image x4
  49032. */
  49033. downSampleX4PostProcess: Nullable<PostProcess>;
  49034. /**
  49035. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  49036. */
  49037. brightPassPostProcess: Nullable<PostProcess>;
  49038. /**
  49039. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  49040. */
  49041. blurHPostProcesses: PostProcess[];
  49042. /**
  49043. * Post-process array storing all the vertical blur post-processes used by the pipeline
  49044. */
  49045. blurVPostProcesses: PostProcess[];
  49046. /**
  49047. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  49048. */
  49049. textureAdderPostProcess: Nullable<PostProcess>;
  49050. /**
  49051. * Post-process used to create volumetric lighting effect
  49052. */
  49053. volumetricLightPostProcess: Nullable<PostProcess>;
  49054. /**
  49055. * Post-process used to smooth the previous volumetric light post-process on the X axis
  49056. */
  49057. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  49058. /**
  49059. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  49060. */
  49061. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  49062. /**
  49063. * Post-process used to merge the volumetric light effect and the real scene color
  49064. */
  49065. volumetricLightMergePostProces: Nullable<PostProcess>;
  49066. /**
  49067. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  49068. */
  49069. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  49070. /**
  49071. * Base post-process used to calculate the average luminance of the final image for HDR
  49072. */
  49073. luminancePostProcess: Nullable<PostProcess>;
  49074. /**
  49075. * Post-processes used to create down sample post-processes in order to get
  49076. * the average luminance of the final image for HDR
  49077. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  49078. */
  49079. luminanceDownSamplePostProcesses: PostProcess[];
  49080. /**
  49081. * Post-process used to create a HDR effect (light adaptation)
  49082. */
  49083. hdrPostProcess: Nullable<PostProcess>;
  49084. /**
  49085. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  49086. */
  49087. textureAdderFinalPostProcess: Nullable<PostProcess>;
  49088. /**
  49089. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  49090. */
  49091. lensFlareFinalPostProcess: Nullable<PostProcess>;
  49092. /**
  49093. * Post-process used to merge the final HDR post-process and the real scene color
  49094. */
  49095. hdrFinalPostProcess: Nullable<PostProcess>;
  49096. /**
  49097. * Post-process used to create a lens flare effect
  49098. */
  49099. lensFlarePostProcess: Nullable<PostProcess>;
  49100. /**
  49101. * Post-process that merges the result of the lens flare post-process and the real scene color
  49102. */
  49103. lensFlareComposePostProcess: Nullable<PostProcess>;
  49104. /**
  49105. * Post-process used to create a motion blur effect
  49106. */
  49107. motionBlurPostProcess: Nullable<PostProcess>;
  49108. /**
  49109. * Post-process used to create a depth of field effect
  49110. */
  49111. depthOfFieldPostProcess: Nullable<PostProcess>;
  49112. /**
  49113. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49114. */
  49115. fxaaPostProcess: Nullable<FxaaPostProcess>;
  49116. /**
  49117. * Represents the brightness threshold in order to configure the illuminated surfaces
  49118. */
  49119. brightThreshold: number;
  49120. /**
  49121. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  49122. */
  49123. blurWidth: number;
  49124. /**
  49125. * Sets if the blur for highlighted surfaces must be only horizontal
  49126. */
  49127. horizontalBlur: boolean;
  49128. /**
  49129. * Sets the overall exposure used by the pipeline
  49130. */
  49131. exposure: number;
  49132. /**
  49133. * Texture used typically to simulate "dirty" on camera lens
  49134. */
  49135. lensTexture: Nullable<Texture>;
  49136. /**
  49137. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  49138. */
  49139. volumetricLightCoefficient: number;
  49140. /**
  49141. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  49142. */
  49143. volumetricLightPower: number;
  49144. /**
  49145. * Used the set the blur intensity to smooth the volumetric lights
  49146. */
  49147. volumetricLightBlurScale: number;
  49148. /**
  49149. * Light (spot or directional) used to generate the volumetric lights rays
  49150. * The source light must have a shadow generate so the pipeline can get its
  49151. * depth map
  49152. */
  49153. sourceLight: Nullable<SpotLight | DirectionalLight>;
  49154. /**
  49155. * For eye adaptation, represents the minimum luminance the eye can see
  49156. */
  49157. hdrMinimumLuminance: number;
  49158. /**
  49159. * For eye adaptation, represents the decrease luminance speed
  49160. */
  49161. hdrDecreaseRate: number;
  49162. /**
  49163. * For eye adaptation, represents the increase luminance speed
  49164. */
  49165. hdrIncreaseRate: number;
  49166. /**
  49167. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  49168. */
  49169. lensColorTexture: Nullable<Texture>;
  49170. /**
  49171. * The overall strengh for the lens flare effect
  49172. */
  49173. lensFlareStrength: number;
  49174. /**
  49175. * Dispersion coefficient for lens flare ghosts
  49176. */
  49177. lensFlareGhostDispersal: number;
  49178. /**
  49179. * Main lens flare halo width
  49180. */
  49181. lensFlareHaloWidth: number;
  49182. /**
  49183. * Based on the lens distortion effect, defines how much the lens flare result
  49184. * is distorted
  49185. */
  49186. lensFlareDistortionStrength: number;
  49187. /**
  49188. * Lens star texture must be used to simulate rays on the flares and is available
  49189. * in the documentation
  49190. */
  49191. lensStarTexture: Nullable<Texture>;
  49192. /**
  49193. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  49194. * flare effect by taking account of the dirt texture
  49195. */
  49196. lensFlareDirtTexture: Nullable<Texture>;
  49197. /**
  49198. * Represents the focal length for the depth of field effect
  49199. */
  49200. depthOfFieldDistance: number;
  49201. /**
  49202. * Represents the blur intensity for the blurred part of the depth of field effect
  49203. */
  49204. depthOfFieldBlurWidth: number;
  49205. /**
  49206. * For motion blur, defines how much the image is blurred by the movement
  49207. */
  49208. motionStrength: number;
  49209. /**
  49210. * List of animations for the pipeline (IAnimatable implementation)
  49211. */
  49212. animations: Animation[];
  49213. /**
  49214. * Private members
  49215. */
  49216. private _scene;
  49217. private _currentDepthOfFieldSource;
  49218. private _basePostProcess;
  49219. private _hdrCurrentLuminance;
  49220. private _floatTextureType;
  49221. private _ratio;
  49222. private _bloomEnabled;
  49223. private _depthOfFieldEnabled;
  49224. private _vlsEnabled;
  49225. private _lensFlareEnabled;
  49226. private _hdrEnabled;
  49227. private _motionBlurEnabled;
  49228. private _fxaaEnabled;
  49229. private _motionBlurSamples;
  49230. private _volumetricLightStepsCount;
  49231. private _samples;
  49232. /**
  49233. * @ignore
  49234. * Specifies if the bloom pipeline is enabled
  49235. */
  49236. BloomEnabled: boolean;
  49237. /**
  49238. * @ignore
  49239. * Specifies if the depth of field pipeline is enabed
  49240. */
  49241. DepthOfFieldEnabled: boolean;
  49242. /**
  49243. * @ignore
  49244. * Specifies if the lens flare pipeline is enabed
  49245. */
  49246. LensFlareEnabled: boolean;
  49247. /**
  49248. * @ignore
  49249. * Specifies if the HDR pipeline is enabled
  49250. */
  49251. HDREnabled: boolean;
  49252. /**
  49253. * @ignore
  49254. * Specifies if the volumetric lights scattering effect is enabled
  49255. */
  49256. VLSEnabled: boolean;
  49257. /**
  49258. * @ignore
  49259. * Specifies if the motion blur effect is enabled
  49260. */
  49261. MotionBlurEnabled: boolean;
  49262. /**
  49263. * Specifies if anti-aliasing is enabled
  49264. */
  49265. fxaaEnabled: boolean;
  49266. /**
  49267. * Specifies the number of steps used to calculate the volumetric lights
  49268. * Typically in interval [50, 200]
  49269. */
  49270. volumetricLightStepsCount: number;
  49271. /**
  49272. * Specifies the number of samples used for the motion blur effect
  49273. * Typically in interval [16, 64]
  49274. */
  49275. motionBlurSamples: number;
  49276. /**
  49277. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49278. */
  49279. samples: number;
  49280. /**
  49281. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49282. * @constructor
  49283. * @param name The rendering pipeline name
  49284. * @param scene The scene linked to this pipeline
  49285. * @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)
  49286. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  49287. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49288. */
  49289. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  49290. private _buildPipeline;
  49291. private _createDownSampleX4PostProcess;
  49292. private _createBrightPassPostProcess;
  49293. private _createBlurPostProcesses;
  49294. private _createTextureAdderPostProcess;
  49295. private _createVolumetricLightPostProcess;
  49296. private _createLuminancePostProcesses;
  49297. private _createHdrPostProcess;
  49298. private _createLensFlarePostProcess;
  49299. private _createDepthOfFieldPostProcess;
  49300. private _createMotionBlurPostProcess;
  49301. private _getDepthTexture;
  49302. private _disposePostProcesses;
  49303. /**
  49304. * Dispose of the pipeline and stop all post processes
  49305. */
  49306. dispose(): void;
  49307. /**
  49308. * Serialize the rendering pipeline (Used when exporting)
  49309. * @returns the serialized object
  49310. */
  49311. serialize(): any;
  49312. /**
  49313. * Parse the serialized pipeline
  49314. * @param source Source pipeline.
  49315. * @param scene The scene to load the pipeline to.
  49316. * @param rootUrl The URL of the serialized pipeline.
  49317. * @returns An instantiated pipeline from the serialized object.
  49318. */
  49319. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  49320. /**
  49321. * Luminance steps
  49322. */
  49323. static LuminanceSteps: number;
  49324. }
  49325. }